OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
WPropertyBase Class Referenceabstract

Abstract base class for all properties. More...

#include <WPropertyBase.h>

+ Inheritance diagram for WPropertyBase:
+ Collaboration diagram for WPropertyBase:

Public Types

typedef std::shared_ptr< WPropertyBaseSPtr
 Convenience typedef for a std::shared_ptr< WPropertyBase > More...
 
typedef std::shared_ptr< const WPropertyBaseConstSPtr
 Convenience typedef for a std::shared_ptr< const WPropertyBase > More...
 
typedef boost::function< void(std::shared_ptr< WPropertyBase >)> PropertyChangeNotifierType
 Signal signature emitted during set operations. More...
 

Public Member Functions

 WPropertyBase (std::string name, std::string description)
 Create an empty named property. More...
 
 WPropertyBase (const WPropertyBase &from)
 Copy constructor. More...
 
virtual ~WPropertyBase ()
 Destructor. More...
 
virtual std::shared_ptr< WPropertyBaseclone ()=0
 This method clones a property and returns the clone. More...
 
std::string getName () const
 Gets the name of the class. More...
 
std::string getDescription () const
 Gets the description of the property. More...
 
bool isHidden () const
 Determines whether the property is hidden or not. More...
 
void setHidden (bool hidden=true)
 Sets the property hidden. More...
 
virtual PROPERTY_TYPE getType () const
 Gets the real WPropertyVariable type of this instance. More...
 
virtual PROPERTY_PURPOSE getPurpose () const
 Gets the purpose of a property. More...
 
virtual void setPurpose (PROPERTY_PURPOSE purpose)
 Sets the purpose of the property. More...
 
virtual bool setAsString (std::string value)=0
 This methods allows properties to be set by a string value. More...
 
virtual std::string getAsString ()=0
 Returns the current value as a string. More...
 
template<typename T >
bool set (const T &value)
 Shortcut to set a property with a given value. More...
 
virtual std::shared_ptr< WConditiongetUpdateCondition () const
 This method returns a condition which gets fired whenever the property changes somehow. More...
 
virtual bool set (std::shared_ptr< WPropertyBase > value, bool recommendedOnly=false)=0
 Sets the value from the specified property to this one. More...
 
WPropInt toPropInt ()
 Helper converts this instance to its native type. More...
 
WPropDouble toPropDouble ()
 Helper converts this instance to its native type. More...
 
WPropBool toPropBool ()
 Helper converts this instance to its native type. More...
 
WPropString toPropString ()
 Helper converts this instance to its native type. More...
 
WPropFilename toPropFilename ()
 Helper converts this instance to its native type. More...
 
WPropSelection toPropSelection ()
 Helper converts this instance to its native type. More...
 
WPropColor toPropColor ()
 Helper converts this instance to its native type. More...
 
WPropPosition toPropPosition ()
 Helper converts this instance to its native type. More...
 
WPropTrigger toPropTrigger ()
 Helper converts this instance to its native type. More...
 
WPropMatrix4X4 toPropMatrix4X4 ()
 Helper converts this instance to its native type. More...
 
WPropTransferFunction toPropTransferFunction ()
 Helper converts this instance to its native type. More...
 
WPropGroup toPropGroup ()
 Helper converts this instance to its native type. More...
 
WPropInterval toPropInterval ()
 Helper converts this instance to its native type. More...
 
std::shared_ptr< WPropertyGroupBasetoPropGroupBase ()
 Convert the property to a WPropertyGroupBase. More...
 
template<typename T >
std::shared_ptr< WPropertyVariable< T > > toPropertyVariable ()
 Helper converts this instance to an arbitrary type. More...
 

Protected Types

typedef boost::signals2::signal< void(std::shared_ptr< WPropertyBase >)> PropertyChangeSignalType
 Signal used for firing change signals. More...
 

Protected Member Functions

virtual void updateType ()
 Calculates the type of the property. More...
 

Protected Attributes

std::string m_name
 Name of the property. More...
 
std::string m_description
 Description of the property. More...
 
bool m_hidden
 Flag denoting whether the property is hidden or not. More...
 
PROPERTY_TYPE m_type
 Type of the PropertyVariable instance. More...
 
PROPERTY_PURPOSE m_purpose
 The purpose of this property. More...
 
