OpenWalnut  1.5.0dev
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
WPropertyVariable< T > Class Template Reference

A named property class with a concrete type. More...

#include <WPropertyVariable.h>

+ Inheritance diagram for WPropertyVariable< T >:
+ Collaboration diagram for WPropertyVariable< T >:

Classes

class  PropertyConstraint
 Class building the base for user defined constraints on a property instance. More...
 

Public Types

typedef std::shared_ptr< WPropertyVariable< T > > SPtr
 Convenience typedef for a shared_ptr of WPropertyVariable. More...
 
typedef std::shared_ptr< const WPropertyVariable< T > > ConstSPtr
 Convenience typedef for a shared_ptr of const WPropertyVariable. More...
 
typedef T DataType
 The type of the data of this property. More...
 
typedef WSharedAssociativeContainer< std::set< std::shared_ptr< PropertyConstraint > > > ConstraintContainerType
 The alias for a shared container. More...
 
typedef std::shared_ptr< WPropertyConstraintMin< T > > PropertyConstraintMin
 Alias for min constraints. More...
 
typedef std::shared_ptr< WPropertyConstraintMax< T > > PropertyConstraintMax
 Alias for max constraints. More...
 
- Public Types inherited from WFlag< T >
typedef T ValueType
 The type for later access. More...
 
typedef std::shared_ptr< WFlag< T > > SPtr
 Convenience typedef for a std::shared_ptr. More...
 
typedef std::shared_ptr< const WFlag< T > > ConstSPtr
 Convenience typedef for a std::shared_ptr. More...
 
- Public Types inherited from WPropertyBase
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

 WPropertyVariable (std::string name, std::string description, const T &initial)
 Create an empty instance just containing a name. More...
 
 WPropertyVariable (std::string name, std::string description, const T &initial, std::shared_ptr< WCondition > condition)
 Create an empty instance just containing a name. More...
 
 WPropertyVariable (std::string name, std::string description, const T &initial, PropertyChangeNotifierType notifier)
 Create an empty instance just containing a name. More...
 
 WPropertyVariable (std::string name, std::string description, const T &initial, std::shared_ptr< WCondition > condition, PropertyChangeNotifierType notifier)
 Create an empty instance just containing a name. More...
 
 WPropertyVariable (const WPropertyVariable< T > &from)
 Copy constructor. More...
 
virtual ~WPropertyVariable ()
 Destructor. More...
 
virtual std::shared_ptr< WPropertyBaseclone ()
 This method clones a property and returns the clone. More...
 
virtual bool accept (const T &newValue)
 Determines whether the specified value is acceptable. More...
 
virtual bool ensureValidity (const T &newValidValue, bool suppressNotification=false)
 This method is useful to ensure, that there is a valid value in the property. More...
 
void addConstraint (std::shared_ptr< PropertyConstraint > constraint)
 Add a new constraint. More...
 
ConstraintContainerType getConstraints ()
 Returns all the current constraints of a WPropertyVariable. More...
 
std::shared_ptr< WConditiongetContraintsChangedCondition ()
 Gets the condition, which gets notified whenever the list of constraints changes. More...
 
PropertyConstraintMin setMin (const T &min)
 Set a minimum constraint. More...
 
PropertyConstraintMax setMax (const T &max)
 Set a maximum constraint. More...
 
PropertyConstraintMin getMin ()
 Gets the current minimum constraint value. More...
 
PropertyConstraintMax getMax ()
 Gets the current maximum constraint value. More...
 
void replaceConstraint (std::shared_ptr< PropertyConstraint > constraint, PROPERTYCONSTRAINT_TYPE type)
 This replaces all existing constraints of a certain type by a new specified constraint. More...
 
std::shared_ptr< PropertyConstraintreplaceConstraint (PROPERTYCONSTRAINT_TYPE constraint, PROPERTYCONSTRAINT_TYPE type)
 This replaces all existing constraints of a certain type by a new specified constraint. More...
 
void removeConstraint (PROPERTYCONSTRAINT_TYPE type)
 Cleans list of constraints from all existing constrains of the specified type. More...
 
void removeConstraint (std::shared_ptr< PropertyConstraint > constraint)
 Removes the specified constraint if existent. More...
 
