OpenWalnut  1.5.0dev
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
WPropertyGroupBase Class Reference

This is the base class and interface for property groups. More...

#include <WPropertyGroupBase.h>

+ Inheritance diagram for WPropertyGroupBase:
+ Collaboration diagram for WPropertyGroupBase:

Classes

struct  PropertyCreatorAndGroupAdder
 Comfortable template to create a property instance and add it to the group. More...
 
struct  PropertyCreatorAndGroupAdder< WPropertyStructHelper::NOTYPE >
 Specialization which does nothing for the NOTYPE default template parameters of WPropertyStruct. More...
 

Public Types

typedef std::vector< std::shared_ptr< WPropertyBase > > PropertyContainerType
 For shortening: a type defining a shared vector of WSubject pointers. More...
 
typedef WSharedSequenceContainer< PropertyContainerTypePropertySharedContainerType
 The alias for a shared container. More...
 
typedef PropertyContainerType::const_iterator PropertyConstIterator
 The const iterator type of the container. More...
 
typedef PropertyContainerType::iterator PropertyIterator
 The iterator type of the container. More...
 
typedef std::shared_ptr< WPropertyGroupBaseSPtr
 Convenience typedef for a std::shared_ptr< WPropertyGroupBase >. More...
 
typedef std::shared_ptr< const WPropertyGroupBaseConstSPtr
 Convenience typedef for a std::shared_ptr< const WPropertyGroupBase >. More...
 
typedef boost::function< void(std::string, std::string)> PropertyStringVisitor
 The visitor type used to visit properties as strings. 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

 WPropertyGroupBase (std::string name, std::string description)
 Constructor. More...
 
 WPropertyGroupBase (const WPropertyGroupBase &from)
 Copy constructor. More...
 
virtual ~WPropertyGroupBase ()
 Destructor. More...
 
virtual bool existsProperty (std::string name)
 Helper function that finds a property by its name. More...
 
virtual std::shared_ptr< WPropertyBasegetProperty (std::string name)
 Function searches the property. More...
 
virtual PropertySharedContainerType::ReadTicket getProperties () const
 Returns a read ticket for read-access to the list of properties. More...
 
virtual PropertySharedContainerType::ReadTicket getReadTicket () const
 Returns an read ticket for the properties. More...
 
virtual std::shared_ptr< WPropertyBasefindProperty (std::string name) const
 Searches the property with a given name. More...
 
virtual void visitAsString (PropertyStringVisitor visitor, std::string pathPrefix="") const
 Visit all leafs in the property three that aren't empty groups. More...
 
bool autoHideEmpty () const
 Checks whether the property group should be hidden if it is empty. More...
 
void setAutoHideEmpty (bool autoHide=true)
 Should the property group be hidden automatically if it is empty? By default, this is true. 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...
 
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...
 

Static Public Attributes

static const std::string separator = "/"
 The separator used to separate groups and subgroups. More...
 

Protected Member Functions

virtual std::shared_ptr< WPropertyBasefindProperty (const WPropertyGroupBase *const props, std::string name) const
 Helping function to find a property inside a specific group. More...
 
bool propNamePredicate (std::shared_ptr< WPropertyBase > prop1, std::shared_ptr< WPropertyBase > prop2) const
 Compares the names of two properties and returns true if they are equal. More...
 
void addArbitraryProperty (WPropertyBase::SPtr prop)
 Insert the specified property into the list. More...
 
- Protected Member Functions inherited from WPropertyBase
virtual void updateType ()
 Calculates the type of the property. More...
 

Protected Attributes

PropertySharedContainerType m_properties
 The set of proerties. 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_autoHideEmpty
 True if the prop should be hidden if if empty. 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

This is the base class and interface for property groups.

This class itself is abstract and derived from WPropertyBase. So if you create a group of properties, this ensures that your group is a property itself. This interface defines no way to add, remove or edit the property list itself. This allows the deriving class to prohibit modifications and to provide a custom interface, or even model-controller like implementations.

Another advantage is, that the GUI implementations which support WPropertyGroupBase can display your custom properties directly.

Definition at line 52 of file WPropertyGroupBase.h.

Member Typedef Documentation

◆ ConstSPtr

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

Convenience typedef for a std::shared_ptr< const WPropertyGroupBase >.

Definition at line 83 of file WPropertyGroupBase.h.

◆ PropertyConstIterator

typedef PropertyContainerType::const_iterator WPropertyGroupBase::PropertyConstIterator