PropertyChangeSignalType signal_PropertyChange
 Signal getting fired whenever the property changes. More...
 
std::shared_ptr< WConditionSetm_updateCondition
 Condition notified whenever something changes. More...
 

Detailed Description

Abstract base class for all properties.

Simply provides name and type information.

Definition at line 47 of file WPropertyBase.h.

Member Typedef Documentation

◆ ConstSPtr

typedef std::shared_ptr< const WPropertyBase > WPropertyBase::ConstSPtr

Convenience typedef for a std::shared_ptr< const WPropertyBase >

Definition at line 58 of file WPropertyBase.h.

◆ PropertyChangeNotifierType

typedef boost::function<void ( std::shared_ptr< WPropertyBase > )> WPropertyBase::PropertyChangeNotifierType

Signal signature emitted during set operations.

Definition at line 318 of file WPropertyBase.h.

◆ PropertyChangeSignalType

typedef boost::signals2::signal<void ( std::shared_ptr< WPropertyBase > )> WPropertyBase::PropertyChangeSignalType
protected

Signal used for firing change signals.

Definition at line 354 of file WPropertyBase.h.

◆ SPtr

typedef std::shared_ptr< WPropertyBase > WPropertyBase::SPtr

Convenience typedef for a std::shared_ptr< WPropertyBase >

Definition at line 53 of file WPropertyBase.h.

Constructor & Destructor Documentation

◆ WPropertyBase() [1/2]

WPropertyBase::WPropertyBase ( std::string  name,
std::string  description 
)

Create an empty named property.

Parameters
namethe name of the property
descriptionthe description of the property

Definition at line 38 of file WPropertyBase.cpp.

References m_name.

◆ WPropertyBase() [2/2]

WPropertyBase::WPropertyBase ( const WPropertyBase from)
explicit

Copy constructor.

Creates a deep copy of this property. As boost::signals2 and condition variables are non-copyable, new instances get created. The subscriptions to a signal are LOST as well as all listeners to a condition.

Parameters
fromthe instance to copy.

Definition at line 55 of file WPropertyBase.cpp.

◆ ~WPropertyBase()

WPropertyBase::~WPropertyBase ( )
virtual

Destructor.

Definition at line 67 of file WPropertyBase.cpp.

Member Function Documentation

◆ clone()

virtual std::shared_ptr< WPropertyBase > WPropertyBase::clone ( )
pure virtual

This method clones a property and returns the clone.

It does a deep copy and, in contrast to a copy constructor, creates property with the correct type without explicitly requiring the user to specify it. It creates a NEW change condition and change signal. This means, alls subscribed signal handlers are NOT copied.

Note
this simply ensures the copy constructor of the runtime type is issued.
Returns
the deep clone of this property.

Implemented in WPropertyVariable< T >, WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, WPropertyList< T >, and WPropertyGroup.

◆ getAsString()

virtual std::string WPropertyBase::getAsString ( )
pure virtual

Returns the current value as a string.

This is useful for debugging or project files. It is not implemented as << operator, since the << should also print min/max constraints and so on. This simply is the value.

Returns
the value as a string.

Implemented in WPropertyVariable< T >, WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, WPropertyList< T >, and WPropertyGroup.

◆ getDescription()

std::string WPropertyBase::getDescription ( ) const

Gets the description of the property.

Returns
the description

Definition at line 77 of file WPropertyBase.cpp.

References m_description.

◆ getName()

std::string WPropertyBase::getName ( ) const

Gets the name of the class.

Returns
the name.

Definition at line 72 of file WPropertyBase.cpp.

References m_name.

Referenced by WPropertyGroupBase::addArbitraryProperty().

+ Here is the caller graph for this function:

◆ getPurpose()

PROPERTY_PURPOSE WPropertyBase::getPurpose ( ) const
virtual

Gets the purpose of a property.

See PROPERTY_PURPOSE for more details. For short: it helps the GUI and others to understand what a module (or whomever created this property) intents with this property. Typically this value is PV_PURPOSE_PARAMETER, meaning that it is used to tune the behaviour of a module.

Note
always assume this to be a hint. It does not actually prevent someone from writing or interpreting a parameter property as an information property.
See also
PROPERTY_PURPOSE
Returns
the purpose.

Definition at line 87 of file WPropertyBase.cpp.

References m_purpose.

Referenced by WPropertyGroupBase::addArbitraryProperty().