std::shared_ptr< PropertyConstraintgetFirstConstraint (PROPERTYCONSTRAINT_TYPE type)
 Method searching the first appearance of a constrained with the specified type. More...
 
int countConstraint (PROPERTYCONSTRAINT_TYPE type)
 Method searching the first appearance of a constrained with the specified type. More...
 
virtual bool setAsString (std::string value)
 This methods allows properties to be set by a string value. More...
 
virtual std::string getAsString ()
 Returns the current value as a string. More...
 
virtual bool set (std::shared_ptr< WPropertyBase > value, bool recommendedOnly=false)
 Sets the value from the specified property to this one. More...
 
virtual bool set (const T &value, bool suppressNotification=false)
 Sets the new value for this flag. More...
 
virtual bool setRecommendedValue (const T &value)
 Sets the specified value as recommended value. More...
 
- Public Member Functions inherited from WFlag< T >
 WFlag (WCondition *condition, const T &initial)
 Constructor. More...
 
 WFlag (std::shared_ptr< WCondition > condition, const T &initial)
 Constructor. More...
 
 WFlag (const WFlag &from)
 Copy constructor. More...
 
virtual ~WFlag ()
 Destructor. More...
 
virtual const T & get (bool resetChangeState=false)
 Operator returns value of the flag. More...
 
virtual const T & get () const
 Operator returns value of the flag. More...
 
virtual const T & operator() () const
 Operator returns value of the flag. More...
 
virtual operator T () const
 Operator returns value of the flag. More...
 
virtual void wait () const
 Wait for the flag to change its value. More...
 
virtual void operator() (const T &value)
 Sets the new value for this flag. More...
 
std::shared_ptr< WConditiongetCondition ()
 Returns the condition that is used by this flag. More...
 
std::shared_ptr< WConditiongetValueChangeCondition ()
 Returns the condition denoting a value change. More...
 
virtual bool isValid ()
 Tests whether a flag is currently valid. More...
 
virtual bool changed (bool reset=false)
 True whenever the value inside this flag has changed since the last reset. More...
 
- Public Member Functions inherited from WPropertyBase
 WPropertyBase (std::string name, std::string description)
 Create an empty named property. More...
 
 WPropertyBase (const WPropertyBase &from)
 Copy constructor. More...
 
virtual ~WPropertyBase ()
 Destructor. 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...
 
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...
 
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...
 

Static Public Member Functions

static PropertyConstraintMin minConstraint (const T &min)
 Creates a new WPropertyConstraintMin for this WPropertyVariable. More...
 
static PropertyConstraintMax maxConstraint (const T &max)
 Creates a new WPropertyConstraintMax for this WPropertyVariable. More...
 

Protected Member Functions

virtual void updateType ()
 Uses typeid() to set the proper type constant. More...
 
void removeConstraints (PROPERTYCONSTRAINT_TYPE type, typename WPropertyVariable< T >::ConstraintContainerType::WriteTicket ticket=ConstraintContainerType::WriteTicket())
 Cleans list of constraints from all existing constrains of the specified type. More...
 
void propertyChangeNotifier ()
 This method gets called by WFlag whenever the value of the property changes. More...
 

Protected Attributes

boost::signals2::connection m_notifierConnection
 The connection used for notification. More...
 
std::shared_ptr< ConstraintContainerTypem_constraints
 A set of constraints applied on this property. More...
 
- Protected Attributes inherited from WFlag< T >
std::shared_ptr< WConditionm_condition
 The condition to be used for waiting/notifying. More...
 
std::shared_ptr< WConditionm_valueChangeCondition
 This condition is fired whenever the value changes. More...
 
m_flag
 The flag value. More...
 
bool m_changed
 Denotes whether the value has changed since the last reset. More...
 
- Protected Attributes inherited from WPropertyBase
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...
 

Private Attributes

bool m_notYetSet
 This is true, if the user did not set a value until now using set. More...
 

Friends

class WPropertyVariableTest
 Access for test class. More...
 

Additional Inherited Members

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

Detailed Description

template<typename T>
class WPropertyVariable< T >

A named property class with a concrete type.

