OpenWalnut 1.3.1
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WPROPERTYGROUP_H 00026 #define WPROPERTYGROUP_H 00027 00028 #include <map> 00029 #include <string> 00030 #include <vector> 00031 00032 #include "WConditionSet.h" 00033 #include "WPropertyBase.h" 00034 #include "WPropertyGroupBase.h" 00035 #include "WPropertyTypes.h" 00036 #include "WPropertyVariable.h" 00037 #include "WSharedSequenceContainer.h" 00038 #include "exceptions/WPropertyNotUnique.h" 00039 00040 00041 00042 /** 00043 * Class to manage properties of an object and to provide convenience methods for easy access and manipulation. It also allows 00044 * thread safe iteration on its elements. The main purpose of this class is to group properties together and to allow searching properties by a 00045 * given name. The name of each property in a group has to be unique and is constructed using the group names containing them: hello/you/property 00046 * is the property with the name "property" in the group "you" which against is in the group "hello". 00047 * \note The root group of each module does not have a name. 00048 */ 00049 class WPropertyGroup: public WPropertyGroupBase 00050 { 00051 friend class WPropertiesTest; 00052 public: 00053 // the following typedefs are for convenience. 00054 typedef boost::shared_ptr< WPropertyGroup > SPtr; //!< shared pointer to object of this type 00055 typedef boost::shared_ptr< const WPropertyGroup > ConstSPtr; //!< const shared pointer to object of this type 00056 typedef WPropertyGroup* Ptr; //!< pointer to object of this type 00057 typedef const WPropertyGroup* ConstPtr; //!< const pointer to object of this type 00058 typedef WPropertyGroup& Ref; //!< ref to object of this type 00059 typedef const WPropertyGroup& ConstRef; //!< const ref to object of this type 00060 00061 /** 00062 * For shortening: a type defining a shared vector of WSubject pointers. 00063 */ 00064 typedef WPropertyGroupBase::PropertyContainerType PropertyContainerType; 00065 00066 /** 00067 * The alias for a shared container. 00068 */ 00069 typedef WPropertyGroupBase::PropertySharedContainerType PropertySharedContainerType; 00070 00071 /** 00072 * The const iterator type of the container. 00073 */ 00074 typedef WPropertyGroupBase::PropertyConstIterator PropertyConstIterator; 00075 00076 /** 00077 * The iterator type of the container. 00078 */ 00079 typedef WPropertyGroupBase::PropertyIterator PropertyIterator; 00080 00081 /** 00082 * Constructor. Creates an empty list of properties. 00083 * 00084 * \note WModule::getProperties always returns an unnamed instance. 00085 * 00086 * \param name the name of the property group. The GUI is using this name for naming the tabs/group boxes 00087 * \param description the description of the group. 00088 */ 00089 WPropertyGroup( std::string name = "unnamed group", std::string description = "an unnamed group of properties" ); 00090 00091 /** 00092 * Copy constructor. Creates a deep copy of this property. As boost::signals2 and condition variables are non-copyable, new instances get 00093 * created. The subscriptions to a signal are LOST as well as all listeners to a condition. 00094 * The conditions you can grab using getValueChangeConditon and getCondition are not the same as in the original! This is because 00095 * the class corresponds to the observer/observable pattern. You won't expect a clone to fire a condition if a original flag is changed 00096 * (which after cloning is completely decoupled from the clone). 00097 * 00098 * \note the properties inside this list are also copied deep 00099 * 00100 * \param from the instance to copy. 00101 */ 00102 explicit WPropertyGroup( const WPropertyGroup& from ); 00103 00104 /** 00105 * destructor 00106 */ 00107 virtual ~WPropertyGroup(); 00108 00109 /////////////////////////////////////////////////////////////////////////////////////////////////// 00110 // The WPropertyBase interface 00111 /////////////////////////////////////////////////////////////////////////////////////////////////// 00112 00113 /** 00114 * This method clones a property and returns the clone. It does a deep copy and, in contrast to a copy constructor, creates property with the 00115 * correct type without explicitly requiring the user to specify it. It creates a NEW change condition and change signal. This means, alls 00116 * subscribed signal handlers are NOT copied. 00117 * 00118 * \note this simply ensures the copy constructor of the runtime type is issued. 00119 * 00120 * \return the deep clone of this property. 00121 */ 00122 virtual boost::shared_ptr< WPropertyBase > clone(); 00123 00124 /** 00125 * Gets the real type of this instance. In this case, PV_GROUP. 00126 * 00127 * \return the real type. 00128 */ 00129 virtual PROPERTY_TYPE getType() const; 00130 00131 /** 00132 * This methods allows properties to be set by a string value. This method does nothing here, as groups can not be set in any kind. 00133 * 00134 * \param value the new value to set. IGNORED. 00135 * 00136 * \return always true 00137 */ 00138 virtual bool setAsString( std::string value ); 00139 00140 /** 00141 * Returns the current value as a string. This is useful for debugging or project files. It is not implemented as << operator, since the << 00142 * should also print min/max constraints and so on. This simply is the value. 00143 * 00144 * \return the value as a string. 00145 */ 00146 virtual std::string getAsString(); 00147 00148 /** 00149 * Sets the value from the specified property to this one. This is especially useful to copy a value without explicitly casting/knowing the 00150 * dynamic type of the property. 00151 * For WPropertyGroup, this tries to set the contained properties to the value of the given group. It does not add/remove properties. It 00152 * simply sets the children values to the ones given. 00153 * 00154 * \param value the new value. 00155 * \param recommendedOnly if true, property types which support recommended values apply the given value as recommendation. 00156 * 00157 * \return true if the values of the children could be set. If one could not be set, false 00158 */ 00159 virtual bool set( boost::shared_ptr< WPropertyBase > value, bool recommendedOnly = false ); 00160 00161 /////////////////////////////////////////////////////////////////////////////////////////////////// 00162 // Extend the WPropertyGroupBase to allow the property list to be modified 00163 /////////////////////////////////////////////////////////////////////////////////////////////////// 00164 00165 /** 00166 * Removes all properties from the list. 00167 */ 00168 virtual void clear(); 00169 00170 /** 00171 * Insert the specified property into the list. 00172 * 00173 * \param prop the property to add 00174 * 00175 * \return The given prop. 00176 */ 00177 template< typename PropType > 00178 PropType addProperty( PropType prop ); 00179 00180 /** 00181 * Remove the specified property from the list. If the given property is not in the list, nothing happens. 00182 * 00183 * \param prop the property to remove. 00184 */ 00185 void removeProperty( boost::shared_ptr< WPropertyBase > prop ); 00186 00187 /////////////////////////////////////////////////////////////////////////////////////////////////// 00188 // Convenience methods to create and add properties 00189 /////////////////////////////////////////////////////////////////////////////////////////////////// 00190 00191 /** 00192 * Create and add a new property group. Use these groups to structure your properties. 00193 * 00194 * \param name the name of the group. 00195 * \param description the description of the group. 00196 * \param hide true if group should be completely hidden. 00197 * 00198 * \return The newly created property group. 00199 */ 00200 WPropGroup addPropertyGroup( std::string name, std::string description, bool hide = false ); 00201 00202 /** 00203 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00204 * 00205 * \see WPropertyVariable 00206 * 00207 * \param name the property name 00208 * \param description the property description 00209 * \param initial the initial value 00210 * \param hide set to true to set the hide flag directly. 00211 * 00212 * \return the newly created property variable instance. 00213 */ 00214 template< typename T> 00215 boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, bool hide = false ); 00216 00217 /** 00218 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00219 * 00220 * \see WPropertyVariable 00221 * 00222 * \param name the property name 00223 * \param description the property description 00224 * \param initial the initial value 00225 * \param condition use this external condition for notification. 00226 * \param hide set to true to set the hide flag directly. 00227 * 00228 * \return the newly created property variable instance. 00229 */ 00230 template< typename T> 00231 boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, 00232 boost::shared_ptr< WCondition > condition, bool hide = false ); 00233 00234 /** 00235 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00236 * 00237 * \see WPropertyVariable 00238 * 00239 * \param name the property name 00240 * \param description the property description 00241 * \param initial the initial value 00242 * \param notifier use this notifier for change callbacks. 00243 * \param hide set to true to set the hide flag directly. 00244 * 00245 * \return the newly created property variable instance. 00246 */ 00247 template< typename T> 00248 boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, 00249 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00250 00251 /** 00252 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00253 * 00254 * \see WPropertyVariable 00255 * 00256 * \param name the property name 00257 * \param description the property description 00258 * \param initial the initial value 00259 * \param notifier use this notifier for change callbacks. 00260 * \param condition use this external condition for notification 00261 * \param hide set to true to set the hide flag directly. 00262 * 00263 * \return the newly created property variable instance. 00264 */ 00265 template< typename T> 00266 boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, 00267 boost::shared_ptr< WCondition > condition, 00268 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00269 00270 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00271 // Convenience methods to create and add properties 00272 // NOTE: these methods use the type of the initial parameter to automatically use the proper type. 00273 // This works, since the compiler always calls the function with the best matching parameter types. 00274 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00275 00276 00277 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00278 // convenience methods for 00279 // template< typename T> 00280 // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, bool hide = false ); 00281 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00282 00283 /** 00284 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00285 * 00286 * \see WPropertyVariable 00287 * 00288 * \param name the property name 00289 * \param description the property description 00290 * \param initial the initial value 00291 * \param hide set to true to set the hide flag directly. 00292 * 00293 * \return the newly created property variable instance. 00294 */ 00295 WPropBool addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL& initial, bool hide = false ); 00296 00297 /** 00298 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00299 * It also sets the min and max constraint to [0,100]. 00300 * 00301 * \see WPropertyVariable 00302 * 00303 * \param name the property name 00304 * \param description the property description 00305 * \param initial the initial value 00306 * \param hide set to true to set the hide flag directly. 00307 * 00308 * \return the newly created property variable instance. 00309 */ 00310 WPropInt addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT& initial, bool hide = false ); 00311 00312 /** 00313 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00314 * It also sets the min and max constraint to [0,100]. 00315 * 00316 * \see WPropertyVariable 00317 * 00318 * \param name the property name 00319 * \param description the property description 00320 * \param initial the initial value 00321 * \param hide set to true to set the hide flag directly. 00322 * 00323 * \return the newly created property variable instance. 00324 */ 00325 WPropDouble addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial, bool hide = false ); 00326 00327 /** 00328 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00329 * 00330 * \see WPropertyVariable 00331 * 00332 * \param name the property name 00333 * \param description the property description 00334 * \param initial the initial value 00335 * \param hide set to true to set the hide flag directly. 00336 * 00337 * \return the newly created property variable instance. 00338 */ 00339 WPropString addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial, bool hide = false ); 00340 00341 /** 00342 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00343 * 00344 * \see WPropertyVariable 00345 * 00346 * \param name the property name 00347 * \param description the property description 00348 * \param initial the initial value 00349 * \param hide set to true to set the hide flag directly. 00350 * 00351 * \return the newly created property variable instance. 00352 */ 00353 WPropFilename addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH& initial, bool hide = false ); 00354 00355 /** 00356 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00357 * 00358 * \see WPropertyVariable 00359 * 00360 * \param name the property name 00361 * \param description the property description 00362 * \param initial the initial value 00363 * \param hide set to true to set the hide flag directly. 00364 * 00365 * \return the newly created property variable instance. 00366 */ 00367 WPropSelection addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION& initial, bool hide = false ); 00368 00369 /** 00370 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00371 * 00372 * \see WPropertyVariable 00373 * 00374 * \param name the property name 00375 * \param description the property description 00376 * \param initial the initial value 00377 * \param hide set to true to set the hide flag directly. 00378 * 00379 * \return the newly created property variable instance. 00380 */ 00381 WPropPosition addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION& initial, bool hide = false ); 00382 00383 /** 00384 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00385 * 00386 * \see WPropertyVariable 00387 * 00388 * \param name the property name 00389 * \param description the property description 00390 * \param initial the initial value 00391 * \param hide set to true to set the hide flag directly. 00392 * 00393 * \return the newly created property variable instance. 00394 */ 00395 WPropColor addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR& initial, bool hide = false ); 00396 00397 /** 00398 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00399 * 00400 * \see WPropertyVariable 00401 * 00402 * \param name the property name 00403 * \param description the property description 00404 * \param initial the initial value 00405 * \param hide set to true to set the hide flag directly. 00406 * 00407 * \return the newly created property variable instance. 00408 */ 00409 WPropTrigger addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER& initial, bool hide = false ); 00410 00411 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00412 // convenience methods for 00413 // template< typename T> 00414 // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, 00415 // boost::shared_ptr< WCondition > condition, bool hide = false ); 00416 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00417 00418 /** 00419 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00420 * 00421 * \see WPropertyVariable 00422 * 00423 * \param name the property name 00424 * \param description the property description 00425 * \param initial the initial value 00426 * \param condition use this external condition for notification. 00427 * \param hide set to true to set the hide flag directly. 00428 * 00429 * \return the newly created property variable instance. 00430 */ 00431 WPropBool addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL& initial, 00432 boost::shared_ptr< WCondition > condition, bool hide = false ); 00433 00434 /** 00435 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00436 * It also sets the min and max constraint to [0,100]. 00437 * 00438 * \see WPropertyVariable 00439 * 00440 * \param name the property name 00441 * \param description the property description 00442 * \param initial the initial value 00443 * \param condition use this external condition for notification. 00444 * \param hide set to true to set the hide flag directly. 00445 * 00446 * \return the newly created property variable instance. 00447 */ 00448 WPropInt addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT& initial, 00449 boost::shared_ptr< WCondition > condition, bool hide = false ); 00450 00451 /** 00452 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00453 * It also sets the min and max constraint to [0,100]. 00454 * 00455 * \see WPropertyVariable 00456 * 00457 * \param name the property name 00458 * \param description the property description 00459 * \param initial the initial value 00460 * \param condition use this external condition for notification. 00461 * \param hide set to true to set the hide flag directly. 00462 * 00463 * \return the newly created property variable instance. 00464 */ 00465 WPropDouble addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial, 00466 boost::shared_ptr< WCondition > condition, bool hide = false ); 00467 00468 /** 00469 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00470 * 00471 * \see WPropertyVariable 00472 * 00473 * \param name the property name 00474 * \param description the property description 00475 * \param initial the initial value 00476 * \param condition use this external condition for notification. 00477 * \param hide set to true to set the hide flag directly. 00478 * 00479 * \return the newly created property variable instance. 00480 */ 00481 WPropString addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial, 00482 boost::shared_ptr< WCondition > condition, bool hide = false ); 00483 00484 /** 00485 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00486 * 00487 * \see WPropertyVariable 00488 * 00489 * \param name the property name 00490 * \param description the property description 00491 * \param initial the initial value 00492 * \param condition use this external condition for notification. 00493 * \param hide set to true to set the hide flag directly. 00494 * 00495 * \return the newly created property variable instance. 00496 */ 00497 WPropFilename addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH& initial, 00498 boost::shared_ptr< WCondition > condition, bool hide = false ); 00499 00500 /** 00501 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00502 * 00503 * \see WPropertyVariable 00504 * 00505 * \param name the property name 00506 * \param description the property description 00507 * \param initial the initial value 00508 * \param condition use this external condition for notification. 00509 * \param hide set to true to set the hide flag directly. 00510 * 00511 * \return the newly created property variable instance. 00512 */ 00513 WPropSelection addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION& initial, 00514 boost::shared_ptr< WCondition > condition, bool hide = false ); 00515 00516 /** 00517 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00518 * 00519 * \see WPropertyVariable 00520 * 00521 * \param name the property name 00522 * \param description the property description 00523 * \param initial the initial value 00524 * \param condition use this external condition for notification. 00525 * \param hide set to true to set the hide flag directly. 00526 * 00527 * \return the newly created property variable instance. 00528 */ 00529 WPropPosition addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION& initial, 00530 boost::shared_ptr< WCondition > condition, bool hide = false ); 00531 00532 /** 00533 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00534 * 00535 * \see WPropertyVariable 00536 * 00537 * \param name the property name 00538 * \param description the property description 00539 * \param initial the initial value 00540 * \param condition use this external condition for notification. 00541 * \param hide set to true to set the hide flag directly. 00542 * 00543 * \return the newly created property variable instance. 00544 */ 00545 WPropColor addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR& initial, 00546 boost::shared_ptr< WCondition > condition, bool hide = false ); 00547 00548 /** 00549 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00550 * 00551 * \see WPropertyVariable 00552 * 00553 * \param name the property name 00554 * \param description the property description 00555 * \param initial the initial value 00556 * \param condition use this external condition for notification. 00557 * \param hide set to true to set the hide flag directly. 00558 * 00559 * \return the newly created property variable instance. 00560 */ 00561 WPropTrigger addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER& initial, 00562 boost::shared_ptr< WCondition > condition, bool hide = false ); 00563 00564 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00565 // convenience methods for 00566 // template< typename T> 00567 // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, 00568 // WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00569 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00570 00571 /** 00572 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00573 * 00574 * \see WPropertyVariable 00575 * 00576 * \param name the property name 00577 * \param description the property description 00578 * \param initial the initial value 00579 * \param notifier use this notifier for change callbacks. 00580 * \param hide set to true to set the hide flag directly. 00581 * 00582 * \return the newly created property variable instance. 00583 */ 00584 WPropBool addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL& initial, 00585 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00586 00587 /** 00588 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00589 * It also sets the min and max constraint to [0,100]. 00590 * 00591 * \see WPropertyVariable 00592 * 00593 * \param name the property name 00594 * \param description the property description 00595 * \param initial the initial value 00596 * \param notifier use this notifier for change callbacks. 00597 * \param hide set to true to set the hide flag directly. 00598 * 00599 * \return the newly created property variable instance. 00600 */ 00601 WPropInt addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT& initial, 00602 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00603 00604 /** 00605 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00606 * It also sets the min and max constraint to [0,100]. 00607 * 00608 * \see WPropertyVariable 00609 * 00610 * \param name the property name 00611 * \param description the property description 00612 * \param initial the initial value 00613 * \param notifier use this notifier for change callbacks. 00614 * \param hide set to true to set the hide flag directly. 00615 * 00616 * \return the newly created property variable instance. 00617 */ 00618 WPropDouble addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial, 00619 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00620 00621 /** 00622 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00623 * 00624 * \see WPropertyVariable 00625 * 00626 * \param name the property name 00627 * \param description the property description 00628 * \param initial the initial value 00629 * \param notifier use this notifier for change callbacks. 00630 * \param hide set to true to set the hide flag directly. 00631 * 00632 * \return the newly created property variable instance. 00633 */ 00634 WPropString addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial, 00635 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00636 00637 /** 00638 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00639 * 00640 * \see WPropertyVariable 00641 * 00642 * \param name the property name 00643 * \param description the property description 00644 * \param initial the initial value 00645 * \param notifier use this notifier for change callbacks. 00646 * \param hide set to true to set the hide flag directly. 00647 * 00648 * \return the newly created property variable instance. 00649 */ 00650 WPropFilename addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH& initial, 00651 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00652 00653 /** 00654 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00655 * 00656 * \see WPropertyVariable 00657 * 00658 * \param name the property name 00659 * \param description the property description 00660 * \param initial the initial value 00661 * \param notifier use this notifier for change callbacks. 00662 * \param hide set to true to set the hide flag directly. 00663 * 00664 * \return the newly created property variable instance. 00665 */ 00666 WPropSelection addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION& initial, 00667 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00668 00669 /** 00670 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00671 * 00672 * \see WPropertyVariable 00673 * 00674 * \param name the property name 00675 * \param description the property description 00676 * \param initial the initial value 00677 * \param notifier use this notifier for change callbacks. 00678 * \param hide set to true to set the hide flag directly. 00679 * 00680 * \return the newly created property variable instance. 00681 */ 00682 WPropPosition addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION& initial, 00683 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00684 00685 /** 00686 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00687 * 00688 * \see WPropertyVariable 00689 * 00690 * \param name the property name 00691 * \param description the property description 00692 * \param initial the initial value 00693 * \param notifier use this notifier for change callbacks. 00694 * \param hide set to true to set the hide flag directly. 00695 * 00696 * \return the newly created property variable instance. 00697 */ 00698 WPropColor addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR& initial, 00699 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00700 00701 /** 00702 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00703 * 00704 * \see WPropertyVariable 00705 * 00706 * \param name the property name 00707 * \param description the property description 00708 * \param initial the initial value 00709 * \param notifier use this notifier for change callbacks. 00710 * \param hide set to true to set the hide flag directly. 00711 * 00712 * \return the newly created property variable instance. 00713 */ 00714 WPropTrigger addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER& initial, 00715 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00716 00717 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00718 // convenience methods for 00719 // template< typename T> 00720 // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, 00721 // boost::shared_ptr< WCondition > condition, 00722 // WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00723 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 00724 00725 /** 00726 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00727 * 00728 * \see WPropertyVariable 00729 * 00730 * \param name the property name 00731 * \param description the property description 00732 * \param initial the initial value 00733 * \param notifier use this notifier for change callbacks. 00734 * \param condition use this external condition for notification 00735 * \param hide set to true to set the hide flag directly. 00736 * 00737 * \return the newly created property variable instance. 00738 */ 00739 WPropBool addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL& initial, 00740 boost::shared_ptr< WCondition > condition, 00741 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00742 00743 /** 00744 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00745 * It also sets the min and max constraint to [0,100]. 00746 * 00747 * \see WPropertyVariable 00748 * 00749 * \param name the property name 00750 * \param description the property description 00751 * \param initial the initial value 00752 * \param notifier use this notifier for change callbacks. 00753 * \param condition use this external condition for notification 00754 * \param hide set to true to set the hide flag directly. 00755 * 00756 * \return the newly created property variable instance. 00757 */ 00758 WPropInt addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT& initial, 00759 boost::shared_ptr< WCondition > condition, 00760 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00761 00762 /** 00763 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00764 * It also sets the min and max constraint to [0,100]. 00765 * 00766 * \see WPropertyVariable 00767 * 00768 * \param name the property name 00769 * \param description the property description 00770 * \param initial the initial value 00771 * \param notifier use this notifier for change callbacks. 00772 * \param condition use this external condition for notification 00773 * \param hide set to true to set the hide flag directly. 00774 * 00775 * \return the newly created property variable instance. 00776 */ 00777 WPropDouble addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial, 00778 boost::shared_ptr< WCondition > condition, 00779 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00780 00781 00782 /** 00783 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00784 * 00785 * \see WPropertyVariable 00786 * 00787 * \param name the property name 00788 * \param description the property description 00789 * \param initial the initial value 00790 * \param notifier use this notifier for change callbacks. 00791 * \param condition use this external condition for notification 00792 * \param hide set to true to set the hide flag directly. 00793 * 00794 * \return the newly created property variable instance. 00795 */ 00796 WPropString addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial, 00797 boost::shared_ptr< WCondition > condition, 00798 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00799 00800 /** 00801 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00802 * 00803 * \see WPropertyVariable 00804 * 00805 * \param name the property name 00806 * \param description the property description 00807 * \param initial the initial value 00808 * \param notifier use this notifier for change callbacks. 00809 * \param condition use this external condition for notification 00810 * \param hide set to true to set the hide flag directly. 00811 * 00812 * \return the newly created property variable instance. 00813 */ 00814 WPropFilename addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH& initial, 00815 boost::shared_ptr< WCondition > condition, 00816 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00817 00818 /** 00819 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00820 * 00821 * \see WPropertyVariable 00822 * 00823 * \param name the property name 00824 * \param description the property description 00825 * \param initial the initial value 00826 * \param notifier use this notifier for change callbacks. 00827 * \param condition use this external condition for notification 00828 * \param hide set to true to set the hide flag directly. 00829 * 00830 * \return the newly created property variable instance. 00831 */ 00832 WPropSelection addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION& initial, 00833 boost::shared_ptr< WCondition > condition, 00834 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00835 00836 /** 00837 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00838 * 00839 * \see WPropertyVariable 00840 * 00841 * \param name the property name 00842 * \param description the property description 00843 * \param initial the initial value 00844 * \param notifier use this notifier for change callbacks. 00845 * \param condition use this external condition for notification 00846 * \param hide set to true to set the hide flag directly. 00847 * 00848 * \return the newly created property variable instance. 00849 */ 00850 WPropPosition addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION& initial, 00851 boost::shared_ptr< WCondition > condition, 00852 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00853 00854 /** 00855 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00856 * 00857 * \see WPropertyVariable 00858 * 00859 * \param name the property name 00860 * \param description the property description 00861 * \param initial the initial value 00862 * \param notifier use this notifier for change callbacks. 00863 * \param condition use this external condition for notification 00864 * \param hide set to true to set the hide flag directly. 00865 * 00866 * \return the newly created property variable instance. 00867 */ 00868 WPropColor addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR& initial, 00869 boost::shared_ptr< WCondition > condition, 00870 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00871 00872 /** 00873 * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable. 00874 * 00875 * \see WPropertyVariable 00876 * 00877 * \param name the property name 00878 * \param description the property description 00879 * \param initial the initial value 00880 * \param notifier use this notifier for change callbacks. 00881 * \param condition use this external condition for notification 00882 * \param hide set to true to set the hide flag directly. 00883 * 00884 * \return the newly created property variable instance. 00885 */ 00886 WPropTrigger addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER& initial, 00887 boost::shared_ptr< WCondition > condition, 00888 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false ); 00889 00890 protected: 00891 private: 00892 }; 00893 00894 template< typename PropType > 00895 PropType WPropertyGroup::addProperty( PropType prop ) 00896 { 00897 addArbitraryProperty( prop ); 00898 return prop; 00899 } 00900 00901 template< typename T> 00902 boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial, bool hide ) 00903 { 00904 boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >( 00905 new WPropertyVariable< T >( name, description, initial ) 00906 ); 00907 p->setHidden( hide ); 00908 addProperty( p ); 00909 return p; 00910 } 00911 00912 template< typename T> 00913 boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial, 00914 boost::shared_ptr< WCondition > condition, bool hide ) 00915 { 00916 boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >( 00917 new WPropertyVariable< T >( name, description, initial, condition ) 00918 ); 00919 p->setHidden( hide ); 00920 addProperty( p ); 00921 return p; 00922 } 00923 00924 template< typename T> 00925 boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial, 00926 WPropertyBase::PropertyChangeNotifierType notifier, bool hide ) 00927 { 00928 boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >( 00929 new WPropertyVariable< T >( name, description, initial, notifier ) 00930 ); 00931 p->setHidden( hide ); 00932 addProperty( p ); 00933 return p; 00934 } 00935 00936 template< typename T> 00937 boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial, 00938 boost::shared_ptr< WCondition > condition, 00939 WPropertyBase::PropertyChangeNotifierType notifier, bool hide ) 00940 { 00941 boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >( 00942 new WPropertyVariable< T >( name, description, initial, condition, notifier ) 00943 ); 00944 p->setHidden( hide ); 00945 addProperty( p ); 00946 return p; 00947 } 00948 00949 #endif // WPROPERTYGROUP_H