Loading...
Searching...
No Matches
property.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: property.h,v 1.40 2005/12/23 17:01:41 amoll Exp $
//
#ifndef BALL_CONCEPT_PROPERTY_H
#define BALL_CONCEPT_PROPERTY_H
#ifndef BALL_COMMON_H
# include <BALL/common.h>
#endif
#ifndef BALL_DATATYPE_BITVECTOR_H
# include <BALL/DATATYPE/bitVector.h>
#endif
#ifndef BALL_CONCEPT_PERSISTENTOBJECT_H
# include <BALL/CONCEPT/persistentObject.h>
#endif
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/any.hpp>
namespace BALL
{
class BALL_EXPORT NamedProperty
: public PersistentObject
{
public:
BALL_CREATE(NamedProperty)
enum Type
{
BOOL,
INT,
UNSIGNED_INT,
FLOAT,
DOUBLE,
STRING,
OBJECT,
NONE,
SMART_OBJECT
};
/* The default constructor
*/
NamedProperty();
NamedProperty(const std::string& name);
NamedProperty(const std::string& name, bool value);
NamedProperty(const std::string& name, int value);
NamedProperty(const std::string& name, unsigned int value);
NamedProperty(const std::string& name, float value);
NamedProperty(const std::string& name, double value);
NamedProperty(const std::string& name, const std::string& str);
NamedProperty(const std::string& name, PersistentObject& po);
NamedProperty(const std::string& name, boost::shared_ptr<PersistentObject>& po);
NamedProperty(const NamedProperty&);
NamedProperty(const NamedProperty&, const std::string& name);
~NamedProperty();
virtual void clear();
virtual void persistentWrite(PersistenceManager& pm, const char* name = "") const;
virtual void persistentRead(PersistenceManager& pm);
Type getType() const;
const std::string& getName() const;
bool getBool() const;
int getInt() const;
float getFloat() const;
double getDouble() const;
unsigned int getUnsignedInt() const;
PersistentObject* getObject() const;
boost::shared_ptr<PersistentObject> getSmartObject() const;
String getString() const;
String toString() const;
bool operator == (const NamedProperty& np) const;
bool operator != (const NamedProperty& np) const;
void operator = (const NamedProperty& np);
private:
/*_ The kind of information contained in the NamedProperty
*/
Type type_;
/*_ The name of the property object
*/
std::string name_;
/*_ The data
*/
boost::any data_;
};
typedef std::vector<NamedProperty>::iterator NamedPropertyIterator;
class BALL_EXPORT PropertyManager
{
public:
BALL_CREATE(PropertyManager)
BALL_INLINE
PropertyManager();
BALL_INLINE
PropertyManager(const PropertyManager& property_manager);
virtual ~PropertyManager();
virtual void clear();
virtual void destroy();
void set(const PropertyManager& property_manager);
const PropertyManager& operator = (const PropertyManager& property_manager);
void get(PropertyManager& property_manager) const;
void swap(PropertyManager& property_manager);
BitVector& getBitVector();
const BitVector& getBitVector() const;
operator BitVector& ();
void setProperty(Property property);
void clearProperty(Property property);
void toggleProperty(Property property);
Size countProperties() const;
const NamedProperty& getNamedProperty(Position index) const;
NamedProperty& getNamedProperty(Position index);
void setProperty(const NamedProperty& property);
void setProperty(const std::string& name);
void setProperty(const std::string& name, bool value);
void setProperty(const std::string& name, int value);
void setProperty(const std::string& name, unsigned int value);
void setProperty(const std::string& name, float value);
void setProperty(const std::string& name, double value);
void setProperty(const std::string& name, const std::string& value);
void setProperty(const std::string& name, const PersistentObject& value);
const NamedProperty& getProperty(const std::string& name) const;
NamedPropertyIterator beginNamedProperty();
NamedPropertyIterator endNamedProperty();
void clearProperty(const std::string& name);
Size countNamedProperties() const;
bool hasProperty(Property property) const;
bool hasProperty(const std::string& name) const;
bool operator == (const PropertyManager& pm) const;
bool operator != (const PropertyManager& pm) const;
void write(PersistenceManager& pm) const;
bool read(PersistenceManager& pm);
bool isValid() const;
void dump(std::ostream& s = std::cout, Size depth = 0) const;
private:
BitVector bitvector_;
std::vector<NamedProperty> named_properties_;
};
# ifndef BALL_NO_INLINE_FUNCTIONS
# include <BALL/CONCEPT/property.iC>
# endif
} // namespace BALL
#endif // BALL_CONCEPT_PROPERTY_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
bitVector.h
BALL::BitVector
Definition bitVector.h:177
BALL::NamedProperty
Definition property.h:40
BALL::NamedProperty::NamedProperty
NamedProperty(const NamedProperty &, const std::string &name)
BALL::NamedProperty::NamedProperty
NamedProperty(const std::string &name, boost::shared_ptr< PersistentObject > &po)
BALL::NamedProperty::NamedProperty
NamedProperty(const std::string &name, PersistentObject &po)
BALL::NamedProperty::NamedProperty
NamedProperty(const std::string &name, unsigned int value)
BALL::NamedProperty::getUnsignedInt
unsigned int getUnsignedInt() const
BALL::NamedProperty::NamedProperty
NamedProperty(const NamedProperty &)
BALL::NamedProperty::NamedProperty
NamedProperty(const std::string &name, double value)
BALL::NamedProperty::getInt
int getInt() const
BALL::NamedProperty::NamedProperty
NamedProperty(const std::string &name, bool value)
BALL::NamedProperty::NamedProperty
NamedProperty(const std::string &name, float value)
BALL::NamedProperty::getDouble
double getDouble() const
BALL::NamedProperty::getString
String getString() const
BALL::NamedProperty::Type
Type
Definition property.h:52
BALL::NamedProperty::INT
@ INT
Definition property.h:60
BALL::NamedProperty::NONE
@ NONE
Definition property.h:91
BALL::NamedProperty::FLOAT
@ FLOAT
Definition property.h:69
BALL::NamedProperty::UNSIGNED_INT
@ UNSIGNED_INT
Definition property.h:65
BALL::NamedProperty::DOUBLE
@ DOUBLE
Definition property.h:73
BALL::NamedProperty::SMART_OBJECT
@ SMART_OBJECT
Definition property.h:97
BALL::NamedProperty::OBJECT
@ OBJECT
Definition property.h:84
BALL::NamedProperty::BOOL
@ BOOL
Definition property.h:56
BALL::NamedProperty::STRING
@ STRING
Definition property.h:78
BALL::NamedProperty::persistentRead
virtual void persistentRead(PersistenceManager &pm)
BALL::NamedProperty::toString
String toString() const
BALL::NamedProperty::~NamedProperty
~NamedProperty()
BALL::NamedProperty::NamedProperty
NamedProperty(const std::string &name, int value)
BALL::NamedProperty::clear
virtual void clear()
BALL::NamedProperty::NamedProperty
NamedProperty(const std::string &name, const std::string &str)
BALL::NamedProperty::getName
const std::string & getName() const
Return the name of the property.
BALL::NamedProperty::getObject
PersistentObject * getObject() const
BALL::NamedProperty::getFloat
float getFloat() const
BALL::NamedProperty::NamedProperty
NamedProperty()
BALL::NamedProperty::getType
Type getType() const
Return the type of the data stored in the property object.
BALL::NamedProperty::getBool
bool getBool() const
BALL::NamedProperty::getSmartObject
boost::shared_ptr< PersistentObject > getSmartObject() const
BALL::NamedProperty::persistentWrite
virtual void persistentWrite(PersistenceManager &pm, const char *name="") const
BALL::NamedProperty::NamedProperty
NamedProperty(const std::string &name)
BALL::PersistenceManager
Definition persistenceManager.h:73
BALL::PersistentObject
Definition persistentObject.h:29
BALL::PersistentObject::PersistentObject
PersistentObject()
Definition persistentObject.h:39
BALL::PropertyManager::countProperties
Size countProperties() const
BALL::PropertyManager::setProperty
void setProperty(const std::string &name)
BALL::PropertyManager::PropertyManager
BALL_INLINE PropertyManager(const PropertyManager &property_manager)
Copy constructor.
BALL::PropertyManager::hasProperty
bool hasProperty(Property property) const
Query for an unnamed property.
BALL::PropertyManager::setProperty
void setProperty(const std::string &name, double value)
BALL::PropertyManager::toggleProperty
void toggleProperty(Property property)
BALL::PropertyManager::getProperty
const NamedProperty & getProperty(const std::string &name) const
BALL::PropertyManager::isValid
bool isValid() const
BALL::PropertyManager::clearProperty
void clearProperty(Property property)
BALL::PropertyManager::hasProperty
bool hasProperty(const std::string &name) const
Query for a named property.
BALL::PropertyManager::dump
void dump(std::ostream &s=std::cout, Size depth=0) const
BALL::PropertyManager::setProperty
void setProperty(const std::string &name, bool value)
BALL::PropertyManager::~PropertyManager
virtual ~PropertyManager()
Destructor.
BALL::PropertyManager::get
void get(PropertyManager &property_manager) const
BALL::PropertyManager::endNamedProperty
NamedPropertyIterator endNamedProperty()
BALL::PropertyManager::countNamedProperties
Size countNamedProperties() const
BALL::PropertyManager::setProperty
void setProperty(const std::string &name, unsigned int value)
BALL::PropertyManager::setProperty
void setProperty(Property property)
BALL::PropertyManager::getBitVector
const BitVector & getBitVector() const
BALL::PropertyManager::setProperty
void setProperty(const std::string &name, const PersistentObject &value)
BALL::PropertyManager::getBitVector
BitVector & getBitVector()
BALL::PropertyManager::write
void write(PersistenceManager &pm) const
Persistent stream writing.
BALL::PropertyManager::destroy
virtual void destroy()
Clears all properties.
BALL::PropertyManager::clear
virtual void clear()
Clears all properties.
BALL::PropertyManager::beginNamedProperty
NamedPropertyIterator beginNamedProperty()
BALL::PropertyManager::set
void set(const PropertyManager &property_manager)
BALL::PropertyManager::setProperty
void setProperty(const std::string &name, float value)
BALL::PropertyManager::PropertyManager
BALL_INLINE PropertyManager()
Default constructor.
BALL::PropertyManager::read
bool read(PersistenceManager &pm)
Persistent stream reading.
BALL::PropertyManager::swap
void swap(PropertyManager &property_manager)
BALL::PropertyManager::clearProperty
void clearProperty(const std::string &name)
BALL::PropertyManager::getNamedProperty
NamedProperty & getNamedProperty(Position index)
BALL::PropertyManager::setProperty
void setProperty(const NamedProperty &property)
BALL::PropertyManager::getNamedProperty
const NamedProperty & getNamedProperty(Position index) const
BALL::PropertyManager::setProperty
void setProperty(const std::string &name, int value)
BALL::PropertyManager::setProperty
void setProperty(const std::string &name, const std::string &value)
BALL::String
Definition string.h:57
common.h
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
BALL_INLINE
#define BALL_INLINE
Definition debug.h:15
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Property
BALL_SIZE_TYPE Property
Definition COMMON/global.h:165
BALL::Position
BALL_SIZE_TYPE Position
Definition COMMON/global.h:140
BALL::NamedPropertyIterator
std::vector< NamedProperty >::iterator NamedPropertyIterator
Definition property.h:317
persistentObject.h