+ Here is the caller graph for this function:

◆ getType()

PROPERTY_TYPE WPropertyBase::getType ( ) const
virtual

Gets the real WPropertyVariable type of this instance.

Returns
the real type.

Reimplemented in WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, WPropertyList< T >, and WPropertyGroup.

Definition at line 82 of file WPropertyBase.cpp.

References m_type.

◆ getUpdateCondition()

std::shared_ptr< WCondition > WPropertyBase::getUpdateCondition ( ) const
virtual

This method returns a condition which gets fired whenever the property changes somehow.

It is fired when:

Returns
a condition notified whenever something changes.

Definition at line 181 of file WPropertyBase.cpp.

References m_updateCondition.

◆ isHidden()

bool WPropertyBase::isHidden ( ) const

Determines whether the property is hidden or not.

Returns
true if hidden

Definition at line 102 of file WPropertyBase.cpp.

References m_hidden.

◆ set() [1/2]

template<typename T >
bool WPropertyBase::set ( const T &  value)

Shortcut to set a property with a given value.

This basically is a shortcut to setAsString with the value being cast to string.

Template Parameters
Ttype of the input value
Parameters
valuethe value to set
Returns
true if successful.

Definition at line 377 of file WPropertyBase.h.

References setAsString(), and string_utils::toString().

+ Here is the call graph for this function:

◆ set() [2/2]

virtual bool WPropertyBase::set ( std::shared_ptr< WPropertyBase value,
bool  recommendedOnly = false 
)
pure virtual

Sets the value from the specified property to this one.

This is especially useful to copy a value without explicitly casting/knowing the dynamic type of the property.

Parameters
valuethe new value.
recommendedOnlyif true, property types which support recommended values apply the given value as recommendation.
Returns
true if the value has been accepted.

Implemented in WPropertyVariable< T >, WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, and WPropertyGroup.

◆ setAsString()

virtual bool WPropertyBase::setAsString ( std::string  value)
pure virtual

This methods allows properties to be set by a string value.

This is especially useful when a property is only available as string and the real type of the property is unknown. This is a shortcut for casting the property and then setting the lexically casted value.

Parameters
valuethe new value to set.
Returns
true if value could be set.

Implemented in WPropertyVariable< T >, WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, WPropertyList< T >, and WPropertyGroup.

Referenced by set().

+ Here is the caller graph for this function:

◆ setHidden()

void WPropertyBase::setHidden ( bool  hidden = true)

Sets the property hidden.

This flag is especially used by the GUI.

Parameters
hiddentrue if it should be hidden.

Definition at line 107 of file WPropertyBase.cpp.

References m_hidden, and m_updateCondition.

◆ setPurpose()

void WPropertyBase::setPurpose ( PROPERTY_PURPOSE  purpose)
virtual

Sets the purpose of the property.

See getPurpose for more details. You generally should avoid setting this value after initialization.

Parameters
purposethe purpose to set.

Definition at line 92 of file WPropertyBase.cpp.

References m_purpose.

◆ toPropBool()

WPropBool WPropertyBase::toPropBool ( )

Helper converts this instance to its native type.

Returns
the property as bool property

Definition at line 126 of file WPropertyBase.cpp.

◆ toPropColor()

WPropColor WPropertyBase::toPropColor ( )

Helper converts this instance to its native type.

Returns
the property as color property

Definition at line 146 of file WPropertyBase.cpp.

◆ toPropDouble()

WPropDouble WPropertyBase::toPropDouble ( )

Helper converts this instance to its native type.

Returns
the property as double property

Definition at line 121 of file WPropertyBase.cpp.

◆ toPropertyVariable()

template<typename T >
std::shared_ptr< WPropertyVariable< T > > WPropertyBase::toPropertyVariable

Helper converts this instance to an arbitrary type.

Returns
the property of given type of NULL if not valid type

Definition at line 371 of file WPropertyBase.h.

◆ toPropFilename()

WPropFilename WPropertyBase::toPropFilename ( )

Helper converts this instance to its native type.

Returns
the property as path property

Definition at line 136 of file WPropertyBase.cpp.

◆ toPropGroup()

WPropGroup WPropertyBase::toPropGroup ( )

Helper converts this instance to its native type.

Returns
the property as group

Definition at line 156 of file WPropertyBase.cpp.

