BALL 1.5.0
property.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4// $Id: property.h,v 1.40 2005/12/23 17:01:41 amoll Exp $
5//
6
7#ifndef BALL_CONCEPT_PROPERTY_H
8#define BALL_CONCEPT_PROPERTY_H
9
10#ifndef BALL_COMMON_H
11# include <BALL/common.h>
12#endif
13
14#ifndef BALL_DATATYPE_BITVECTOR_H
16#endif
17
18#ifndef BALL_CONCEPT_PERSISTENTOBJECT_H
20#endif
21
22#include <iostream>
23
24#include <boost/shared_ptr.hpp>
25#include <boost/any.hpp>
26
27namespace BALL
28{
29
34
39 : public PersistentObject
40 {
41 public:
42
44
45
51 enum Type
52 {
57
61
66
70
74
79
85
92
97 SMART_OBJECT
98 };
99
101
104
105 /* The default constructor
106 */
108
115 NamedProperty(const std::string& name);
116
123 NamedProperty(const std::string& name, bool value);
124
131 NamedProperty(const std::string& name, int value);
132
139 NamedProperty(const std::string& name, unsigned int value);
140
147 NamedProperty(const std::string& name, float value);
148
155 NamedProperty(const std::string& name, double value);
156
164 NamedProperty(const std::string& name, const std::string& str);
165
173 NamedProperty(const std::string& name, PersistentObject& po);
174
182 NamedProperty(const std::string& name, boost::shared_ptr<PersistentObject>& po);
183
187
191 NamedProperty(const NamedProperty&, const std::string& name);
192
198
201 virtual void clear();
202
204
207
211 virtual void persistentWrite(PersistenceManager& pm, const char* name = "") const;
212
217
219
222
224 Type getType() const;
225
227 const std::string& getName() const;
228
233 bool getBool() const;
234
239 int getInt() const;
240
245 float getFloat() const;
246
251 double getDouble() const;
252
257 unsigned int getUnsignedInt() const;
258
264
269 boost::shared_ptr<PersistentObject> getSmartObject() const;
270
276
280
282
285
289 bool operator == (const NamedProperty& np) const;
290
294 bool operator != (const NamedProperty& np) const;
295
297 void operator = (const NamedProperty& np);
298
300
301 private:
302
303 /*_ The kind of information contained in the NamedProperty
304 */
305 Type type_;
306
307 /*_ The name of the property object
308 */
309 std::string name_;
310
311 /*_ The data
312 */
313 boost::any data_;
314
315 };
316
317 typedef std::vector<NamedProperty>::iterator NamedPropertyIterator;
318
344 {
345 public:
346
348
349
351
353
356
359 PropertyManager(const PropertyManager& property_manager);
360
363
365 virtual void clear();
366
368 virtual void destroy();
369
371
374
378 void set(const PropertyManager& property_manager);
379
386 const PropertyManager& operator = (const PropertyManager& property_manager);
387
393 void get(PropertyManager& property_manager) const;
394
398 void swap(PropertyManager& property_manager);
399
401
404
412
419 const BitVector& getBitVector() const;
420
422
425
432 operator BitVector& ();
433
435
438
444 void setProperty(Property property);
445
451 void clearProperty(Property property);
452
458 void toggleProperty(Property property);
459
466
468
477
482
487
495 void setProperty(const NamedProperty& property);
496
503 void setProperty(const std::string& name);
504
512 void setProperty(const std::string& name, bool value);
513
521 void setProperty(const std::string& name, int value);
522
530 void setProperty(const std::string& name, unsigned int value);
531
539 void setProperty(const std::string& name, float value);
540
548 void setProperty(const std::string& name, double value);
549
557 void setProperty(const std::string& name, const std::string& value);
558
566 void setProperty(const std::string& name, const PersistentObject& value);
567
574 const NamedProperty& getProperty(const std::string& name) const;
575
578
581
587 void clearProperty(const std::string& name);
588
594
599 bool hasProperty(Property property) const;
600
602 bool hasProperty(const std::string& name) const;
603
607 bool operator == (const PropertyManager& pm) const;
608
610 bool operator != (const PropertyManager& pm) const;
611
613
614
619 void write(PersistenceManager& pm) const;
620
624
628
633 bool isValid() const;
634
641 void dump(std::ostream& s = std::cout, Size depth = 0) const;
642
644
645 private:
646
647 BitVector bitvector_;
648 std::vector<NamedProperty> named_properties_;
649 };
650
652
653# ifndef BALL_NO_INLINE_FUNCTIONS
654# include <BALL/CONCEPT/property.iC>
655# endif
656
657} // namespace BALL
658
659#endif // BALL_CONCEPT_PROPERTY_H
#define BALL_INLINE
Definition: debug.h:15
#define BALL_CREATE(name)
Definition: create.h:62
Definition: constants.h:13
BALL_EXPORT bool operator==(const String &s1, const String &s2)
BALL_EXPORT bool operator!=(const String &s1, const String &s2)
std::vector< NamedProperty >::iterator NamedPropertyIterator
Definition: property.h:317
NamedProperty(const NamedProperty &, const std::string &name)
NamedProperty(const std::string &name, boost::shared_ptr< PersistentObject > &po)
NamedProperty(const std::string &name, PersistentObject &po)
NamedProperty(const std::string &name, unsigned int value)
unsigned int getUnsignedInt() const
NamedProperty(const NamedProperty &)
NamedProperty(const std::string &name, double value)
int getInt() const
NamedProperty(const std::string &name, bool value)
NamedProperty(const std::string &name, float value)
double getDouble() const
String getString() const
virtual void persistentRead(PersistenceManager &pm)
String toString() const
NamedProperty(const std::string &name, int value)
virtual void clear()
NamedProperty(const std::string &name, const std::string &str)
const std::string & getName() const
Return the name of the property.
PersistentObject * getObject() const
float getFloat() const
Type getType() const
Return the type of the data stored in the property object.
bool getBool() const
boost::shared_ptr< PersistentObject > getSmartObject() const
virtual void persistentWrite(PersistenceManager &pm, const char *name="") const
NamedProperty(const std::string &name)
Size countProperties() const
void setProperty(const std::string &name)
BALL_INLINE PropertyManager(const PropertyManager &property_manager)
Copy constructor.
bool hasProperty(Property property) const
Query for an unnamed property.
void setProperty(const std::string &name, double value)
void toggleProperty(Property property)
const NamedProperty & getProperty(const std::string &name) const
bool isValid() const
void clearProperty(Property property)
bool hasProperty(const std::string &name) const
Query for a named property.
void dump(std::ostream &s=std::cout, Size depth=0) const
void setProperty(const std::string &name, bool value)
virtual ~PropertyManager()
Destructor.
void get(PropertyManager &property_manager) const
NamedPropertyIterator endNamedProperty()
Size countNamedProperties() const
void setProperty(const std::string &name, unsigned int value)
void setProperty(Property property)
const BitVector & getBitVector() const
void setProperty(const std::string &name, const PersistentObject &value)
BitVector & getBitVector()
void write(PersistenceManager &pm) const
Persistent stream writing.
virtual void destroy()
Clears all properties.
virtual void clear()
Clears all properties.
NamedPropertyIterator beginNamedProperty()
void set(const PropertyManager &property_manager)
void setProperty(const std::string &name, float value)
BALL_INLINE PropertyManager()
Default constructor.
bool read(PersistenceManager &pm)
Persistent stream reading.
void swap(PropertyManager &property_manager)
void clearProperty(const std::string &name)
NamedProperty & getNamedProperty(Position index)
void setProperty(const NamedProperty &property)
const NamedProperty & getNamedProperty(Position index) const
void setProperty(const std::string &name, int value)
void setProperty(const std::string &name, const std::string &value)
#define BALL_EXPORT
Definition: COMMON/global.h:50