~ubuntu-branches/ubuntu/raring/openwalnut/raring

« back to all changes in this revision

Viewing changes to src/core/common/WPropertyGroup.h

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2012-12-12 11:26:32 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121212112632-xhiuwkxuz5h0idkh
Tags: 1.3.1+hg5849-1
* Minor changes compared to 1.3.0 but included several bug fixes.
* See http://www.openwalnut.org/versions/4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//---------------------------------------------------------------------------
 
2
//
 
3
// Project: OpenWalnut ( http://www.openwalnut.org )
 
4
//
 
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
 
6
// For more information see http://www.openwalnut.org/copying
 
7
//
 
8
// This file is part of OpenWalnut.
 
9
//
 
10
// OpenWalnut is free software: you can redistribute it and/or modify
 
11
// it under the terms of the GNU Lesser General Public License as published by
 
12
// the Free Software Foundation, either version 3 of the License, or
 
13
// (at your option) any later version.
 
14
//
 
15
// OpenWalnut is distributed in the hope that it will be useful,
 
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
// GNU Lesser General Public License for more details.
 
19
//
 
20
// You should have received a copy of the GNU Lesser General Public License
 
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
 
22
//
 
23
//---------------------------------------------------------------------------
 
24
 
 
25
#ifndef WPROPERTYGROUP_H
 
26
#define WPROPERTYGROUP_H
 
27
 
 
28
#include <map>
 
29
#include <string>
 
30
#include <vector>
 
31
 
 
32
#include "WConditionSet.h"
 
33
#include "WPropertyBase.h"
 
34
#include "WPropertyGroupBase.h"
 
35
#include "WPropertyTypes.h"
 
36
#include "WPropertyVariable.h"
 
37
#include "WSharedSequenceContainer.h"
 
38
#include "exceptions/WPropertyNotUnique.h"
 
39
 
 
40
 
 
41
 
 
42
/**
 
43
 * Class to manage properties of an object and to provide convenience methods for easy access and manipulation. It also allows
 
44
 * thread safe iteration on its elements. The main purpose of this class is to group properties together and to allow searching properties by a
 
45
 * 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
 
46
 * is the property with the name "property" in the group "you" which against is in the group "hello".
 
47
 * \note The root group of each module does not have a name.
 
48
 */
 
49
class WPropertyGroup: public WPropertyGroupBase
 