Definition at line 54 of file WPropertyVariable.h.

Member Typedef Documentation

◆ ConstraintContainerType

template<typename T >
typedef WSharedAssociativeContainer< std::set< std::shared_ptr< PropertyConstraint > > > WPropertyVariable< T >::ConstraintContainerType

The alias for a shared container.

Definition at line 227 of file WPropertyVariable.h.

◆ ConstSPtr

template<typename T >
typedef std::shared_ptr< const WPropertyVariable< T > > WPropertyVariable< T >::ConstSPtr

Convenience typedef for a shared_ptr of const WPropertyVariable.

Definition at line 67 of file WPropertyVariable.h.

◆ DataType

template<typename T >
typedef T WPropertyVariable< T >::DataType

The type of the data of this property.

Definition at line 70 of file WPropertyVariable.h.

◆ PropertyConstraintMax

template<typename T >
typedef std::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::PropertyConstraintMax

Alias for max constraints.

It is an alias for convenience.

Definition at line 237 of file WPropertyVariable.h.

◆ PropertyConstraintMin

template<typename T >
typedef std::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::PropertyConstraintMin

Alias for min constraints.

It is an alias for convenience.

Definition at line 232 of file WPropertyVariable.h.

◆ SPtr

template<typename T >
typedef std::shared_ptr< WPropertyVariable< T > > WPropertyVariable< T >::SPtr

Convenience typedef for a shared_ptr of WPropertyVariable.

Definition at line 62 of file WPropertyVariable.h.

Constructor & Destructor Documentation

◆ WPropertyVariable() [1/5]

template<typename T >
WPropertyVariable< T >::WPropertyVariable ( std::string  name,
std::string  description,
const T &  initial 
)

Create an empty instance just containing a name.

Parameters
namethe property name
descriptionthe property description
initialthe initial value

Definition at line 453 of file WPropertyVariable.h.

References WPropertyVariable< T >::m_constraints, WPropertyBase::m_updateCondition, and WPropertyVariable< T >::updateType().

+ Here is the call graph for this function:

◆ WPropertyVariable() [2/5]

template<typename T >
WPropertyVariable< T >::WPropertyVariable ( std::string  name,
std::string  description,
const T &  initial,
std::shared_ptr< WCondition condition 
)

Create an empty instance just containing a name.

This constructor allows an external condition to be used for notifiaction. This is practical if one would like to share a condition among several properties.

Parameters
namethe property name
descriptionthe property description
initialthe initial value
conditionuse this external condition for notification.

Definition at line 467 of file WPropertyVariable.h.

References WPropertyVariable< T >::m_constraints, WPropertyBase::m_updateCondition, and WPropertyVariable< T >::updateType().

+ Here is the call graph for this function:

◆ WPropertyVariable() [3/5]

template<typename T >
WPropertyVariable< T >::WPropertyVariable ( std::string  name,
std::string  description,
const T &  initial,
PropertyChangeNotifierType  notifier 
)

Create an empty instance just containing a name.

This constructor allows an external callback to be used for notification.

Parameters
namethe property name
descriptionthe property description
initialthe initial value
notifieruse this notifier for change callbacks.
Note
: instead of setting another notifier, you should consider using the callbacks the condition offers.
: the notifiers gets connected to the notification callback of the internal condition. So be careful when using the condition ( getCondition() ) for other properties, since they would also share the callbacks

Definition at line 481 of file WPropertyVariable.h.

References WFlag< T >::getValueChangeCondition(), WPropertyVariable< T >::m_constraints, WPropertyVariable< T >::m_notifierConnection, WPropertyBase::m_updateCondition, WPropertyBase::signal_PropertyChange, and WPropertyVariable< T >::updateType().

+ Here is the call graph for this function:

◆ WPropertyVariable() [4/5]

template<typename T >
WPropertyVariable< T >::WPropertyVariable ( std::string  name,
std::string  description,
const T &  initial,
std::shared_ptr< WCondition condition,
PropertyChangeNotifierType  notifier 
)

Create an empty instance just containing a name.

This constructor allows an external callback and condition to be used for notification.

