OpenWalnut
1.4.0
|
This is the base class and interface for property groups. More...
#include <WPropertyGroupBase.h>
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 < boost::shared_ptr < WPropertyBase > > | PropertyContainerType |
For shortening: a type defining a shared vector of WSubject pointers. | |
typedef WSharedSequenceContainer < PropertyContainerType > | PropertySharedContainerType |
The alias for a shared container. | |
typedef PropertyContainerType::const_iterator | PropertyConstIterator |
The const iterator type of the container. | |
typedef PropertyContainerType::iterator | PropertyIterator |
The iterator type of the container. | |
typedef boost::shared_ptr < WPropertyGroupBase > | SPtr |
Convenience typedef for a boost::shared_ptr< WPropertyGroupBase >. | |
typedef boost::shared_ptr < const WPropertyGroupBase > | ConstSPtr |
Convenience typedef for a boost::shared_ptr< const WPropertyGroupBase >. | |
typedef boost::function< void(std::string, std::string)> | PropertyStringVisitor |
The visitor type used to visit properties as strings. | |
Public Member Functions | |
WPropertyGroupBase (std::string name, std::string description) | |
Constructor. | |
WPropertyGroupBase (const WPropertyGroupBase &from) | |
Copy constructor. | |
virtual | ~WPropertyGroupBase () |
Destructor. | |
virtual bool | existsProperty (std::string name) |
Helper function that finds a property by its name. | |
virtual boost::shared_ptr < WPropertyBase > | getProperty (std::string name) |
Function searches the property. | |
virtual PropertySharedContainerType::ReadTicket | getProperties () const |
Returns a read ticket for read-access to the list of properties. | |
virtual PropertySharedContainerType::ReadTicket | getReadTicket () const |
Returns an read ticket for the properties. | |
virtual boost::shared_ptr < WPropertyBase > | findProperty (std::string name) const |
Searches the property with a given name. | |
virtual void | visitAsString (PropertyStringVisitor visitor, std::string pathPrefix="") const |
Visit all leafs in the property three that aren't empty groups. | |
Static Public Attributes | |
static const std::string | separator = "/" |
The separator used to separate groups and subgroups. | |
Protected Member Functions | |
virtual boost::shared_ptr < WPropertyBase > | findProperty (const WPropertyGroupBase *const props, std::string name) const |
Helping function to find a property inside a specific group. | |
bool | propNamePredicate (boost::shared_ptr< WPropertyBase > prop1, boost::shared_ptr< WPropertyBase > prop2) const |
Compares the names of two properties and returns true if they are equal. | |
void | addArbitraryProperty (WPropertyBase::SPtr prop) |
Insert the specified property into the list. | |
Protected Attributes | |
PropertySharedContainerType | m_properties |
The set of proerties. |
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 51 of file WPropertyGroupBase.h.
typedef boost::shared_ptr< const WPropertyGroupBase > WPropertyGroupBase::ConstSPtr |
Convenience typedef for a boost::shared_ptr< const WPropertyGroupBase >.
Reimplemented from WPropertyBase.
Reimplemented in WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, WPropertyList< T >, and WPropertyGroup.
Definition at line 82 of file WPropertyGroupBase.h.
typedef PropertyContainerType::const_iterator WPropertyGroupBase::PropertyConstIterator |
The const iterator type of the container.
Reimplemented in WPropertyGroup.
Definition at line 67 of file WPropertyGroupBase.h.
typedef std::vector< boost::shared_ptr< WPropertyBase > > WPropertyGroupBase::PropertyContainerType |
For shortening: a type defining a shared vector of WSubject pointers.
Reimplemented in WPropertyGroup.
Definition at line 57 of file WPropertyGroupBase.h.
typedef PropertyContainerType::iterator WPropertyGroupBase::PropertyIterator |
The iterator type of the container.
Reimplemented in WPropertyGroup.
Definition at line 72 of file WPropertyGroupBase.h.
typedef WSharedSequenceContainer< PropertyContainerType > WPropertyGroupBase::PropertySharedContainerType |
The alias for a shared container.
Reimplemented in WPropertyGroup.
Definition at line 62 of file WPropertyGroupBase.h.
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 172 of file WPropertyGroupBase.h.
typedef boost::shared_ptr< WPropertyGroupBase > WPropertyGroupBase::SPtr |
Convenience typedef for a boost::shared_ptr< WPropertyGroupBase >.
Reimplemented from WPropertyBase.
Reimplemented in WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, WPropertyList< T >, and WPropertyGroup.
Definition at line 77 of file WPropertyGroupBase.h.
WPropertyGroupBase::WPropertyGroupBase | ( | std::string | name, |
std::string | description | ||
) |
Constructor.
Creates an empty list of properties.
name | the name of the property group. The GUI is using this name for naming the tabs/group boxes |
description | the description of the group. |
Definition at line 45 of file WPropertyGroupBase.cpp.
References WSharedObject< T >::getChangeCondition(), m_properties, and WPropertyBase::m_updateCondition.
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).
from | the 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.
WPropertyGroupBase::~WPropertyGroupBase | ( | ) | [virtual] |
Destructor.
Definition at line 53 of file WPropertyGroupBase.cpp.
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.
prop | the 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().
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.
name | name of searched property. |
Definition at line 180 of file WPropertyGroupBase.cpp.
References findProperty().
boost::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".
name | the name of the property to search |
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().
boost::shared_ptr< WPropertyBase > WPropertyGroupBase::findProperty | ( | const WPropertyGroupBase *const | props, |
std::string | name | ||
) | const [protected, virtual] |
Helping function to find a property inside a specific group.
It does not recursively find properties nested inside other property groups.
props | the 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. |
name | the name of the property inside THIS group. |
Definition at line 85 of file WPropertyGroupBase.cpp.
References WSharedObject< T >::getReadTicket(), and m_properties.
WPropertyGroupBase::PropertySharedContainerType::ReadTicket WPropertyGroupBase::getProperties | ( | ) | const [virtual] |
Returns a read ticket for read-access to the list of properties.
Definition at line 234 of file WPropertyGroupBase.cpp.
References WSharedObject< T >::getReadTicket(), and m_properties.
boost::shared_ptr< WPropertyBase > WPropertyGroupBase::getProperty | ( | std::string | name | ) | [virtual] |
Function searches the property.
If it does not exists, it throws an exception.
name | the name of the property |
Definition at line 185 of file WPropertyGroupBase.cpp.
References findProperty().
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.
Definition at line 239 of file WPropertyGroupBase.cpp.
References WSharedObject< T >::getReadTicket(), and m_properties.
Referenced by visitAsString().
bool WPropertyGroupBase::propNamePredicate | ( | boost::shared_ptr< WPropertyBase > | prop1, |
boost::shared_ptr< WPropertyBase > | prop2 | ||
) | const [protected] |
Compares the names of two properties and returns true if they are equal.
prop1 | the first prop. |
prop2 | the second prop. |
Definition at line 80 of file WPropertyGroupBase.cpp.
Referenced by addArbitraryProperty().
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.
visitor | the function to use for each property. |
pathPrefix | add 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.
The set of proerties.
This uses the operators ==,<,> WProperty to determine equalness.
Definition at line 200 of file WPropertyGroupBase.h.
Referenced by addArbitraryProperty(), WPropertyGroup::clear(), findProperty(), WPropertyList< T >::getAsString(), WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::getAsString(), getProperties(), WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::getProperty(), getReadTicket(), WPropertyGroup::removeProperty(), WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::set(), WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::setAsString(), and WPropertyGroupBase().
const std::string WPropertyGroupBase::separator = "/" [static] |
The separator used to separate groups and subgroups.
Definition at line 87 of file WPropertyGroupBase.h.
Referenced by findProperty(), WPropertyGroup::setImpl(), and visitAsString().