50
{
 
51
friend class WPropertiesTest;
 
52
public:
 
53
    // the following typedefs are for convenience.
 
54
    typedef boost::shared_ptr< WPropertyGroup > SPtr; //!< shared pointer to object of this type
 
55
    typedef boost::shared_ptr< const WPropertyGroup > ConstSPtr; //!< const shared pointer to object of this type
 
56
    typedef WPropertyGroup* Ptr; //!< pointer to object of this type
 
57
    typedef const WPropertyGroup* ConstPtr; //!< const pointer to object of this type
 
58
    typedef WPropertyGroup& Ref; //!< ref to object of this type
 
59
    typedef const WPropertyGroup& ConstRef; //!< const ref to object of this type
 
60
 
 
61
    /**
 
62
     * For shortening: a type defining a shared vector of WSubject pointers.
 
63
     */
 
64
    typedef WPropertyGroupBase::PropertyContainerType PropertyContainerType;
 
65
 
 
66
    /**
 
67
     * The alias for a shared container.
 
68
     */
 
69
    typedef WPropertyGroupBase::PropertySharedContainerType PropertySharedContainerType;
 
70
 
 
71
    /**
 
72
     * The const iterator type of the container.
 
73
     */
 
74
    typedef WPropertyGroupBase::PropertyConstIterator PropertyConstIterator;
 
75
 
 
76
    /**
 
77
     * The iterator type of the container.
 
78
     */
 
79
    typedef WPropertyGroupBase::PropertyIterator PropertyIterator;
 
80
 
 
81
    /**
 
82
     * Constructor. Creates an empty list of properties.
 
83
     *
 
84
     * \note WModule::getProperties always returns an unnamed instance.
 
85
     *
 
86
     * \param name the name of the property group. The GUI is using this name for naming the tabs/group boxes
 
87
     * \param description the description of the group.
 
88
     */
 
89
    WPropertyGroup( std::string name = "unnamed group", std::string description = "an unnamed group of properties" );
 
90
 
 
91
    /**
 
92
     * Copy constructor. Creates a deep copy of this property. As boost::signals2 and condition variables are non-copyable, new instances get
 
93
     * created. The subscriptions to a signal are LOST as well as all listeners to a condition.
 
94
     * The conditions you can grab using getValueChangeConditon and getCondition are not the same as in the original! This is because
 
95
     * the class corresponds to the observer/observable pattern. You won't expect a clone to fire a condition if a original flag is changed
 
96
     * (which after cloning is completely decoupled from the clone).
 
97
     *
 
98
     * \note the properties inside this list are also copied deep
 
99
     *
 
100
     * \param from the instance to copy.
 
101
     */
 
102
    explicit WPropertyGroup( const WPropertyGroup& from );
 
103
 
 
104
    /**
 
105
     * destructor
 
106
     */
 
107
    virtual ~WPropertyGroup();
 
108
 
 
109
    ///////////////////////////////////////////////////////////////////////////////////////////////////
 
110
    // The WPropertyBase interface
 
111
    ///////////////////////////////////////////////////////////////////////////////////////////////////
 
112
 
 
113
    /**
 
114
     * 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
 
115
     * correct type without explicitly requiring the user to specify it. It creates a NEW change condition and change signal. This means, alls
 
116
     * subscribed signal handlers are NOT copied.
 
117
     *
 
118
     * \note this simply ensures the copy constructor of the runtime type is issued.
 
119
     *
 
120
     * \return the deep clone of this property.
 
121
     */
 
122
    virtual boost::shared_ptr< WPropertyBase > clone();
 
123
 
 
124
    /**
 
125
     * Gets the real type of this instance. In this case, PV_GROUP.
 
126
     *
 
127
     * \return the real type.
 
128
     */
 
129
    virtual PROPERTY_TYPE getType() const;
 
130
 
 
131
    /**
 
132
     * 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.
 
133
     *
 
134
     * \param value the new value to set. IGNORED.
 
135
     *
 
136
     * \return always true
 
137
     */
 
138
    virtual bool setAsString( std::string value );
 
139
 
 
140
    /**
 
141
     * Returns the current value as a string. This is useful for debugging or project files. It is not implemented as << operator, since the <<
 
142
     * should also print min/max constraints and so on. This simply is the value.
 
143
     *
 
144
     * \return the value as a string.
 
145
     */
 
146
    virtual std::string getAsString();
 
147
 
 
148
    /**
 
149
     * Sets the value from the specified property to this one. This is especially useful to copy a value without explicitly casting/knowing the
 
150
     * dynamic type of the property.
 
151
     * For WPropertyGroup, this tries to set the contained properties to the value of the given group. It does not add/remove properties. It
 
152
     * simply sets the children values to the ones given.
 
153
     *
 
154
     * \param value the new value.
 
155
     * \param recommendedOnly if true, property types which support recommended values apply the given value as recommendation.
 
156
     *
 
157
     * \return true if the values of the children could be set. If one could not be set, false
 
158
     */
 
159
    virtual bool set( boost::shared_ptr< WPropertyBase > value, bool recommendedOnly = false );
 
160
 
 
161
    ///////////////////////////////////////////////////////////////////////////////////////////////////
 
162
    // Extend the WPropertyGroupBase to allow the property list to be modified
 
163
    ///////////////////////////////////////////////////////////////////////////////////////////////////
 
164
 
 
165
    /**
 
166
     * Removes all properties from the list.
 
167
     */
 
168
    virtual void clear();
 
169
 
 
170
    /**
 
171
     * Insert the specified property into the list.
 
172
     *
 
173
     * \param prop the property to add
 
174
     *
 
175
     * \return The given prop.
 
176
     */
 
177
    template< typename PropType >
 
178
    PropType addProperty( PropType prop );
 
179
 
 
180
    /**
 
181
     * Remove the specified property from the list. If the given property is not in the list, nothing happens.
 
182
     *
 
183
     * \param prop the property to remove.
 
184
     */
 
185
    void removeProperty( boost::shared_ptr< WPropertyBase > prop );
 
186
 
 
187
    ///////////////////////////////////////////////////////////////////////////////////////////////////
 
188
    // Convenience methods to create and add properties
 
189
    ///////////////////////////////////////////////////////////////////////////////////////////////////
 
190
 
 
191
    /**
 
192
     * Create and add a new property group. Use these groups to structure your properties.
 
193
     *
 
194
     * \param name the name of the group.
 
195
     * \param description the description of the group.
 
196
     * \param hide true if group should be completely hidden.
 
197
     *
 
198
     * \return The newly created property group.
 
199
     */
 
200
    WPropGroup addPropertyGroup( std::string name, std::string description, bool hide = false );
 
201
 
 
202
    /**
 
203
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
204
     *
 
205
     * \see WPropertyVariable
 
206
     *
 
207
     * \param name  the property name
 
208
     * \param description the property description
 
209
     * \param initial the initial value
 
210
     * \param hide set to true to set the hide flag directly.
 
211
     *
 
212
     * \return the newly created property variable instance.
 
213
     */
 
214
    template< typename T>
 
215
    boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, bool hide = false );
 
