Loading...
Searching...
No Matches
BALL::NamedProperty Class Reference

`#include <BALL/CONCEPT/property.h>`

Inheritance diagram for BALL::NamedProperty:

## Public Types

Enums
enum | Type { BOOL , INT , UNSIGNED_INT , FLOAT , DOUBLE , STRING , OBJECT , NONE , SMART_OBJECT }

## Public Member Functions

Constructors and Destructors
| 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 ()
Persistence
virtual void | persistentWrite (PersistenceManager &pm, const char *name="") const
virtual void | persistentRead (PersistenceManager &pm)
Accessors
Type | getType () const
| Return the type of the data stored in the property object.
const std::string & | getName () const
| Return the name of the property.
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
Public Member Functions inherited from BALL::PersistentObject
| PersistentObject ()
virtual | ~PersistentObject ()
PersistenceManager & | operator>> (PersistenceManager &pm) const
virtual void | finalize ()
Public Member Functions inherited from BALL::Object
| Object ()
| Default constructor.
| Object (const Object &object)
| Copy constructor.
virtual | ~Object ()
| Destructor.
const Object & | operator= (const Object &)
bool | operator== (const Object &object) const
bool | operator!= (const Object &object) const
bool | operator< (const Object &object) const
bool | operator<= (const Object &object) const
bool | operator>= (const Object &object) const
bool | operator> (const Object &object) const
int | compare (const Object &object) const
virtual bool | isValid () const
virtual void | dump (::std::ostream &s=std::cout, Size depth=0) const
Handle | getHandle () const
Public Member Functions inherited from BALL::AutoDeletable
virtual | ~AutoDeletable ()
void * | operator new (size_t size)
void | operator delete (void *ptr)
void * | operator new (size_t size, void *ptr)
void | operator delete (void *ptr, void *)
bool | isAutoDeletable () const
void | setAutoDeletable (bool enable)

## Predicates

bool | operator== (const NamedProperty &np) const
bool | operator!= (const NamedProperty &np) const
void | operator= (const NamedProperty &np)

## Additional Inherited Members

static Handle | getNextHandle ()
static Handle | getNewHandle ()
static void | clearLastPtr ()
| AutoDeletable ()
| AutoDeletable (const AutoDeletable &auto_deletable, bool deep=false)

## Detailed Description

Named Property Class.

Definition at line 38 of file property.h.

## Member Enumeration Documentation

## Type

enum BALL::NamedProperty::Type

The different types of data a NamedProperty may contain.

Enumerator
BOOL | Bool-type properties can have the value true or false.
INT | Int-type properties contain a variable of type int
UNSIGNED_INT | Unsigned-int-type properties contain a variable of type unsigned int
FLOAT | Float-type properties contain a variable of type double
DOUBLE | Double-type properties contain a variable of type double
STRING | String-type properties contain a pointer to a string. When destructing the property, the string is destructed, too.
OBJECT | Object-type properties contain a pointer to a PersistentObject. Remember to destruct the objects if they are not needed any more! the Destructor of NamedProperty will not delete this object!
NONE | Properties of this type do not contain any data. Use this type to indicate that an object has a certain property. The type can be seen as an extension of the bit properties used in PropertyManager except for the user-defined name.
SMART_OBJECT | Object-type properties contain a smart pointer to a PersistentObject. Here, destruction will autmatically be handled by the smart pointer implementation.

Definition at line 51 of file property.h.

## Constructor & Destructor Documentation

## NamedProperty() [1/12]

BALL::NamedProperty::NamedProperty | ( |  | ) |

## NamedProperty() [2/12]

BALL::NamedProperty::NamedProperty | ( | const std::string & | name | ) |

Standard constructor. Creates an object of type NONE. Use this constructor to create it properties with user defined names. The Type is set to OBJECT .

Parameters

  name | the propertie's name

## NamedProperty() [3/12]

BALL::NamedProperty::NamedProperty | ( | const std::string & | name,
|  | bool | value )

Constructor for bool-type properties. Creates a NamedProperty object containing a boolean value. The Type is set to BOOL .

Parameters

  name | the property's name
  value | the boolean value stored in the property

## NamedProperty() [4/12]

BALL::NamedProperty::NamedProperty | ( | const std::string & | name,
|  | int | value )

Constructor for int-type properties. Creates a NamedProperty object containing a signed int value. The Type is set to INT .

Parameters

  name | the property's name
  value | the int value stored in the property

## NamedProperty() [5/12]

BALL::NamedProperty::NamedProperty | ( | const std::string & | name,
|  | unsigned int | value )

Constructor for unsigned int-type properties. Creates a NamedProperty object containing an unsigned int value. The Type is set to UNSIGNED_INT .

Parameters

  name | the property's name
  value | the int value stored in the property

## NamedProperty() [6/12]

BALL::NamedProperty::NamedProperty | ( | const std::string & | name,
|  | float | value )

Constructor for float-type properties. Creates a NamedProperty object containing a float value. The Type is set to FLOAT .

