31 #include <boost/tokenizer.hpp>
32 #include <boost/algorithm/string/predicate.hpp>
34 #include "WStringUtils.h"
36 #include "exceptions/WPropertyUnknown.h"
37 #include "exceptions/WPropertyNotUnique.h"
39 #include "WPropertyHelper.h"
41 #include "WPropertyGroupBase.h"
82 return ( prop1->getName() == prop2->getName() );
87 boost::shared_ptr< WPropertyBase > result = boost::shared_ptr< WPropertyBase >();
93 for( PropertyContainerType::const_iterator it = l->get().begin(); it != l->get().end(); ++it )
95 if( ( *it )->getName() == name )
108 boost::shared_ptr< WPropertyBase > result = boost::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 boost::shared_ptr< WPropertyBase >();
131 return boost::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 ) != boost::shared_ptr< WPropertyBase >() );
187 boost::shared_ptr< WPropertyBase > p =
findProperty( name );
188 if( p == boost::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 );
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.
boost::shared_ptr< WSharedObjectTicketWrite< PropertyContainerType > > WriteTicket
Type for write tickets.
boost::shared_ptr< WPropertyGroupBase > SPtr
Convenience typedef for a boost::shared_ptr< WPropertyGroupBase >.
boost::function< void(std::string, std::string)> PropertyStringVisitor
The visitor type used to visit properties as strings.
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.
ReadTicket getReadTicket() const
Returns a ticket to get read access to the contained data.
WriteTicket getWriteTicket(bool suppressNotify=false) const
Returns a ticket to get write access to the contained data.
void addArbitraryProperty(WPropertyBase::SPtr prop)
Insert the specified property into the list.
boost::shared_ptr< WConditionSet > m_updateCondition
Condition notified whenever something changes.
boost::shared_ptr< WPropertyGroupBase > toPropGroupBase()
Convert the property to a WPropertyGroupBase.
virtual PROPERTY_PURPOSE getPurpose() const
Gets the purpose of a property.
virtual PropertySharedContainerType::ReadTicket getProperties() const
Returns a read ticket for read-access to the list of properties.
bool isPropertyGroup(PROPERTY_TYPE type)
Checks which property types are derived from WPropertyGroupBase.
virtual bool existsProperty(std::string name)
Helper function that finds a property by its name.
This is the base class and interface for property groups.
std::string toString(const T &value)
Convert a given value to a string.
Abstract base class for all properties.
WPropertyGroupBase(std::string name, std::string description)
Constructor.
Indicates that a given property is not unique in a group of properties.
boost::shared_ptr< WPropertyBase > SPtr
Convenience typedef for a boost::shared_ptr< WPropertyBase >
static const std::string separator
The separator used to separate groups and subgroups.
virtual boost::shared_ptr< WPropertyBase > findProperty(std::string name) const
Searches the property with a given name.
virtual boost::shared_ptr< WPropertyBase > getProperty(std::string name)
Function searches the property.
std::string getName() const
Gets the name of the class.
PropertyContainerType::const_iterator PropertyConstIterator
The const iterator type of the container.
virtual PropertySharedContainerType::ReadTicket getReadTicket() const
Returns an read ticket for the properties.
boost::shared_ptr< WSharedObjectTicketRead< PropertyContainerType > > ReadTicket
Type for read tickets.
virtual ~WPropertyGroupBase()
Destructor.
boost::shared_ptr< WCondition > getChangeCondition() const
This condition fires whenever the encapsulated object changed.
Indicates invalid element access of a container.