216
 
 
217
    /**
 
218
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
219
     *
 
220
     * \see WPropertyVariable
 
221
     *
 
222
     * \param name  the property name
 
223
     * \param description the property description
 
224
     * \param initial the initial value
 
225
     * \param condition use this external condition for notification.
 
226
     * \param hide set to true to set the hide flag directly.
 
227
     *
 
228
     * \return the newly created property variable instance.
 
229
     */
 
230
    template< typename T>
 
231
    boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
 
232
                                                             boost::shared_ptr< WCondition > condition, bool hide = false );
 
233
 
 
234
    /**
 
235
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
236
     *
 
237
     * \see WPropertyVariable
 
238
     *
 
239
     * \param name  the property name
 
240
     * \param description the property description
 
241
     * \param initial the initial value
 
242
     * \param notifier use this notifier for change callbacks.
 
243
     * \param hide set to true to set the hide flag directly.
 
244
     *
 
245
     * \return the newly created property variable instance.
 
246
     */
 
247
    template< typename T>
 
248
    boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
 
249
                                                             WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
250
 
 
251
    /**
 
252
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
253
     *
 
254
     * \see WPropertyVariable
 
255
     *
 
256
     * \param name  the property name
 
257
     * \param description the property description
 
258
     * \param initial the initial value
 
259
     * \param notifier use this notifier for change callbacks.
 
260
     * \param condition use this external condition for notification
 
261
     * \param hide set to true to set the hide flag directly.
 
262
     *
 
263
     * \return the newly created property variable instance.
 
264
     */
 
265
    template< typename T>
 
266
    boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
 
267
                                                             boost::shared_ptr< WCondition > condition,
 
268
                                                             WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
269
 
 
270
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
271
    // Convenience methods to create and add properties
 
272
    // NOTE: these methods use the type of the initial parameter to automatically use the proper type.
 
273
    // This works, since the compiler always calls the function with the best matching parameter types.
 
274
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
275
 
 
276
 
 
277
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
278
    // convenience methods for
 
279
    // template< typename T>
 
280
    // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial, bool hide = false );
 
281
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
282
 
 
283
    /**
 
284
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
285
     *
 
286
     * \see WPropertyVariable
 
287
     *
 
288
     * \param name  the property name
 
289
     * \param description the property description
 
290
     * \param initial the initial value
 
291
     * \param hide set to true to set the hide flag directly.
 
292
     *
 
293
     * \return the newly created property variable instance.
 
294
     */
 
295
    WPropBool      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL&   initial, bool hide = false );
 
296
 
 
297
    /**
 
298
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
299
     * It also sets the min and max constraint to [0,100].
 
300
     *
 
301
     * \see WPropertyVariable
 
302
     *
 
303
     * \param name  the property name
 
304
     * \param description the property description
 
305
     * \param initial the initial value
 
306
     * \param hide set to true to set the hide flag directly.
 
307
     *
 
308
     * \return the newly created property variable instance.
 
309
     */
 
310
    WPropInt       addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT&    initial, bool hide = false );
 
311
 
 
312
    /**
 
313
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
314
     * It also sets the min and max constraint to [0,100].
 
315
     *
 
316
     * \see WPropertyVariable
 
317
     *
 
318
     * \param name  the property name
 
319
     * \param description the property description
 
320
     * \param initial the initial value
 
321
     * \param hide set to true to set the hide flag directly.
 
322
     *
 
323
     * \return the newly created property variable instance.
 
324
     */
 
