OpenWalnut  1.4.0
WPropertyGroup.h
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      * This method is a special version of \ref WPropertyBase::set for groups. It allows to set the values of the contained properties. It does
00163      * not add nor remove properties. It searches the property by name (recursively) and sets the value from the specified property group's
00164      * property. You can use the exclusion list to exclude a certain property.
00165      *
00166      * \param value the source values
00167      * \param exclude a list of property names to exclude. Use complete names here, which means, when having nested groups, apply the rules
00168      *                defined in \ref WPropertyGroupBase::findProperty.
00169      * \param recommendedOnly if true, property types which support recommended values apply the given value as recommendation.
00170      *
00171      * \return true if the values of the children could be set. If one could not be set, false
00172      */
00173     virtual bool set( boost::shared_ptr< WPropertyGroup > value, std::vector< std::string > exclude = std::vector< std::string >(),
00174                                                                  bool recommendedOnly = false );
00175 
00176     ///////////////////////////////////////////////////////////////////////////////////////////////////
00177     // Extend the WPropertyGroupBase to allow the property list to be modified
00178     ///////////////////////////////////////////////////////////////////////////////////////////////////
00179 
00180     /**
00181      * Removes all properties from the list.
00182      */
00183     virtual void clear();
00184 
00185     /**
00186      * Insert the specified property into the list.
00187      *
00188      * \param prop the property to add
00189      *
00190      * \return The given prop.
00191      */
00192     template< typename PropType >
00193     PropType addProperty( PropType prop );
00194 
00195     /**
00196      * Remove the specified property from the list. If the given property is not in the list, nothing happens.
00197      *
00198      * \param prop the property to remove.
00199      */
00200     void removeProperty( boost::shared_ptr< WPropertyBase > prop );
00201 
00202     ///////////////////////////////////////////////////////////////////////////////////////////////////
00203     // Convenience methods to create and add properties
00204     ///////////////////////////////////////////////////////////////////////////////////////////////////
00205 
00206     /**
00207      * Create and add a new property group. Use these groups to structure your properties.
00208      *
00209      * \param name the name of the group.
00210      * \param description the description of the group.
00211      * \param hide true if group should be completely hidden.
00212      *
00213      * \return The newly created property group.
00214      */
00215     WPropGroup addPropertyGroup( std::string name, std::string description, 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 hide set to true to set the hide flag directly.
00226      *
00227      * \return the newly created property variable instance.
00228      */
00229     template< typename T>
00230     boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, bool hide = false );
00231 
00232     /**
00233      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00234      *
00235      * \see WPropertyVariable
00236      *
00237      * \param name  the property name
00238      * \param description the property description
00239      * \param initial the initial value
00240      * \param condition use this external condition for notification.
00241      * \param hide set to true to set the hide flag directly.
00242      *
00243      * \return the newly created property variable instance.
00244      */
00245     template< typename T>
00246     boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
00247                                                              boost::shared_ptr< WCondition > condition, bool hide = false );
00248 
00249     /**
00250      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00251      *
00252      * \see WPropertyVariable
00253      *
00254      * \param name  the property name
00255      * \param description the property description
00256      * \param initial the initial value
00257      * \param notifier use this notifier for change callbacks.
00258      * \param hide set to true to set the hide flag directly.
00259      *
00260      * \return the newly created property variable instance.
00261      */
00262     template< typename T>
00263     boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
00264                                                              WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00265 
00266     /**
00267      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00268      *
00269      * \see WPropertyVariable
00270      *
00271      * \param name  the property name
00272      * \param description the property description
00273      * \param initial the initial value
00274      * \param notifier use this notifier for change callbacks.
00275      * \param condition use this external condition for notification
00276      * \param hide set to true to set the hide flag directly.
00277      *
00278      * \return the newly created property variable instance.
00279      */
00280     template< typename T>
00281     boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
00282                                                              boost::shared_ptr< WCondition > condition,
00283                                                              WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00284 
00285     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
00286     // Convenience methods to create and add properties
00287     // NOTE: these methods use the type of the initial parameter to automatically use the proper type.
00288     // This works, since the compiler always calls the function with the best matching parameter types.
00289     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
00290 
00291 
00292     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
00293     // convenience methods for
00294     // template< typename T>
00295     // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, bool hide = false );
00296     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
00297 
00298     /**
00299      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
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     WPropBool      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL&   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     WPropInt       addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT&    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      * It also sets the min and max constraint to [0,100].
00330      *
00331      * \see WPropertyVariable
00332      *
00333      * \param name  the property name
00334      * \param description the property description
00335      * \param initial the initial value
00336      * \param hide set to true to set the hide flag directly.
00337      *
00338      * \return the newly created property variable instance.
00339      */
00340     WPropDouble    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial, bool hide = false );
00341 
00342     /**
00343      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00344      *
00345      * \see WPropertyVariable
00346      *
00347      * \param name  the property name
00348      * \param description the property description
00349      * \param initial the initial value
00350      * \param hide set to true to set the hide flag directly.
00351      *
00352      * \return the newly created property variable instance.
00353      */
00354     WPropString    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial, bool hide = false );
00355 
00356     /**
00357      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00358      *
00359      * \see WPropertyVariable
00360      *
00361      * \param name  the property name
00362      * \param description the property description
00363      * \param initial the initial value
00364      * \param hide set to true to set the hide flag directly.
00365      *
00366      * \return the newly created property variable instance.
00367      */
00368     WPropFilename  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH&   initial, bool hide = false );
00369 
00370     /**
00371      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00372      *
00373      * \see WPropertyVariable
00374      *
00375      * \param name  the property name
00376      * \param description the property description
00377      * \param initial the initial value
00378      * \param hide set to true to set the hide flag directly.
00379      *
00380      * \return the newly created property variable instance.
00381      */
00382     WPropSelection      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION&   initial, bool hide = false );
00383 
00384     /**
00385      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00386      *
00387      * \see WPropertyVariable
00388      *
00389      * \param name  the property name
00390      * \param description the property description
00391      * \param initial the initial value
00392      * \param hide set to true to set the hide flag directly.
00393      *
00394      * \return the newly created property variable instance.
00395      */
00396     WPropPosition      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION&   initial, bool hide = false );
00397 
00398     /**
00399      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00400      *
00401      * \see WPropertyVariable
00402      *
00403      * \param name  the property name
00404      * \param description the property description
00405      * \param initial the initial value
00406      * \param hide set to true to set the hide flag directly.
00407      *
00408      * \return the newly created property variable instance.
00409      */
00410     WPropColor         addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR&  initial, bool hide = false );
00411 
00412     /**
00413      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00414      *
00415      * \see WPropertyVariable
00416      *
00417      * \param name  the property name
00418      * \param description the property description
00419      * \param initial the initial value
00420      * \param hide set to true to set the hide flag directly.
00421      *
00422      * \return the newly created property variable instance.
00423      */
00424     WPropTrigger       addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER&  initial, bool hide = false );
00425 
00426     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
00427     // convenience methods for
00428     // template< typename T>
00429     // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
00430     //                                                          boost::shared_ptr< WCondition > condition, bool hide = false );
00431     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
00432 
00433     /**
00434      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00435      *
00436      * \see WPropertyVariable
00437      *
00438      * \param name  the property name
00439      * \param description the property description
00440      * \param initial the initial value
00441      * \param condition use this external condition for notification.
00442      * \param hide set to true to set the hide flag directly.
00443      *
00444      * \return the newly created property variable instance.
00445      */
00446     WPropBool      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL&   initial,
00447                                 boost::shared_ptr< WCondition > condition, bool hide = false );
00448 
00449     /**
00450      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00451      * It also sets the min and max constraint to [0,100].
00452      *
00453      * \see WPropertyVariable
00454      *
00455      * \param name  the property name
00456      * \param description the property description
00457      * \param initial the initial value
00458      * \param condition use this external condition for notification.
00459      * \param hide set to true to set the hide flag directly.
00460      *
00461      * \return the newly created property variable instance.
00462      */
00463     WPropInt       addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT&    initial,
00464                                 boost::shared_ptr< WCondition > condition, bool hide = false );
00465 
00466     /**
00467      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00468      * It also sets the min and max constraint to [0,100].
00469      *
00470      * \see WPropertyVariable
00471      *
00472      * \param name  the property name
00473      * \param description the property description
00474      * \param initial the initial value
00475      * \param condition use this external condition for notification.
00476      * \param hide set to true to set the hide flag directly.
00477      *
00478      * \return the newly created property variable instance.
00479      */
00480     WPropDouble    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial,
00481                                 boost::shared_ptr< WCondition > condition, bool hide = false );
00482 
00483     /**
00484      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00485      *
00486      * \see WPropertyVariable
00487      *
00488      * \param name  the property name
00489      * \param description the property description
00490      * \param initial the initial value
00491      * \param condition use this external condition for notification.
00492      * \param hide set to true to set the hide flag directly.
00493      *
00494      * \return the newly created property variable instance.
00495      */
00496     WPropString    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial,
00497                                 boost::shared_ptr< WCondition > condition, bool hide = false );
00498 
00499     /**
00500      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00501      *
00502      * \see WPropertyVariable
00503      *
00504      * \param name  the property name
00505      * \param description the property description
00506      * \param initial the initial value
00507      * \param condition use this external condition for notification.
00508      * \param hide set to true to set the hide flag directly.
00509      *
00510      * \return the newly created property variable instance.
00511      */
00512     WPropFilename  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH&   initial,
00513                                 boost::shared_ptr< WCondition > condition, bool hide = false );
00514 
00515     /**
00516      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00517      *
00518      * \see WPropertyVariable
00519      *
00520      * \param name  the property name
00521      * \param description the property description
00522      * \param initial the initial value
00523      * \param condition use this external condition for notification.
00524      * \param hide set to true to set the hide flag directly.
00525      *
00526      * \return the newly created property variable instance.
00527      */
00528     WPropSelection addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION&   initial,
00529                                 boost::shared_ptr< WCondition > condition, bool hide = false );
00530 
00531     /**
00532      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00533      *
00534      * \see WPropertyVariable
00535      *
00536      * \param name  the property name
00537      * \param description the property description
00538      * \param initial the initial value
00539      * \param condition use this external condition for notification.
00540      * \param hide set to true to set the hide flag directly.
00541      *
00542      * \return the newly created property variable instance.
00543      */
00544     WPropPosition  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION&   initial,
00545                                 boost::shared_ptr< WCondition > condition, bool hide = false );
00546 
00547     /**
00548      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00549      *
00550      * \see WPropertyVariable
00551      *
00552      * \param name  the property name
00553      * \param description the property description
00554      * \param initial the initial value
00555      * \param condition use this external condition for notification.
00556      * \param hide set to true to set the hide flag directly.
00557      *
00558      * \return the newly created property variable instance.
00559      */
00560     WPropColor     addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR&   initial,
00561                                 boost::shared_ptr< WCondition > condition, bool hide = false );
00562 
00563     /**
00564      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00565      *
00566      * \see WPropertyVariable
00567      *
00568      * \param name  the property name
00569      * \param description the property description
00570      * \param initial the initial value
00571      * \param condition use this external condition for notification.
00572      * \param hide set to true to set the hide flag directly.
00573      *
00574      * \return the newly created property variable instance.
00575      */
00576     WPropTrigger   addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER&   initial,
00577                                 boost::shared_ptr< WCondition > condition, bool hide = false );
00578 
00579     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
00580     // convenience methods for
00581     // template< typename T>
00582     // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
00583     //                                                          WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00584     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
00585 
00586     /**
00587      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00588      *
00589      * \see WPropertyVariable
00590      *
00591      * \param name  the property name
00592      * \param description the property description
00593      * \param initial the initial value
00594      * \param notifier use this notifier for change callbacks.
00595      * \param hide set to true to set the hide flag directly.
00596      *
00597      * \return the newly created property variable instance.
00598      */
00599     WPropBool      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL&   initial,
00600                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00601 
00602     /**
00603      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00604      * It also sets the min and max constraint to [0,100].
00605      *
00606      * \see WPropertyVariable
00607      *
00608      * \param name  the property name
00609      * \param description the property description
00610      * \param initial the initial value
00611      * \param notifier use this notifier for change callbacks.
00612      * \param hide set to true to set the hide flag directly.
00613      *
00614      * \return the newly created property variable instance.
00615      */
00616     WPropInt       addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT&    initial,
00617                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00618 
00619     /**
00620      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00621      * It also sets the min and max constraint to [0,100].
00622      *
00623      * \see WPropertyVariable
00624      *
00625      * \param name  the property name
00626      * \param description the property description
00627      * \param initial the initial value
00628      * \param notifier use this notifier for change callbacks.
00629      * \param hide set to true to set the hide flag directly.
00630      *
00631      * \return the newly created property variable instance.
00632      */
00633     WPropDouble    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial,
00634                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00635 
00636     /**
00637      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00638      *
00639      * \see WPropertyVariable
00640      *
00641      * \param name  the property name
00642      * \param description the property description
00643      * \param initial the initial value
00644      * \param notifier use this notifier for change callbacks.
00645      * \param hide set to true to set the hide flag directly.
00646      *
00647      * \return the newly created property variable instance.
00648      */
00649     WPropString    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial,
00650                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00651 
00652     /**
00653      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00654      *
00655      * \see WPropertyVariable
00656      *
00657      * \param name  the property name
00658      * \param description the property description
00659      * \param initial the initial value
00660      * \param notifier use this notifier for change callbacks.
00661      * \param hide set to true to set the hide flag directly.
00662      *
00663      * \return the newly created property variable instance.
00664      */
00665     WPropFilename  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH&   initial,
00666                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00667 
00668     /**
00669      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00670      *
00671      * \see WPropertyVariable
00672      *
00673      * \param name  the property name
00674      * \param description the property description
00675      * \param initial the initial value
00676      * \param notifier use this notifier for change callbacks.
00677      * \param hide set to true to set the hide flag directly.
00678      *
00679      * \return the newly created property variable instance.
00680      */
00681     WPropSelection addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION&   initial,
00682                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00683 
00684     /**
00685      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00686      *
00687      * \see WPropertyVariable
00688      *
00689      * \param name  the property name
00690      * \param description the property description
00691      * \param initial the initial value
00692      * \param notifier use this notifier for change callbacks.
00693      * \param hide set to true to set the hide flag directly.
00694      *
00695      * \return the newly created property variable instance.
00696      */
00697     WPropPosition  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION& initial,
00698                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00699 
00700     /**
00701      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00702      *
00703      * \see WPropertyVariable
00704      *
00705      * \param name  the property name
00706      * \param description the property description
00707      * \param initial the initial value
00708      * \param notifier use this notifier for change callbacks.
00709      * \param hide set to true to set the hide flag directly.
00710      *
00711      * \return the newly created property variable instance.
00712      */
00713     WPropColor     addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR&  initial,
00714                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00715 
00716     /**
00717      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00718      *
00719      * \see WPropertyVariable
00720      *
00721      * \param name  the property name
00722      * \param description the property description
00723      * \param initial the initial value
00724      * \param notifier use this notifier for change callbacks.
00725      * \param hide set to true to set the hide flag directly.
00726      *
00727      * \return the newly created property variable instance.
00728      */
00729     WPropTrigger   addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER&  initial,
00730                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00731 
00732     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
00733     // convenience methods for
00734     // template< typename T>
00735     // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
00736     //                                                          boost::shared_ptr< WCondition > condition,
00737     //                                                          WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00738     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
00739 
00740     /**
00741      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00742      *
00743      * \see WPropertyVariable
00744      *
00745      * \param name  the property name
00746      * \param description the property description
00747      * \param initial the initial value
00748      * \param notifier use this notifier for change callbacks.
00749      * \param condition use this external condition for notification
00750      * \param hide set to true to set the hide flag directly.
00751      *
00752      * \return the newly created property variable instance.
00753      */
00754     WPropBool      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL&   initial,
00755                                 boost::shared_ptr< WCondition > condition,
00756                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00757 
00758     /**
00759      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00760      * It also sets the min and max constraint to [0,100].
00761      *
00762      * \see WPropertyVariable
00763      *
00764      * \param name  the property name
00765      * \param description the property description
00766      * \param initial the initial value
00767      * \param notifier use this notifier for change callbacks.
00768      * \param condition use this external condition for notification
00769      * \param hide set to true to set the hide flag directly.
00770      *
00771      * \return the newly created property variable instance.
00772      */
00773     WPropInt       addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT&    initial,
00774                                 boost::shared_ptr< WCondition > condition,
00775                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00776 
00777     /**
00778      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00779      * It also sets the min and max constraint to [0,100].
00780      *
00781      * \see WPropertyVariable
00782      *
00783      * \param name  the property name
00784      * \param description the property description
00785      * \param initial the initial value
00786      * \param notifier use this notifier for change callbacks.
00787      * \param condition use this external condition for notification
00788      * \param hide set to true to set the hide flag directly.
00789      *
00790      * \return the newly created property variable instance.
00791      */
00792     WPropDouble    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial,
00793                                 boost::shared_ptr< WCondition > condition,
00794                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00795 
00796 
00797     /**
00798      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00799      *
00800      * \see WPropertyVariable
00801      *
00802      * \param name  the property name
00803      * \param description the property description
00804      * \param initial the initial value
00805      * \param notifier use this notifier for change callbacks.
00806      * \param condition use this external condition for notification
00807      * \param hide set to true to set the hide flag directly.
00808      *
00809      * \return the newly created property variable instance.
00810      */
00811     WPropString    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial,
00812                                 boost::shared_ptr< WCondition > condition,
00813                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00814 
00815     /**
00816      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00817      *
00818      * \see WPropertyVariable
00819      *
00820      * \param name  the property name
00821      * \param description the property description
00822      * \param initial the initial value
00823      * \param notifier use this notifier for change callbacks.
00824      * \param condition use this external condition for notification
00825      * \param hide set to true to set the hide flag directly.
00826      *
00827      * \return the newly created property variable instance.
00828      */
00829     WPropFilename  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH&   initial,
00830                                 boost::shared_ptr< WCondition > condition,
00831                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00832 
00833     /**
00834      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00835      *
00836      * \see WPropertyVariable
00837      *
00838      * \param name  the property name
00839      * \param description the property description
00840      * \param initial the initial value
00841      * \param notifier use this notifier for change callbacks.
00842      * \param condition use this external condition for notification
00843      * \param hide set to true to set the hide flag directly.
00844      *
00845      * \return the newly created property variable instance.
00846      */
00847     WPropSelection addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION&   initial,
00848                                 boost::shared_ptr< WCondition > condition,
00849                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00850 
00851     /**
00852      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00853      *
00854      * \see WPropertyVariable
00855      *
00856      * \param name  the property name
00857      * \param description the property description
00858      * \param initial the initial value
00859      * \param notifier use this notifier for change callbacks.
00860      * \param condition use this external condition for notification
00861      * \param hide set to true to set the hide flag directly.
00862      *
00863      * \return the newly created property variable instance.
00864      */
00865     WPropPosition  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION&   initial,
00866                                 boost::shared_ptr< WCondition > condition,
00867                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00868 
00869     /**
00870      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00871      *
00872      * \see WPropertyVariable
00873      *
00874      * \param name  the property name
00875      * \param description the property description
00876      * \param initial the initial value
00877      * \param notifier use this notifier for change callbacks.
00878      * \param condition use this external condition for notification
00879      * \param hide set to true to set the hide flag directly.
00880      *
00881      * \return the newly created property variable instance.
00882      */
00883     WPropColor     addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR&   initial,
00884                                 boost::shared_ptr< WCondition > condition,
00885                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00886 
00887     /**
00888      * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
00889      *
00890      * \see WPropertyVariable
00891      *
00892      * \param name  the property name
00893      * \param description the property description
00894      * \param initial the initial value
00895      * \param notifier use this notifier for change callbacks.
00896      * \param condition use this external condition for notification
00897      * \param hide set to true to set the hide flag directly.
00898      *
00899      * \return the newly created property variable instance.
00900      */
00901     WPropTrigger   addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER&   initial,
00902                                 boost::shared_ptr< WCondition > condition,
00903                                 WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
00904 
00905 protected:
00906     /**
00907      * This function implements the set functionality. It works recursively and keeps track of the current path.
00908      *
00909      * \param value the value source
00910      * \param path the current path inside the source property group
00911      * \param exclude exclude list with paths relative to the original source group
00912      * \param recommendedOnly recommendation flag.
00913      *
00914      * \return true if everything was set successfully.
00915      */
00916     virtual bool setImpl( boost::shared_ptr< WPropertyGroup > value, std::string path = "",
00917                                                                      std::vector< std::string > exclude = std::vector< std::string >(),
00918                                                                      bool recommendedOnly = false );
00919 
00920 private:
00921 };
00922 
00923 template< typename PropType >
00924 PropType WPropertyGroup::addProperty( PropType prop )
00925 {
00926     addArbitraryProperty( prop );
00927     return prop;
00928 }
00929 
00930 template< typename T>
00931 boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial, bool hide )
00932 {
00933     boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >(
00934             new WPropertyVariable< T >( name, description, initial )
00935     );
00936     p->setHidden( hide );
00937     addProperty( p );
00938     return p;
00939 }
00940 
00941 template< typename T>
00942 boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial,
00943                                                                        boost::shared_ptr< WCondition > condition, bool hide )
00944 {
00945     boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >(
00946             new WPropertyVariable< T >( name, description, initial, condition )
00947     );
00948     p->setHidden( hide );
00949     addProperty( p );
00950     return p;
00951 }
00952 
00953 template< typename T>
00954 boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial,
00955                                                                        WPropertyBase::PropertyChangeNotifierType notifier, bool hide )
00956 {
00957     boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >(
00958             new WPropertyVariable< T >( name, description, initial, notifier )
00959     );
00960     p->setHidden( hide );
00961     addProperty( p );
00962     return p;
00963 }
00964 
00965 template< typename T>
00966 boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial,
00967                                                                        boost::shared_ptr< WCondition > condition,
00968                                                                        WPropertyBase::PropertyChangeNotifierType notifier, bool hide )
00969 {
00970     boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >(
00971             new WPropertyVariable< T >( name, description, initial, condition, notifier )
00972     );
00973     p->setHidden( hide );
00974     addProperty( p );
00975     return p;
00976 }
00977 
00978 #endif  // WPROPERTYGROUP_H