32 #include <boost/tokenizer.hpp>
35 #include "WPropertyGroup.h"
36 #include "WPropertyHelper.h"
37 #include "exceptions/WPropertyUnknown.h"
59 return std::shared_ptr< WPropertyGroup >(
new WPropertyGroup( *
this ) );
88 template<
typename T >
89 T _addDefaultConstraints( T prop )
103 WPropSelection _addDefaultConstraints( WPropSelection prop )
118 WPropFilename _addDefaultConstraints( WPropFilename prop )
133 template<
typename T >
134 T addDefaultConstraints( T prop )
136 if( prop->getPurpose() == PV_PURPOSE_INFORMATION )
141 return _addDefaultConstraints( prop );
155 return set( v, std::vector< std::string >(), recommendedOnly );
158 bool WPropertyGroup::set( std::shared_ptr< WPropertyGroup > value, std::vector< std::string > exclude,
bool recommendedOnly )
160 return setImpl( value,
"", exclude, recommendedOnly );
163 bool WPropertyGroup::setImpl( std::shared_ptr< WPropertyGroup > value, std::string path, std::vector< std::string > exclude,
bool recommendedOnly )
184 completePath = ( *it )->getName();
188 if( std::find( exclude.begin(), exclude.end(), completePath ) != exclude.end() )
197 if( inputAsGroup && meAsGroup )
200 c += meAsGroup->setImpl( inputAsGroup, completePath, exclude, recommendedOnly );
202 else if( inputAsGroup || meAsGroup )
208 c += prop->set( *it, recommendedOnly );
214 return ( c == r->get().size() );
226 l->get().erase( std::remove( l->get().begin(), l->get().end(), prop ), l->get().end() );
232 WPropGroup p = WPropGroup(
new WPropertyGroup( name, description ) );
233 p->setHidden( hide );
253 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_BOOL >( name, description, initial, hide ) );
258 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_INT >( name, description, initial, hide ) );
263 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_DOUBLE >( name, description, initial, hide ) );
268 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_STRING >( name, description, initial, hide ) );
273 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, hide ) );
278 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_SELECTION >( name, description, initial, hide ) );
283 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_POSITION >( name, description, initial, hide ) );
288 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_COLOR >( name, description, initial, hide ) );
293 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_TRIGGER >( name, description, initial, hide ) );
304 std::shared_ptr< WCondition > condition,
bool hide )
306 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_BOOL >( name, description, initial, condition, hide ) );
310 std::shared_ptr< WCondition > condition,
bool hide )
312 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_INT >( name, description, initial, condition, hide ) );
316 std::shared_ptr< WCondition > condition,
bool hide )
318 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_DOUBLE >( name, description, initial, condition, hide ) );
322 std::shared_ptr< WCondition > condition,
bool hide )
324 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_STRING >( name, description, initial, condition, hide ) );
328 std::shared_ptr< WCondition > condition,
bool hide )
330 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, condition, hide ) );
334 std::shared_ptr< WCondition > condition,
bool hide )
336 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_SELECTION >( name, description, initial, condition, hide ) );
340 std::shared_ptr< WCondition > condition,
bool hide )
342 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_POSITION >( name, description, initial, condition, hide ) );
346 std::shared_ptr< WCondition > condition,
bool hide )
348 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_COLOR >( name, description, initial, condition, hide ) );
352 std::shared_ptr< WCondition > condition,
bool hide )
354 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_TRIGGER >( name, description, initial, condition, hide ) );
367 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_BOOL >( name, description, initial, notifier, hide ) );
373 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_INT >( name, description, initial, notifier, hide ) );
379 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_DOUBLE >( name, description, initial, notifier, hide ) );
385 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_STRING >( name, description, initial, notifier, hide ) );
391 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, notifier, hide ) );
397 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_SELECTION >( name, description, initial, notifier, hide ) );
403 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_POSITION >( name, description, initial, notifier, hide ) );
409 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_COLOR >( name, description, initial, notifier, hide ) );
415 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_TRIGGER >( name, description, initial, notifier, hide ) );
427 std::shared_ptr< WCondition > condition,
430 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_BOOL >( name, description, initial, condition, notifier, hide ) );
434 std::shared_ptr< WCondition > condition,
437 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_INT >( name, description, initial, condition, notifier, hide ) );
441 std::shared_ptr< WCondition > condition,
444 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_DOUBLE >( name, description, initial, condition, notifier, hide ) );
448 std::shared_ptr< WCondition > condition,
451 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_STRING >( name, description, initial, condition, notifier, hide ) );
455 std::shared_ptr< WCondition > condition,
458 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, condition, notifier, hide ) );
462 std::shared_ptr< WCondition > condition,
465 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_SELECTION >( name, description, initial, condition, notifier, hide ) );
469 std::shared_ptr< WCondition > condition,
472 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_POSITION >( name, description, initial, condition, notifier, hide ) );
476 std::shared_ptr< WCondition > condition,
479 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_COLOR >( name, description, initial, condition, notifier, hide ) );
483 std::shared_ptr< WCondition > condition,
486 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_TRIGGER >( name, description, initial, condition, notifier, hide ) );
This class represents a subset of a WItemSelection.
This only is a 3d double vector.
std::shared_ptr< WConditionSet > m_updateCondition
Condition notified whenever something changes.
boost::function< void(std::shared_ptr< WPropertyBase >)> PropertyChangeNotifierType
Signal signature emitted during set operations.
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.
static const std::string separator
The separator used to separate groups and subgroups.
virtual std::shared_ptr< WPropertyBase > findProperty(std::string name) const
Searches the property with a given name.
PropertySharedContainerType m_properties
The set of proerties.
Class to manage properties of an object and to provide convenience methods for easy access and manipu...
WPropGroup addPropertyGroup(std::string name, std::string description, bool hide=false)
Create and add a new property group.
PropType addProperty(PropType prop)
Insert the specified property into the list.
std::shared_ptr< WPropertyGroup > SPtr
shared pointer to object of this type
virtual PROPERTY_TYPE getType() const
Gets the real type of this instance.
virtual bool setAsString(std::string value)
This methods allows properties to be set by a string value.
virtual std::shared_ptr< WPropertyBase > clone()
This method clones a property and returns the clone.
virtual std::string getAsString()
Returns the current value as a string.
virtual bool setImpl(std::shared_ptr< WPropertyGroup > value, std::string path="", std::vector< std::string > exclude=std::vector< std::string >(), bool recommendedOnly=false)
This function implements the set functionality.
virtual void clear()
Removes all properties from the list.
virtual ~WPropertyGroup()
destructor
WPropertyGroup(std::string name="unnamed group", std::string description="an unnamed group of properties")
Constructor.
virtual bool set(std::shared_ptr< WPropertyBase > value, bool recommendedOnly=false)
Sets the value from the specified property to this one.
void removeProperty(std::shared_ptr< WPropertyBase > prop)
Remove the specified property from the list.
std::shared_ptr< WSharedObjectTicketRead< T > > ReadTicket
Type for read tickets.
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.
PV_TRIGGER
Enum denoting the possible trigger states.
WColor PV_COLOR
base type used for every WPVColor
std::string PV_STRING
base type used for every WPVString
double PV_DOUBLE
base type used for every WPVDouble
bool PV_BOOL
base type used for every WPVBool
boost::filesystem::path PV_PATH
base type used for every WPVFilename
int32_t PV_INT
base type used for every WPVInt
void addTo(WPropSelection prop)
Add the PC_ISVALID constraint to the property.
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.