32 #include <boost/algorithm/string/predicate.hpp>
33 #include <boost/tokenizer.hpp>
36 #include "WPropertyGroupBase.h"
37 #include "WPropertyHelper.h"
38 #include "WStringUtils.h"
39 #include "exceptions/WPropertyNotUnique.h"
40 #include "exceptions/WPropertyUnknown.h"
47 m_autoHideEmpty( true )
82 return ( prop1->getName() == prop2->getName() );
87 std::shared_ptr< WPropertyBase > result = std::shared_ptr< WPropertyBase >();
93 for( PropertyContainerType::const_iterator it = l->get().begin(); it != l->get().end(); ++it )
95 if( ( *it )->getName() == name )
108 std::shared_ptr< WPropertyBase > result = std::shared_ptr< WPropertyBase >();
111 typedef boost::tokenizer<boost::char_separator< char > > tokenizer;
113 tokenizer tok( name, sep );
117 for( tokenizer::iterator it = tok.begin(); it != tok.end(); ++it )
123 return std::shared_ptr< WPropertyBase >();
131 return std::shared_ptr< WPropertyBase >();
156 propName = pathPrefix + ( *it )->getName();
159 if( pathPrefix.empty() )
161 propName = ( *it )->getName();
169 g->visitAsString( visitor, propName );
174 std::string value = ( *it )->getAsString();
175 visitor( propName, value );
182 return (
findProperty( name ) != std::shared_ptr< WPropertyBase >() );
187 std::shared_ptr< WPropertyBase > p =
findProperty( name );
188 if( p == std::shared_ptr< WPropertyBase >() )
190 throw WPropertyUnknown( std::string(
"Property \"" + name +
"\" can't be found." ) );
204 if( std::count_if( l->get().begin(), l->get().end(),
213 throw WPropertyNotUnique( std::string(
"Property \"" + prop->getName() +
"\" is not unique in this group (\"" +
getName() +
"\")." ) );
217 throw WPropertyNotUnique( std::string(
"Property \"" + prop->getName() +
"\" is not unique in this group (unnamed root)." ) );
224 prop->setPurpose( PV_PURPOSE_INFORMATION );
228 l->get().push_back( prop );
Abstract base class for all properties.
std::shared_ptr< WPropertyGroupBase > toPropGroupBase()
Convert the property to a WPropertyGroupBase.
std::string getName() const
Gets the name of the class.
std::shared_ptr< WConditionSet > m_updateCondition
Condition notified whenever something changes.
virtual PROPERTY_PURPOSE getPurpose() const
Gets the purpose of a property.
std::shared_ptr< WPropertyBase > SPtr
Convenience typedef for a std::shared_ptr< WPropertyBase >
This is the base class and interface for property groups.
PropertyContainerType::const_iterator PropertyConstIterator
The const iterator type of the container.
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.
bool autoHideEmpty() const
Checks whether the property group should be hidden if it is empty.
void addArbitraryProperty(WPropertyBase::SPtr prop)
Insert the specified property into the list.
virtual ~WPropertyGroupBase()
Destructor.
virtual PropertySharedContainerType::ReadTicket getProperties() const
Returns a read ticket for read-access to the list of properties.
void setAutoHideEmpty(bool autoHide=true)
Should the property group be hidden automatically if it is empty? By default, this is true.
virtual PropertySharedContainerType::ReadTicket getReadTicket() const
Returns an read ticket for the properties.
bool m_autoHideEmpty
True if the prop should be hidden if if empty.
virtual std::shared_ptr< WPropertyBase > getProperty(std::string name)
Function searches the property.
static const std::string separator
The separator used to separate groups and subgroups.
std::shared_ptr< WPropertyGroupBase > SPtr
Convenience typedef for a std::shared_ptr< WPropertyGroupBase >.
virtual std::shared_ptr< WPropertyBase > findProperty(std::string name) const
Searches the property with a given name.
virtual bool existsProperty(std::string name)
Helper function that finds a property by its name.
WPropertyGroupBase(std::string name, std::string description)
Constructor.
virtual void visitAsString(PropertyStringVisitor visitor, std::string pathPrefix="") const
Visit all leafs in the property three that aren't empty groups.
PropertySharedContainerType m_properties
The set of proerties.
boost::function< void(std::string, std::string)> PropertyStringVisitor
The visitor type used to visit properties as strings.
Indicates that a given property is not unique in a group of properties.
Indicates invalid element access of a container.
std::shared_ptr< WSharedObjectTicketRead< T > > ReadTicket
Type for read tickets.
ReadTicket getReadTicket() const
Returns a ticket to get read access to the contained data.
std::shared_ptr< WSharedObjectTicketWrite< T > > WriteTicket
Type for write tickets.
WriteTicket getWriteTicket(bool suppressNotify=false) const
Returns a ticket to get write access to the contained data.
std::shared_ptr< WCondition > getChangeCondition() const
This condition fires whenever the encapsulated object changed.
bool isPropertyGroup(PROPERTY_TYPE type)
Checks which property types are derived from WPropertyGroupBase.
std::string toString(const T &value)
Convert a given value to a string.