325
    WPropDouble    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial, bool hide = false );
 
326
 
 
327
    /**
 
328
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
329
     *
 
330
     * \see WPropertyVariable
 
331
     *
 
332
     * \param name  the property name
 
333
     * \param description the property description
 
334
     * \param initial the initial value
 
335
     * \param hide set to true to set the hide flag directly.
 
336
     *
 
337
     * \return the newly created property variable instance.
 
338
     */
 
339
    WPropString    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial, bool hide = false );
 
340
 
 
341
    /**
 
342
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
343
     *
 
344
     * \see WPropertyVariable
 
345
     *
 
346
     * \param name  the property name
 
347
     * \param description the property description
 
348
     * \param initial the initial value
 
349
     * \param hide set to true to set the hide flag directly.
 
350
     *
 
351
     * \return the newly created property variable instance.
 
352
     */
 
353
    WPropFilename  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH&   initial, bool hide = false );
 
354
 
 
355
    /**
 
356
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
357
     *
 
358
     * \see WPropertyVariable
 
359
     *
 
360
     * \param name  the property name
 
361
     * \param description the property description
 
362
     * \param initial the initial value
 
363
     * \param hide set to true to set the hide flag directly.
 
364
     *
 
365
     * \return the newly created property variable instance.
 
366
     */
 
367
    WPropSelection      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION&   initial, bool hide = false );
 
368
 
 
369
    /**
 
370
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
371
     *
 
372
     * \see WPropertyVariable
 
373
     *
 
374
     * \param name  the property name
 
375
     * \param description the property description
 
376
     * \param initial the initial value
 
377
     * \param hide set to true to set the hide flag directly.
 
378
     *
 
379
     * \return the newly created property variable instance.
 
380
     */
 
381
    WPropPosition      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION&   initial, bool hide = false );
 
382
 
 
383
    /**
 
384
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
385
     *
 
386
     * \see WPropertyVariable
 
387
     *
 
388
     * \param name  the property name
 
389
     * \param description the property description
 
390
     * \param initial the initial value
 
391
     * \param hide set to true to set the hide flag directly.
 
392
     *
 
393
     * \return the newly created property variable instance.
 
394
     */
 
395
    WPropColor         addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR&  initial, bool hide = false );
 
396
 
 
397
    /**
 
398
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
399
     *
 
400
     * \see WPropertyVariable
 
401
     *
 
402
     * \param name  the property name
 
403
     * \param description the property description
 
404
     * \param initial the initial value
 
405
     * \param hide set to true to set the hide flag directly.
 
406
     *
 
407
     * \return the newly created property variable instance.
 
408
     */
 
409
    WPropTrigger       addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER&  initial, bool hide = false );
 
410
 
 
411
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
412
    // convenience methods for
 
413
    // template< typename T>
 
414
    // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
 
415
    //                                                          boost::shared_ptr< WCondition > condition, bool hide = false );
 
416
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
417
 
 
418
    /**
 
419
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
420
     *
 
421
     * \see WPropertyVariable
 
422
     *
 
423
     * \param name  the property name
 
424
     * \param description the property description
 
425
     * \param initial the initial value
 
426
     * \param condition use this external condition for notification.
 
427
     * \param hide set to true to set the hide flag directly.
 
428
     *
 
429
     * \return the newly created property variable instance.
 
430
     */
 
431
    WPropBool      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL&   initial,
 
432
                                boost::shared_ptr< WCondition > condition, bool hide = false );
 
433
 
 
434
    /**
 
435
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
436
     * It also sets the min and max constraint to [0,100].
 
437
     *
 
438
     * \see WPropertyVariable
 
439
     *
 
440
     * \param name  the property name
 
441
     * \param description the property description
 
442
     * \param initial the initial value
 
443
     * \param condition use this external condition for notification.
 
444
     * \param hide set to true to set the hide flag directly.
 
445
     *
 
446
     * \return the newly created property variable instance.
 
447
     */
 
448
    WPropInt       addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT&    initial,
 
449
                                boost::shared_ptr< WCondition > condition, bool hide = false );
 
450
 
 
451
    /**
 
452
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
453
     * It also sets the min and max constraint to [0,100].
 
454
     *
 
455
     * \see WPropertyVariable
 
456
     *
 
457
     * \param name  the property name
 
458
     * \param description the property description
 
459
     * \param initial the initial value
 
460
     * \param condition use this external condition for notification.
 
461
     * \param hide set to true to set the hide flag directly.
 
462
     *
 
463
     * \return the newly created property variable instance.
 
464
     */
 
465
    WPropDouble    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial,
 
466
                                boost::shared_ptr< WCondition > condition, bool hide = false );
 
467
 
 
468
    /**
 
469
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
470
     *
 
471
     * \see WPropertyVariable
 
472
     *
 
473
     * \param name  the property name
 
474
     * \param description the property description
 
475
     * \param initial the initial value
 
476
     * \param condition use this external condition for notification.
 
477
     * \param hide set to true to set the hide flag directly.
 
478
     *
 
479
     * \return the newly created property variable instance.
 
480
     */
 
481
    WPropString    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial,
 
482
                                boost::shared_ptr< WCondition > condition, bool hide = false );
 
483
 
 
484
    /**
 
485
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
486
     *
 
487
     * \see WPropertyVariable
 
488
     *
 
489
     * \param name  the property name
 
490
     * \param description the property description
 
491
     * \param initial the initial value
 
492
     * \param condition use this external condition for notification.
 
493
     * \param hide set to true to set the hide flag directly.
 
494
     *
 
495
     * \return the newly created property variable instance.
 
496
     */
 
497
    WPropFilename  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH&   initial,
 
498
                                boost::shared_ptr< WCondition > condition, bool hide = false );
 
499
 
 
500
    /**
 
501
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
502
     *
 
503
     * \see WPropertyVariable
 
504
     *
 
505
     * \param name  the property name
 
506
     * \param description the property description
 
507
     * \param initial the initial value
 
508
     * \param condition use this external condition for notification.
 
509
     * \param hide set to true to set the hide flag directly.
 
510
     *
 
511
     * \return the newly created property variable instance.
 
512
     */
 
513
    WPropSelection addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION&   initial,
 
514
                                boost::shared_ptr< WCondition > condition, bool hide = false );
 
515
 
 
516
    /**
 
517
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
518
     *
 
519
     * \see WPropertyVariable
 
520
     *
 
521
     * \param name  the property name
 
522
     * \param description the property description
 
523
     * \param initial the initial value
 
524
     * \param condition use this external condition for notification.
 
525
     * \param hide set to true to set the hide flag directly.
 
526
     *
 
527
     * \return the newly created property variable instance.
 
528
     */
 
529
    WPropPosition  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION&   initial,
 
530
                                boost::shared_ptr< WCondition > condition, bool hide = false );
 
531
 
 
532
    /**
 
533
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
534
     *
 
535
     * \see WPropertyVariable
 
536
     *
 
537
     * \param name  the property name
 
538
     * \param description the property description
 
539
     * \param initial the initial value
 
540
     * \param condition use this external condition for notification.
 
541
     * \param hide set to true to set the hide flag directly.
 
542
     *
 
543
     * \return the newly created property variable instance.
 
544
     */
 
545
    WPropColor     addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR&   initial,
 
546
                                boost::shared_ptr< WCondition > condition, bool hide = false );
 
547
 
 
548
    /**
 
549
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
550
     *
 
551
     * \see WPropertyVariable
 
552
     *
 
553
     * \param name  the property name
 
554
     * \param description the property description
 
555
     * \param initial the initial value
 
556
     * \param condition use this external condition for notification.
 
557
     * \param hide set to true to set the hide flag directly.
 
558
     *
 
559
     * \return the newly created property variable instance.
 
560
     */
 
561
    WPropTrigger   addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER&   initial,
 
562
                                boost::shared_ptr< WCondition > condition, bool hide = false );
 
563
 
 
564
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
565
    // convenience methods for
 
566
    // template< typename T>
 
567
    // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
 
568
    //                                                          WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
569
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
570
 
 
571
    /**
 
572
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
573
     *
 
574
     * \see WPropertyVariable
 
575
     *
 
576
     * \param name  the property name
 
577
     * \param description the property description
 
578
     * \param initial the initial value
 
579
     * \param notifier use this notifier for change callbacks.
 
580
     * \param hide set to true to set the hide flag directly.
 
581
     *
 
582
     * \return the newly created property variable instance.
 
583
     */
 