◆ toPropGroupBase()

WPropertyGroupBase::SPtr WPropertyBase::toPropGroupBase ( )

Convert the property to a WPropertyGroupBase.

This can be done with property structs and groups-

Returns
the property as base group.

Definition at line 161 of file WPropertyBase.cpp.

Referenced by WPropertyGroupBase::findProperty().

+ Here is the caller graph for this function:

◆ toPropInt()

WPropInt WPropertyBase::toPropInt ( )

Helper converts this instance to its native type.

Returns
the property as integer property

Definition at line 116 of file WPropertyBase.cpp.

◆ toPropInterval()

WPropInterval WPropertyBase::toPropInterval ( )

Helper converts this instance to its native type.

Returns
the property as interval property

Definition at line 186 of file WPropertyBase.cpp.

◆ toPropMatrix4X4()

WPropMatrix4X4 WPropertyBase::toPropMatrix4X4 ( )

Helper converts this instance to its native type.

Returns
the property as matrix4x4 property

Definition at line 166 of file WPropertyBase.cpp.

◆ toPropPosition()

WPropPosition WPropertyBase::toPropPosition ( )

Helper converts this instance to its native type.

Returns
the property as position property

Definition at line 151 of file WPropertyBase.cpp.

◆ toPropSelection()

WPropSelection WPropertyBase::toPropSelection ( )

Helper converts this instance to its native type.

Returns
the property as selection property

Definition at line 141 of file WPropertyBase.cpp.

◆ toPropString()

WPropString WPropertyBase::toPropString ( )

Helper converts this instance to its native type.

Returns
the property as string property

Definition at line 131 of file WPropertyBase.cpp.

◆ toPropTransferFunction()

WPropTransferFunction WPropertyBase::toPropTransferFunction ( )

Helper converts this instance to its native type.

Returns
the property as transfer function property

Definition at line 176 of file WPropertyBase.cpp.

◆ toPropTrigger()

WPropTrigger WPropertyBase::toPropTrigger ( )

Helper converts this instance to its native type.

Returns
the property as trigger property

Definition at line 171 of file WPropertyBase.cpp.

◆ updateType()

void WPropertyBase::updateType ( )
protectedvirtual

Calculates the type of the property.

This has to be done by the implementing class.

Reimplemented in WPropertyVariable< T >.

Definition at line 97 of file WPropertyBase.cpp.

References m_type.

Member Data Documentation

◆ m_description

std::string WPropertyBase::m_description
protected

Description of the property.

Definition at line 329 of file WPropertyBase.h.

Referenced by getDescription().

◆ m_hidden

bool WPropertyBase::m_hidden
protected

Flag denoting whether the property is hidden or not.

Definition at line 334 of file WPropertyBase.h.

Referenced by isHidden(), and setHidden().

◆ m_name

std::string WPropertyBase::m_name
protected

Name of the property.

Definition at line 324 of file WPropertyBase.h.

Referenced by getName(), and WPropertyBase().

◆ m_purpose

PROPERTY_PURPOSE WPropertyBase::m_purpose
protected

The purpose of this property.

PropertyBase always initializes it with PV_PURPOSE_PARAMETER.

Definition at line 344 of file WPropertyBase.h.

Referenced by getPurpose(), and setPurpose().

◆ m_type

PROPERTY_TYPE WPropertyBase::m_type
protected

Type of the PropertyVariable instance.

Definition at line 339 of file WPropertyBase.h.

Referenced by getType(), and updateType().

◆ m_updateCondition

std::shared_ptr< WConditionSet > WPropertyBase::m_updateCondition
protected

Condition notified whenever something changes.

See getUpdateCondition for more details.

See also
getUpdateCondition

Definition at line 365 of file WPropertyBase.h.

Referenced by WPropertyGroupBase::addArbitraryProperty(), getUpdateCondition(), WPropertyGroup::removeProperty(), setHidden(), WPropertyGroupBase::WPropertyGroupBase(), and WPropertyVariable< T >::WPropertyVariable().

◆ signal_PropertyChange

PropertyChangeSignalType WPropertyBase::signal_PropertyChange
protected

Signal getting fired whenever the property changes.

Definition at line 359 of file WPropertyBase.h.

Referenced by WPropertyVariable< T >::WPropertyVariable().


The documentation for this class was generated from the following files: