31 #include <boost/lexical_cast.hpp>
32 #include <boost/tokenizer.hpp>
35 #include "exceptions/WPropertyUnknown.h"
37 #include "WPropertyHelper.h"
39 #include "WProperties.h"
80 return boost::shared_ptr< WProperties >(
new WProperties( *
this ) );
109 template<
typename T >
110 T _addDefaultConstraints( T prop )
124 WPropInt _addDefaultConstraints( WPropInt prop )
140 WPropDouble _addDefaultConstraints( WPropDouble prop )
143 prop->setMax( 100.0 );
156 WPropSelection _addDefaultConstraints( WPropSelection prop )
171 WPropFilename _addDefaultConstraints( WPropFilename prop )
186 template<
typename T >
187 T addDefaultConstraints( T prop )
189 if( prop->getPurpose() == PV_PURPOSE_INFORMATION )
194 return _addDefaultConstraints( prop );
204 return ( prop1->getName() == prop2->getName() );
215 l->get().erase( std::remove( l->get().begin(), l->get().end(), prop ), l->get().end() );
221 boost::shared_ptr< WPropertyBase > result = boost::shared_ptr< WPropertyBase >();
227 for( PropertyContainerType::const_iterator it = l->get().begin(); it != l->get().end(); ++it )
229 if( ( *it )->getName() == name )
242 boost::shared_ptr< WPropertyBase > result = boost::shared_ptr< WPropertyBase >();
245 typedef boost::tokenizer<boost::char_separator< char > > tokenizer;
246 boost::char_separator< char > sep(
"/" );
247 tokenizer tok( name, sep );
251 for( tokenizer::iterator it = tok.begin(); it != tok.end(); ++it )
254 if( result && ( result->getType() != PV_GROUP ) )
257 return boost::shared_ptr< WPropertyBase >();
261 result =
findProperty( curProps, boost::lexical_cast< std::string >( *it ) );
265 return boost::shared_ptr< WPropertyBase >();
267 else if( result && ( result->getType() == PV_GROUP ) )
279 return (
findProperty( name ) != boost::shared_ptr< WPropertyBase >() );
284 boost::shared_ptr< WPropertyBase > p =
findProperty( name );
285 if( p == boost::shared_ptr< WPropertyBase >() )
287 throw WPropertyUnknown( std::string(
"Property \"" + name +
"\" can't be found." ) );
305 WPropGroup p = WPropGroup(
new WProperties( name, description ) );
306 p->setHidden( hide );
331 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_BOOL >( name, description, initial, hide ) );
336 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_INT >( name, description, initial, hide ) );
341 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_DOUBLE >( name, description, initial, hide ) );
346 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_STRING >( name, description, initial, hide ) );
351 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, hide ) );
356 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_SELECTION >( name, description, initial, hide ) );
361 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_POSITION >( name, description, initial, hide ) );
366 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_COLOR >( name, description, initial, hide ) );
371 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_TRIGGER >( name, description, initial, hide ) );
382 boost::shared_ptr< WCondition > condition,
bool hide )
384 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_BOOL >( name, description, initial, condition, hide ) );
388 boost::shared_ptr< WCondition > condition,
bool hide )
390 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_INT >( name, description, initial, condition, hide ) );
394 boost::shared_ptr< WCondition > condition,
bool hide )
396 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_DOUBLE >( name, description, initial, condition, hide ) );
400 boost::shared_ptr< WCondition > condition,
bool hide )
402 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_STRING >( name, description, initial, condition, hide ) );
406 boost::shared_ptr< WCondition > condition,
bool hide )
408 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, condition, hide ) );
412 boost::shared_ptr< WCondition > condition,
bool hide )
414 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_SELECTION >( name, description, initial, condition, hide ) );
418 boost::shared_ptr< WCondition > condition,
bool hide )
420 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_POSITION >( name, description, initial, condition, hide ) );
424 boost::shared_ptr< WCondition > condition,
bool hide )
426 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_COLOR >( name, description, initial, condition, hide ) );
430 boost::shared_ptr< WCondition > condition,
bool hide )
432 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_TRIGGER >( name, description, initial, condition, hide ) );
445 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_BOOL >( name, description, initial, notifier, hide ) );
451 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_INT >( name, description, initial, notifier, hide ) );
457 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_DOUBLE >( name, description, initial, notifier, hide ) );
463 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_STRING >( name, description, initial, notifier, hide ) );
469 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, notifier, hide ) );
475 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_SELECTION >( name, description, initial, notifier, hide ) );
481 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_POSITION >( name, description, initial, notifier, hide ) );
487 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_COLOR >( name, description, initial, notifier, hide ) );
493 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_TRIGGER >( name, description, initial, notifier, hide ) );
505 boost::shared_ptr< WCondition > condition,
508 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_BOOL >( name, description, initial, condition, notifier, hide ) );
512 boost::shared_ptr< WCondition > condition,
515 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_INT >( name, description, initial, condition, notifier, hide ) );
519 boost::shared_ptr< WCondition > condition,
522 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_DOUBLE >( name, description, initial, condition, notifier, hide ) );
526 boost::shared_ptr< WCondition > condition,
529 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_STRING >( name, description, initial, condition, notifier, hide ) );
533 boost::shared_ptr< WCondition > condition,
536 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, condition, notifier, hide ) );
540 boost::shared_ptr< WCondition > condition,
543 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_SELECTION >( name, description, initial, condition, notifier, hide ) );
547 boost::shared_ptr< WCondition > condition,
550 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_POSITION >( name, description, initial, condition, notifier, hide ) );
554 boost::shared_ptr< WCondition > condition,
557 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_COLOR >( name, description, initial, condition, notifier, hide ) );
561 boost::shared_ptr< WCondition > condition,
564 return addDefaultConstraints( addProperty< WPVBaseTypes::PV_TRIGGER >( name, description, initial, condition, notifier, hide ) );