The const iterator type of the container.

Definition at line 68 of file WPropertyGroupBase.h.

◆ PropertyContainerType

typedef std::vector< std::shared_ptr< WPropertyBase > > WPropertyGroupBase::PropertyContainerType

For shortening: a type defining a shared vector of WSubject pointers.

Definition at line 58 of file WPropertyGroupBase.h.

◆ PropertyIterator

typedef PropertyContainerType::iterator WPropertyGroupBase::PropertyIterator

The iterator type of the container.

Definition at line 73 of file WPropertyGroupBase.h.

◆ PropertySharedContainerType

The alias for a shared container.

Definition at line 63 of file WPropertyGroupBase.h.

◆ PropertyStringVisitor

typedef boost::function< void ( std::string, std::string )> WPropertyGroupBase::PropertyStringVisitor

The visitor type used to visit properties as strings.

The first parameter is the name, including the path of the property, relative to this group. The second parameter is the value as string.

Definition at line 173 of file WPropertyGroupBase.h.

◆ SPtr

typedef std::shared_ptr< WPropertyGroupBase > WPropertyGroupBase::SPtr

Convenience typedef for a std::shared_ptr< WPropertyGroupBase >.

Definition at line 78 of file WPropertyGroupBase.h.

Constructor & Destructor Documentation

◆ WPropertyGroupBase() [1/2]

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

Constructor.

Creates an empty list of properties.

Parameters
namethe name of the property group. The GUI is using this name for naming the tabs/group boxes
descriptionthe description of the group.

Definition at line 44 of file WPropertyGroupBase.cpp.

References WSharedObject< T >::getChangeCondition(), m_properties, and WPropertyBase::m_updateCondition.

+ Here is the call graph for this function:

◆ WPropertyGroupBase() [2/2]