584
    WPropBool      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL&   initial,
 
585
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
586
 
 
587
    /**
 
588
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
589
     * It also sets the min and max constraint to [0,100].
 
590
     *
 
591
     * \see WPropertyVariable
 
592
     *
 
593
     * \param name  the property name
 
594
     * \param description the property description
 
595
     * \param initial the initial value
 
596
     * \param notifier use this notifier for change callbacks.
 
597
     * \param hide set to true to set the hide flag directly.
 
598
     *
 
599
     * \return the newly created property variable instance.
 
600
     */
 
601
    WPropInt       addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT&    initial,
 
602
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
603
 
 
604
    /**
 
605
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
606
     * It also sets the min and max constraint to [0,100].
 
607
     *
 
608
     * \see WPropertyVariable
 
609
     *
 
610
     * \param name  the property name
 
611
     * \param description the property description
 
612
     * \param initial the initial value
 
613
     * \param notifier use this notifier for change callbacks.
 
614
     * \param hide set to true to set the hide flag directly.
 
615
     *
 
616
     * \return the newly created property variable instance.
 
617
     */
 
618
    WPropDouble    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial,
 
619
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
620
 
 
621
    /**
 
622
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
623
     *
 
624
     * \see WPropertyVariable
 
625
     *
 
626
     * \param name  the property name
 
627
     * \param description the property description
 
628
     * \param initial the initial value
 
629
     * \param notifier use this notifier for change callbacks.
 
630
     * \param hide set to true to set the hide flag directly.
 
631
     *
 
632
     * \return the newly created property variable instance.
 
633
     */
 
634
    WPropString    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial,
 
635
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
636
 
 
637
    /**
 
638
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
639
     *
 
640
     * \see WPropertyVariable
 
641
     *
 
642
     * \param name  the property name
 
643
     * \param description the property description
 
644
     * \param initial the initial value
 
645
     * \param notifier use this notifier for change callbacks.
 
646
     * \param hide set to true to set the hide flag directly.
 
647
     *
 
648
     * \return the newly created property variable instance.
 
649
     */
 
650
    WPropFilename  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH&   initial,
 
651
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
652
 
 
653
    /**
 
654
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
655
     *
 
656
     * \see WPropertyVariable
 
657
     *
 
658
     * \param name  the property name
 
659
     * \param description the property description
 
660
     * \param initial the initial value
 
661
     * \param notifier use this notifier for change callbacks.
 
662
     * \param hide set to true to set the hide flag directly.
 
663
     *
 
664
     * \return the newly created property variable instance.
 
665
     */
 
666
    WPropSelection addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION&   initial,
 
667
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
668
 
 
669
    /**
 
670
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
671
     *
 
672
     * \see WPropertyVariable
 
673
     *
 
674
     * \param name  the property name
 
675
     * \param description the property description
 
676
     * \param initial the initial value
 
677
     * \param notifier use this notifier for change callbacks.
 
678
     * \param hide set to true to set the hide flag directly.
 
679
     *
 
680
     * \return the newly created property variable instance.
 
681
     */
 
682
    WPropPosition  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION& initial,
 
683
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
684
 
 
685
    /**
 
686
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
687
     *
 
688
     * \see WPropertyVariable
 
689
     *
 
690
     * \param name  the property name
 
691
     * \param description the property description
 
692
     * \param initial the initial value
 
693
     * \param notifier use this notifier for change callbacks.
 
694
     * \param hide set to true to set the hide flag directly.
 
695
     *
 
696
     * \return the newly created property variable instance.
 
697
     */
 
698
    WPropColor     addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR&  initial,
 
699
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
700
 
 
701
    /**
 
702
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
703
     *
 
704
     * \see WPropertyVariable
 
705
     *
 
706
     * \param name  the property name
 
707
     * \param description the property description
 
708
     * \param initial the initial value
 
709
     * \param notifier use this notifier for change callbacks.
 
710
     * \param hide set to true to set the hide flag directly.
 
711
     *
 
712
     * \return the newly created property variable instance.
 
713
     */
 
714
    WPropTrigger   addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER&  initial,
 
715
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
716
 
 
717
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
718
    // convenience methods for
 
719
    // template< typename T>
 