Parameters

  name | the property's name
  value | the float value stored in the property

## NamedProperty() [7/12]

BALL::NamedProperty::NamedProperty | ( | const std::string & | name,
|  | double | value )

Constructor for double-type properties. Creates a NamedProperty object containing a double value. The Type is set to DOUBLE .

Parameters

  name | the property's name
  value | the double value stored in the property

## NamedProperty() [8/12]

BALL::NamedProperty::NamedProperty | ( | const std::string & | name,
|  | const std::string & | str )

Constructor for string-type properties. Objects of type STRING contain a pointer to a string object. This object is constructed as a copy of str The Type is set to STRING .

Parameters

  name | the property's name
  str | the string stored in the property

## NamedProperty() [9/12]

BALL::NamedProperty::NamedProperty | ( | const std::string & | name,
|  | PersistentObject & | po )

Constructor for object-type properties. Creates a NamedProperty object containing a pointer to a persistent object. The Type is set to OBJECT .

Parameters

  name | the property's name
  po | a reference to the persistent object stored in the property

## NamedProperty() [10/12]

BALL::NamedProperty::NamedProperty | ( | const std::string & | name,
|  | boost::shared_ptr< PersistentObject > & | po )

Constructor for smart-pointer handled object-type properties. Creates a NamedProperty object containing a smart pointer to a persistent object. The Type is set to SMART_OBJECT .

Parameters

  name | the property's name
  ptr | a smart pointer to the persistent object

## NamedProperty() [11/12]

BALL::NamedProperty::NamedProperty | ( | const NamedProperty & |  | ) |

Copy constructor

## NamedProperty() [12/12]

BALL::NamedProperty::NamedProperty | ( | const NamedProperty & | ,
|  | const std::string & | name )

Copy constructor with renaming

## ~NamedProperty()

BALL::NamedProperty::~NamedProperty | ( |  | ) |

Destructor . The destructor destructs the contained data in the case of STRING-type properties only.

## Member Function Documentation

## clear()

virtual void BALL::NamedProperty::clear | ( |  | ) |

virtual

Clear method

Reimplemented from BALL::Object.

## getBool()

bool BALL::NamedProperty::getBool | ( |  | ) | const

Return the data of the property object as bool. If the property object is not of BOOL type, false is returned.

## getDouble()

double BALL::NamedProperty::getDouble | ( |  | ) | const

Return the data of the property object as double. If the property object is not of DOUBLE type, 0.0 is returned.

## getFloat()

float BALL::NamedProperty::getFloat | ( |  | ) | const

Return the data of the property object as float. If the property object is not of FLOAT type, 0.0 is returned.

## getInt()

int BALL::NamedProperty::getInt | ( |  | ) | const

Return the data of the property object as int. If the property object is not of INT type, 0 is returned.

## getName()

const std::string & BALL::NamedProperty::getName | ( |  | ) | const

Return the name of the property.

## getObject()

PersistentObject * BALL::NamedProperty::getObject | ( |  | ) | const

Return the data of the property object as a pointer to a PersistentObject. If the property object is not of OBJECT type, 0 is returned.

## getSmartObject()

boost::shared_ptr< PersistentObject > BALL::NamedProperty::getSmartObject | ( |  | ) | const

Return the data of the property object as a smart pointer to a PersistentObject. If the property object is not of SMART_OBJECT type, 0 is returned.

## getString()

String BALL::NamedProperty::getString | ( |  | ) | const

Return the data of the property object as a string. If the property object is not of STRING type, "" is returned.

## getType()

Type BALL::NamedProperty::getType | ( |  | ) | const

Return the type of the data stored in the property object.

## getUnsignedInt()

unsigned int BALL::NamedProperty::getUnsignedInt | ( |  | ) | const

Return the data of the property object as unsigned int. If the property object is not of UNSIGNED_INT type, 0 is returned.

## operator!=()

bool BALL::NamedProperty::operator!= | ( | const NamedProperty & | np | ) | const

Inequality operator

See also
  operator ==

## operator=()

void BALL::NamedProperty::operator= | ( | const NamedProperty & | np | ) |

copy operator

## operator==()

bool BALL::NamedProperty::operator== | ( | const NamedProperty & | np | ) | const

Equality operator Two instances are equal if they have the same name and the same value.

## persistentRead()

virtual void BALL::NamedProperty::persistentRead | ( | PersistenceManager & | pm | ) |

virtual

Retrieve a persistent copy of the object

Exceptions

  Exception::GeneralException |

Reimplemented from BALL::PersistentObject.

## persistentWrite()

virtual void BALL::NamedProperty::persistentWrite | ( | PersistenceManager & | pm,
|  | const char * | name = "" ) const

virtual

Write a persistent copy of the object.

Exceptions

  Exception::GeneralException |

Reimplemented from BALL::PersistentObject.

## toString()

String BALL::NamedProperty::toString | ( |  | ) | const

Converts the data contained in this NamedProperty to a string and returns it.
Note that this function is intended as a convenience and does NOT depend on the type of the data (in constrast to getString()).