WPropertyGroupBase::WPropertyGroupBase ( const WPropertyGroupBase 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 flag is changed (which after cloning is completely decoupled from the clone).

Note
the properties inside this list are also copied deep
Parameters
fromthe instance to copy.

Definition at line 57 of file WPropertyGroupBase.cpp.

References addArbitraryProperty(), WSharedObject< T >::getChangeCondition(), WSharedObject< T >::getReadTicket(), m_properties, and WPropertyBase::m_updateCondition.

+ Here is the call graph for this function:

◆ ~WPropertyGroupBase()

WPropertyGroupBase::~WPropertyGroupBase ( )
virtual

Destructor.

Definition at line 53 of file WPropertyGroupBase.cpp.

Member Function Documentation

◆ addArbitraryProperty()

void WPropertyGroupBase::addArbitraryProperty ( WPropertyBase::SPtr  prop)
protected

Insert the specified property into the list.

This method is protected. It is a convenience method for deriving classes to add properties without the need to update several conditions and similar.

Parameters
propthe property to add

Definition at line 196 of file WPropertyGroupBase.cpp.

References WPropertyBase::getName(), WPropertyBase::getPurpose(), WSharedObject< T >::getWriteTicket(), m_properties, WPropertyBase::m_updateCondition, and propNamePredicate().

Referenced by WPropertyGroup::addProperty(), WPropertyGroupBase::PropertyCreatorAndGroupAdder< PropertyType >::createAndAdd(), and WPropertyGroupBase().

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

◆ autoHideEmpty()

bool WPropertyGroupBase::autoHideEmpty ( ) const

Checks whether the property group should be hidden if it is empty.

Returns
true if it should be hidden if empty.

Definition at line 244 of file WPropertyGroupBase.cpp.

References m_autoHideEmpty.

◆ existsProperty()

bool WPropertyGroupBase::existsProperty ( std::string  name)
virtual

Helper function that finds a property by its name.

Use this method to find out whether the property exists or not, since findProperty throws an exception.

Parameters
namename of searched property.
Returns
Answer to the question whether the property exists.

Definition at line 180 of file WPropertyGroupBase.cpp.

References findProperty().

+ Here is the call graph for this function:

◆ findProperty() [1/2]

std::shared_ptr< WPropertyBase > WPropertyGroupBase::findProperty ( const WPropertyGroupBase *const  props,
std::string  name 
) const
protectedvirtual

Helping function to find a property inside a specific group.

It does not recursively find properties nested inside other property groups.

Parameters
propsthe group to search in. This is not a shared pointer since it is not needed. It simply can't happen that it is freed during findProperty as it is contained in this or a nested properties instance.
namethe name of the property inside THIS group.
Returns
the property if found, else NULL.

Definition at line 85 of file WPropertyGroupBase.cpp.

References WSharedObject< T >::getReadTicket(), and m_properties.

+ Here is the call graph for this function:

◆ findProperty() [2/2]

std::shared_ptr< WPropertyBase > WPropertyGroupBase::findProperty ( std::string  name) const
virtual

Searches the property with a given name.

It does not throw any exception. It simply returns NULL if it can't be found. It searches in nested groups too. The naming rules for finding a property in subgroups of this group is like specifying a path, using the separator char: "somegroup" + separator + "anothergroup" + separator + "propnametosearch".

Parameters
namethe name of the property to search
Returns
the property or NULL if not found.

Definition at line 106 of file WPropertyGroupBase.cpp.

References WPVBaseTypes::isPropertyGroup(), separator, WPropertyBase::toPropGroupBase(), and string_utils::toString().

Referenced by existsProperty(), getProperty(), and WPropertyGroup::setImpl().

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

◆ getProperties()

WPropertyGroupBase::PropertySharedContainerType::ReadTicket WPropertyGroupBase::getProperties ( ) const
virtual

Returns a read ticket for read-access to the list of properties.

Returns
the read ticket.

Definition at line 234 of file WPropertyGroupBase.cpp.

References WSharedObject< T >::getReadTicket(), and m_properties.

+ Here is the call graph for this function:

◆ getProperty()

std::shared_ptr< WPropertyBase > WPropertyGroupBase::getProperty ( std::string  name)
virtual

Function searches the property.

If it does not exists, it throws an exception.

Parameters
namethe name of the property
Returns
a WProperty object

Definition at line 185 of file WPropertyGroupBase.cpp.

References findProperty().

+ Here is the call graph for this function:

◆ getReadTicket()

WPropertyGroupBase::PropertySharedContainerType::ReadTicket WPropertyGroupBase::getReadTicket ( ) const
virtual

Returns an read ticket for the properties.

This, and only this, has to be used for external iteration of properties.

See also
WSharedObjectTicketRead
Returns
the read ticket.

Definition at line 239 of file WPropertyGroupBase.cpp.

References WSharedObject< T >::getReadTicket(), and m_properties.

Referenced by visitAsString().

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

◆ propNamePredicate()

bool WPropertyGroupBase::propNamePredicate ( std::shared_ptr< WPropertyBase prop1,
std::shared_ptr< WPropertyBase prop2 
) const
protected

Compares the names of two properties and returns true if they are equal.

Parameters
prop1the first prop.
prop2the second prop.
Returns
Are the names of the two properties equal?

Definition at line 80 of file WPropertyGroupBase.cpp.

Referenced by addArbitraryProperty().

+ Here is the caller graph for this function:

◆ setAutoHideEmpty()

void WPropertyGroupBase::setAutoHideEmpty ( bool  autoHide = true)

Should the property group be hidden automatically if it is empty? By default, this is true.

Note
this does not trigger an update. You should use this setting before adding this property to a parent group.
Parameters
autoHidetrue if it should be hidden automatically if empty.

Definition at line 249 of file WPropertyGroupBase.cpp.

References m_autoHideEmpty.

◆ visitAsString()

void WPropertyGroupBase::visitAsString ( WPropertyGroupBase::PropertyStringVisitor  visitor,
std::string  pathPrefix = "" 
) const
virtual

Visit all leafs in the property three that aren't empty groups.

This is especially interesting when using it with lambda functionality. The visitor function gets two parameters: 1st: the name of the property, including the path beginning at this group; 2nd: the value as string.

Parameters
visitorthe function to use for each property.
pathPrefixadd this prefix to the property name in the visitor. It might be interesting if manually implementing group visitors that always require a complete path, so you can add an upper-level path here.

Definition at line 143 of file WPropertyGroupBase.cpp.

References getReadTicket(), and separator.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_autoHideEmpty

bool WPropertyGroupBase::m_autoHideEmpty
private

True if the prop should be hidden if if empty.

Definition at line 277 of file WPropertyGroupBase.h.

Referenced by autoHideEmpty(), and setAutoHideEmpty().

◆ m_properties

PropertySharedContainerType WPropertyGroupBase::m_properties
protected

◆ separator

const std::string WPropertyGroupBase::separator = "/"
static

The separator used to separate groups and subgroups.

Definition at line 88 of file WPropertyGroupBase.h.

Referenced by findProperty(), WPropertyGroup::setImpl(), and visitAsString().


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