720
    // boost::shared_ptr< WPropertyVariable< T > > addProperty( std::string name, std::string description, const T& initial,
 
721
    //                                                          boost::shared_ptr< WCondition > condition,
 
722
    //                                                          WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
723
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
724
 
 
725
    /**
 
726
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
727
     *
 
728
     * \see WPropertyVariable
 
729
     *
 
730
     * \param name  the property name
 
731
     * \param description the property description
 
732
     * \param initial the initial value
 
733
     * \param notifier use this notifier for change callbacks.
 
734
     * \param condition use this external condition for notification
 
735
     * \param hide set to true to set the hide flag directly.
 
736
     *
 
737
     * \return the newly created property variable instance.
 
738
     */
 
739
    WPropBool      addProperty( std::string name, std::string description, const WPVBaseTypes::PV_BOOL&   initial,
 
740
                                boost::shared_ptr< WCondition > condition,
 
741
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
742
 
 
743
    /**
 
744
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
745
     * It also sets the min and max constraint to [0,100].
 
746
     *
 
747
     * \see WPropertyVariable
 
748
     *
 
749
     * \param name  the property name
 
750
     * \param description the property description
 
751
     * \param initial the initial value
 
752
     * \param notifier use this notifier for change callbacks.
 
753
     * \param condition use this external condition for notification
 
754
     * \param hide set to true to set the hide flag directly.
 
755
     *
 
756
     * \return the newly created property variable instance.
 
757
     */
 
758
    WPropInt       addProperty( std::string name, std::string description, const WPVBaseTypes::PV_INT&    initial,
 
759
                                boost::shared_ptr< WCondition > condition,
 
760
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
761
 
 
762
    /**
 
763
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
764
     * It also sets the min and max constraint to [0,100].
 
765
     *
 
766
     * \see WPropertyVariable
 
767
     *
 
768
     * \param name  the property name
 
769
     * \param description the property description
 
770
     * \param initial the initial value
 
771
     * \param notifier use this notifier for change callbacks.
 
772
     * \param condition use this external condition for notification
 
773
     * \param hide set to true to set the hide flag directly.
 
774
     *
 
775
     * \return the newly created property variable instance.
 
776
     */
 
777
    WPropDouble    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_DOUBLE& initial,
 
778
                                boost::shared_ptr< WCondition > condition,
 
779
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
780
 
 
781
 
 
782
    /**
 
783
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
784
     *
 
785
     * \see WPropertyVariable
 
786
     *
 
787
     * \param name  the property name
 
788
     * \param description the property description
 
789
     * \param initial the initial value
 
790
     * \param notifier use this notifier for change callbacks.
 
791
     * \param condition use this external condition for notification
 
792
     * \param hide set to true to set the hide flag directly.
 
793
     *
 
794
     * \return the newly created property variable instance.
 
795
     */
 
796
    WPropString    addProperty( std::string name, std::string description, const WPVBaseTypes::PV_STRING& initial,
 
797
                                boost::shared_ptr< WCondition > condition,
 
798
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
799
 
 
800
    /**
 
801
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
802
     *
 
803
     * \see WPropertyVariable
 
804
     *
 
805
     * \param name  the property name
 
806
     * \param description the property description
 
807
     * \param initial the initial value
 
808
     * \param notifier use this notifier for change callbacks.
 
809
     * \param condition use this external condition for notification
 
810
     * \param hide set to true to set the hide flag directly.
 
811
     *
 
812
     * \return the newly created property variable instance.
 
813
     */
 
814
    WPropFilename  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH&   initial,
 
815
                                boost::shared_ptr< WCondition > condition,
 
816
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
817
 
 
818
    /**
 
819
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
820
     *
 
821
     * \see WPropertyVariable
 
822
     *
 
823
     * \param name  the property name
 
824
     * \param description the property description
 
825
     * \param initial the initial value
 
826
     * \param notifier use this notifier for change callbacks.
 
827
     * \param condition use this external condition for notification
 
828
     * \param hide set to true to set the hide flag directly.
 
829
     *
 
830
     * \return the newly created property variable instance.
 
831
     */
 
832
    WPropSelection addProperty( std::string name, std::string description, const WPVBaseTypes::PV_SELECTION&   initial,
 
833
                                boost::shared_ptr< WCondition > condition,
 
834
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
835
 
 
836
    /**
 
837
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
838
     *
 
839
     * \see WPropertyVariable
 
840
     *
 
841
     * \param name  the property name
 
842
     * \param description the property description
 
843
     * \param initial the initial value
 
844
     * \param notifier use this notifier for change callbacks.
 
845
     * \param condition use this external condition for notification
 
846
     * \param hide set to true to set the hide flag directly.
 
847
     *
 
848
     * \return the newly created property variable instance.
 
849
     */
 
850
    WPropPosition  addProperty( std::string name, std::string description, const WPVBaseTypes::PV_POSITION&   initial,
 
851
                                boost::shared_ptr< WCondition > condition,
 
852
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
853
 
 
854
    /**
 
855
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
856
     *
 
857
     * \see WPropertyVariable
 
858
     *
 
859
     * \param name  the property name
 
860
     * \param description the property description
 
861
     * \param initial the initial value
 
862
     * \param notifier use this notifier for change callbacks.
 
863
     * \param condition use this external condition for notification
 
864
     * \param hide set to true to set the hide flag directly.
 
865
     *
 
866
     * \return the newly created property variable instance.
 
867
     */
 
868
    WPropColor     addProperty( std::string name, std::string description, const WPVBaseTypes::PV_COLOR&   initial,
 
869
                                boost::shared_ptr< WCondition > condition,
 
870
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
871
 
 
872
    /**
 
873
     * Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
 
874
     *
 
875
     * \see WPropertyVariable
 
876
     *
 
877
     * \param name  the property name
 
878
     * \param description the property description
 
879
     * \param initial the initial value
 
880
     * \param notifier use this notifier for change callbacks.
 
881
     * \param condition use this external condition for notification
 
882
     * \param hide set to true to set the hide flag directly.
 
883
     *
 
884
     * \return the newly created property variable instance.
 
885
     */
 
886
    WPropTrigger   addProperty( std::string name, std::string description, const WPVBaseTypes::PV_TRIGGER&   initial,
 
887
                                boost::shared_ptr< WCondition > condition,
 
888
                                WPropertyBase::PropertyChangeNotifierType notifier, bool hide = false );
 
889
 
 
890
protected:
 
891
private:
 
892
};
 
893
 
 
894
template< typename PropType >
 
895
PropType WPropertyGroup::addProperty( PropType prop )
 
896
{
 
897
    addArbitraryProperty( prop );
 
898
    return prop;
 
899
}
 
900
 
 
901
template< typename T>
 
902
boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial, bool hide )
 
903
{
 
904
    boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >(
 
905
            new WPropertyVariable< T >( name, description, initial )
 
906
    );
 
907
    p->setHidden( hide );
 
908
    addProperty( p );
 
909
    return p;
 
910
}
 
911
 
 
912
template< typename T>
 
913
boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial,
 
914
                                                                       boost::shared_ptr< WCondition > condition, bool hide )
 
915
{
 
916
    boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >(
 
917
            new WPropertyVariable< T >( name, description, initial, condition )
 
918
    );
 
919
    p->setHidden( hide );
 
920
    addProperty( p );
 
921
    return p;
 
922
}
 
923
 
 
924
template< typename T>
 
925
boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial,
 
926
                                                                       WPropertyBase::PropertyChangeNotifierType notifier, bool hide )
 
927
{
 
928
    boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >(
 
929
            new WPropertyVariable< T >( name, description, initial, notifier )
 
930
    );
 
931
    p->setHidden( hide );
 
932
    addProperty( p );
 
933
    return p;
 
934
}
 
935
 
 
936
template< typename T>
 
937
boost::shared_ptr< WPropertyVariable< T > > WPropertyGroup::addProperty( std::string name, std::string description, const T& initial,
 
938
                                                                       boost::shared_ptr< WCondition > condition,
 
939
                                                                       WPropertyBase::PropertyChangeNotifierType notifier, bool hide )
 
940
{
 
941
    boost::shared_ptr< WPropertyVariable< T > > p = boost::shared_ptr< WPropertyVariable< T > >(
 
942
            new WPropertyVariable< T >( name, description, initial, condition, notifier )
 
943
    );
 
944
    p->setHidden( hide );
 
945
    addProperty( p );
 
946
    return p;
 
947
}
 
948
 
 
949
#endif  // WPROPERTYGROUP_H