Parameters
namethe property name
descriptionthe property description
initialthe initial value
notifieruse this notifier for change callbacks.
conditionuse this external condition for notification
Note
: instead of setting another notifier, you should consider using the callbacks the condition offers.
: the notifiers gets connected to the notification callback of the internal condition. So be careful when using the condition ( getCondition() ) for other properties, since they would also share the callbacks

Definition at line 502 of file WPropertyVariable.h.

References WFlag< T >::getValueChangeCondition(), WPropertyVariable< T >::m_constraints, WPropertyVariable< T >::m_notifierConnection, WPropertyBase::m_updateCondition, WPropertyBase::signal_PropertyChange, and WPropertyVariable< T >::updateType().

+ Here is the call graph for this function:

◆ WPropertyVariable() [5/5]

template<typename T >
WPropertyVariable< T >::WPropertyVariable ( const WPropertyVariable< T > &  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. The conditions you can grab using getValueChangeConditon and getCondition are not the same as in the original! This is because the class corresponds to the observer/observable pattern. You won't expect a clone to fire a condition if a original variable is changed (which after cloning is completely decoupled from the clone).

Parameters
fromthe instance to copy.

Definition at line 523 of file WPropertyVariable.h.

References WFlag< T >::get(), WPropertyVariable< T >::m_constraints, and WPropertyBase::m_updateCondition.

+ Here is the call graph for this function:

◆ ~WPropertyVariable()

template<typename T >
WPropertyVariable< T >::~WPropertyVariable
virtual

Destructor.

Definition at line 551 of file WPropertyVariable.h.

References WFlag< T >::get().

+ Here is the call graph for this function:

Member Function Documentation

◆ accept()

template<typename T >
bool WPropertyVariable< T >::accept ( const T &  newValue)
virtual

Determines whether the specified value is acceptable.

Parameters
newValuethe new value.
Returns
true if it is a valid/acceptable value.

Reimplemented from WFlag< T >.

Definition at line 578 of file WPropertyVariable.h.

References WFlag< T >::accept(), and WFlag< T >::get().

+ Here is the call graph for this function:

◆ addConstraint()

template<typename T >
void WPropertyVariable< T >::addConstraint ( std::shared_ptr< PropertyConstraint constraint)

Add a new constraint.

This is useful to disallow several (custom) values for this property.

Parameters
constraintthe new constraint.

Definition at line 678 of file WPropertyVariable.h.

References WFlag< T >::get().

+ Here is the call graph for this function:

◆ clone()

template<typename T >
std::shared_ptr< WPropertyBase > WPropertyVariable< T >::clone
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.

Implements WPropertyBase.

Definition at line 565 of file WPropertyVariable.h.

◆ countConstraint()

template<typename T >
int WPropertyVariable< T >::countConstraint ( PROPERTYCONSTRAINT_TYPE  type)

Method searching the first appearance of a constrained with the specified type.

Parameters
typethe type of the searched constraint
Returns
the constraint, or NULL if none.

Definition at line 768 of file WPropertyVariable.h.

References WFlag< T >::get().

+ Here is the call graph for this function:

◆ ensureValidity()

template<typename T >
bool WPropertyVariable< T >::ensureValidity ( const T &  newValidValue,
bool  suppressNotification = false 
)
virtual

This method is useful to ensure, that there is a valid value in the property.

Assume the following situation. The property p got a min value of 10. p->setMin( 10 ). Now, p gets set by the GUI to 11. Now your module sets another min value: p->setMin( 15 ). As the property already has been set, the property can't decide what to do; it simply stays invalid. To ensure a valid value, you can use this method. It only sets the new value if the old value is invalid.

Parameters
newValidValuethe new value to set.
suppressNotificationtrue to avoid a firing condition.
Returns
true if the new value has been accepted ( if it was valid ) - for short true if the property NOW is valid

Definition at line 665 of file WPropertyVariable.h.

References WFlag< T >::set().

+ Here is the call graph for this function:

◆ getAsString()

template<typename T >
std::string WPropertyVariable< T >::getAsString
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.

Implements WPropertyBase.

Definition at line 609 of file WPropertyVariable.h.

References PROPERTY_TYPE_HELPER::WStringConversion< T >::asString().

+ Here is the call graph for this function:

◆ getConstraints()

template<typename T >
WPropertyVariable< T >::ConstraintContainerType WPropertyVariable< T >::getConstraints

Returns all the current constraints of a WPropertyVariable.

They can be iterated using the provided access object.

Returns
the constraint access object

Definition at line 817 of file WPropertyVariable.h.

◆ getContraintsChangedCondition()

template<typename T >
std::shared_ptr< WCondition > WPropertyVariable< T >::getContraintsChangedCondition

Gets the condition, which gets notified whenever the list of constraints changes.

It is notified AFTER the write lock has been released so a read lock can be acquired in the callback.

Returns
the condition.

Definition at line 689 of file WPropertyVariable.h.

◆ getFirstConstraint()

template<typename T >
std::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint > WPropertyVariable< T >::getFirstConstraint ( PROPERTYCONSTRAINT_TYPE  type)

Method searching the first appearance of a constrained with the specified type.

Parameters
typethe type of the searched constraint
Returns
the constraint, or NULL if none.

Definition at line 750 of file WPropertyVariable.h.

References WFlag< T >::get().

Referenced by WPropertyVariableTest::testConstraintManagement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMax()

template<typename T >
std::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::getMax

Gets the current maximum constraint value.

Returns
the maximum constraint, or NULL if none.

Definition at line 802 of file WPropertyVariable.h.

Referenced by WPropertyVariableTest::testMinMaxWithSetAndAccept().

+ Here is the caller graph for this function:

◆ getMin()

template<typename T >
std::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::getMin

Gets the current minimum constraint value.

Returns
the minimum constraint, or NULL if none.

Definition at line 787 of file WPropertyVariable.h.

◆ maxConstraint()

template<typename T >
std::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::maxConstraint ( const T &  max)
static

Creates a new WPropertyConstraintMax for this WPropertyVariable.

Parameters
maxthe maximum value of the property
Returns
the new constraint.

Definition at line 708 of file WPropertyVariable.h.

◆ minConstraint()

template<typename T >
std::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::minConstraint ( const T &  min)
static

Creates a new WPropertyConstraintMin for this WPropertyVariable.

Parameters
minthe minimum value.
Returns
the new constraint.

Definition at line 702 of file WPropertyVariable.h.

◆ propertyChangeNotifier()

template<typename T >
void WPropertyVariable< T >::propertyChangeNotifier
protected

This method gets called by WFlag whenever the value of the property changes.

It re-emits the signal with a this pointer

Definition at line 571 of file WPropertyVariable.h.

◆ removeConstraint() [1/2]

template<typename T >
void WPropertyVariable< T >::removeConstraint ( PROPERTYCONSTRAINT_TYPE  type)

Cleans list of constraints from all existing constrains of the specified type.

Parameters
typethe type to remove.

Definition at line 866 of file WPropertyVariable.h.

◆ removeConstraint() [2/2]

template<typename T >
void WPropertyVariable< T >::removeConstraint ( std::shared_ptr< PropertyConstraint constraint)

Removes the specified constraint if existent.

Parameters
constraintthe constraint to remove.

Definition at line 873 of file WPropertyVariable.h.

References WFlag< T >::get().

+ Here is the call graph for this function:

◆ removeConstraints()

template<typename T >
void WPropertyVariable< T >::removeConstraints ( PROPERTYCONSTRAINT_TYPE  type,
typename WPropertyVariable< T >::ConstraintContainerType::WriteTicket  ticket = ConstraintContainerType::WriteTicket() 
)
protected

Cleans list of constraints from all existing constrains of the specified type.

Parameters
typethe type to remove.
ticketthe write ticket if already existent.

Definition at line 823 of file WPropertyVariable.h.

References WFlag< T >::get().

+ Here is the call graph for this function:

◆ replaceConstraint() [1/2]

template<typename T >
std::shared_ptr< typename WPropertyVariable< T >::PropertyConstraint > WPropertyVariable< T >::replaceConstraint ( PROPERTYCONSTRAINT_TYPE  constraint,
PROPERTYCONSTRAINT_TYPE  type 
)

This replaces all existing constraints of a certain type by a new specified constraint.

Parameters
constraintthe new constraint
typethe type of constraints to replace
Returns
the constraint created

Definition at line 741 of file WPropertyVariable.h.

◆ replaceConstraint() [2/2]

template<typename T >
void WPropertyVariable< T >::replaceConstraint ( std::shared_ptr< PropertyConstraint constraint,
PROPERTYCONSTRAINT_TYPE  type 
)

This replaces all existing constraints of a certain type by a new specified constraint.

Parameters
constraintthe new constraint
typethe type of constraints to replace

Definition at line 730 of file WPropertyVariable.h.

References WFlag< T >::get().

+ Here is the call graph for this function:

◆ set() [1/2]

template<typename T >
bool WPropertyVariable< T >::set ( const T &  value,
bool  suppressNotification = false 
)
virtual

Sets the new value for this flag.

Also notifies waiting threads. After setting a value, changed() will be true.

Parameters
valuethe new value
suppressNotificationtrue to avoid a firing condition. This is useful for resetting values.
Returns
true if the value has been set successfully.
Note
set( get() ) == true
this is defined here to help the compiler to disambiguate between WFlag::set and the WPropertyBase::set.

Reimplemented from WFlag< T >.

Definition at line 642 of file WPropertyVariable.h.

References WFlag< T >::set().

+ Here is the call graph for this function:

◆ set() [2/2]

template<typename T >
bool WPropertyVariable< T >::set ( std::shared_ptr< WPropertyBase value,
bool  recommendedOnly = false 
)
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.

Implements WPropertyBase.

Definition at line 620 of file WPropertyVariable.h.

◆ setAsString()

template<typename T >
bool WPropertyVariable< T >::setAsString ( std::string  value)
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.

Implements WPropertyBase.

Definition at line 594 of file WPropertyVariable.h.

References PROPERTY_TYPE_HELPER::WStringConversion< T >::create().

+ Here is the call graph for this function:

◆ setMax()

template<typename T >
std::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::setMax ( const T &  max)

Set a maximum constraint.

Parameters
maxthe maximum value allowed.
Returns
the newly created constraint.

Definition at line 722 of file WPropertyVariable.h.

Referenced by WPropertyVariableTest::testMinMaxWithSetAndAccept().

+ Here is the caller graph for this function:

◆ setMin()

template<typename T >
std::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::setMin ( const T &  min)

Set a minimum constraint.

Parameters
minthe minimum value allowed.
Returns
the newly created constraint.

Definition at line 714 of file WPropertyVariable.h.

◆ setRecommendedValue()

template<typename T >
bool WPropertyVariable< T >::setRecommendedValue ( const T &  value)
virtual

Sets the specified value as recommended value.

The difference to set is simple. If some value was set using the method set earlier, the setRecommendedValue call is ignored. This is very useful in modules, where incoming data yields some useful default values but you do not want to overwrite a user-value which might have been set.

Parameters
valuethe new value to set if the user did not yet set the value
Returns
true if value has been set successfully.

Definition at line 649 of file WPropertyVariable.h.

◆ updateType()

template<typename T >
void WPropertyVariable< T >::updateType
protectedvirtual

Uses typeid() to set the proper type constant.

Reimplemented from WPropertyBase.

Definition at line 695 of file WPropertyVariable.h.

References PROPERTY_TYPE_HELPER::WTypeIdentifier< T >::getType().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WPropertyVariableTest

template<typename T >
friend class WPropertyVariableTest
friend

Access for test class.

Definition at line 57 of file WPropertyVariable.h.

Member Data Documentation

◆ m_constraints

template<typename T >
std::shared_ptr< ConstraintContainerType > WPropertyVariable< T >::m_constraints
protected

A set of constraints applied on this property.

Definition at line 443 of file WPropertyVariable.h.

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

◆ m_notifierConnection

template<typename T >
boost::signals2::connection WPropertyVariable< T >::m_notifierConnection
protected

The connection used for notification.

Definition at line 418 of file WPropertyVariable.h.

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

◆ m_notYetSet

template<typename T >
bool WPropertyVariable< T >::m_notYetSet
private

This is true, if the user did not set a value until now using set.

Definition at line 449 of file WPropertyVariable.h.


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