25 #ifndef WPROPERTYBASE_H
26 #define WPROPERTYBASE_H
31 #include <boost/function.hpp>
32 #include <boost/signals2/signal.hpp>
34 #include "WCondition.h"
35 #include "WConditionSet.h"
36 #include "WProperties_Fwd.h"
37 #include "WStringUtils.h"
47 class WPropertyBase:
public std::enable_shared_from_this< WPropertyBase >
53 typedef std::shared_ptr< WPropertyBase >
SPtr;
58 typedef std::shared_ptr< const WPropertyBase >
ConstSPtr;
90 virtual std::shared_ptr< WPropertyBase >
clone() = 0;
125 virtual PROPERTY_TYPE
getType()
const;
146 virtual void setPurpose( PROPERTY_PURPOSE purpose );
174 template<
typename T >
175 bool set(
const T& value );
203 virtual bool set( std::shared_ptr< WPropertyBase > value,
bool recommendedOnly =
false ) = 0;
312 template<
typename T >
370 template<
typename T >
373 return std::dynamic_pointer_cast< WPropertyVariable< T > >( shared_from_this() );
376 template<
typename T >
Abstract base class for all properties.
bool isHidden() const
Determines whether the property is hidden or not.
PROPERTY_TYPE m_type
Type of the PropertyVariable instance.
std::shared_ptr< WPropertyGroupBase > toPropGroupBase()
Convert the property to a WPropertyGroupBase.
WPropInterval toPropInterval()
Helper converts this instance to its native type.
virtual bool set(std::shared_ptr< WPropertyBase > value, bool recommendedOnly=false)=0
Sets the value from the specified property to this one.
WPropString toPropString()
Helper converts this instance to its native type.
WPropDouble toPropDouble()
Helper converts this instance to its native type.
std::string m_description
Description of the property.
WPropTransferFunction toPropTransferFunction()
Helper converts this instance to its native type.
PROPERTY_PURPOSE m_purpose
The purpose of this property.
std::string getName() const
Gets the name of the class.
virtual std::shared_ptr< WPropertyBase > clone()=0
This method clones a property and returns the clone.
std::shared_ptr< const WPropertyBase > ConstSPtr
Convenience typedef for a std::shared_ptr< const WPropertyBase >
std::shared_ptr< WConditionSet > m_updateCondition
Condition notified whenever something changes.
std::shared_ptr< WPropertyVariable< T > > toPropertyVariable()
Helper converts this instance to an arbitrary type.
WPropBool toPropBool()
Helper converts this instance to its native type.
virtual PROPERTY_TYPE getType() const
Gets the real WPropertyVariable type of this instance.
bool m_hidden
Flag denoting whether the property is hidden or not.
WPropColor toPropColor()
Helper converts this instance to its native type.
void setHidden(bool hidden=true)
Sets the property hidden.
std::string getDescription() const
Gets the description of the property.
std::string m_name
Name of the property.
WPropFilename toPropFilename()
Helper converts this instance to its native type.
virtual std::shared_ptr< WCondition > getUpdateCondition() const
This method returns a condition which gets fired whenever the property changes somehow.
PropertyChangeSignalType signal_PropertyChange
Signal getting fired whenever the property changes.
WPropMatrix4X4 toPropMatrix4X4()
Helper converts this instance to its native type.
WPropInt toPropInt()
Helper converts this instance to its native type.
WPropPosition toPropPosition()
Helper converts this instance to its native type.
virtual void setPurpose(PROPERTY_PURPOSE purpose)
Sets the purpose of the property.
boost::signals2::signal< void(std::shared_ptr< WPropertyBase >)> PropertyChangeSignalType
Signal used for firing change signals.
virtual bool setAsString(std::string value)=0
This methods allows properties to be set by a string value.
WPropertyBase(std::string name, std::string description)
Create an empty named property.
virtual PROPERTY_PURPOSE getPurpose() const
Gets the purpose of a property.
virtual std::string getAsString()=0
Returns the current value as a string.
WPropTrigger toPropTrigger()
Helper converts this instance to its native type.
virtual void updateType()
Calculates the type of the property.
WPropSelection toPropSelection()
Helper converts this instance to its native type.
virtual ~WPropertyBase()
Destructor.
boost::function< void(std::shared_ptr< WPropertyBase >)> PropertyChangeNotifierType
Signal signature emitted during set operations.
WPropGroup toPropGroup()
Helper converts this instance to its native type.
std::shared_ptr< WPropertyBase > SPtr
Convenience typedef for a std::shared_ptr< WPropertyBase >
bool set(const T &value)
Shortcut to set a property with a given value.
This is the base class and interface for property groups.
std::string toString(const T &value)
Convert a given value to a string.