Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

NamedProperty Class Reference
[Miscellaneous]

Named Property Class. More...

#include <property.h>

Inheritance diagram for NamedProperty:

PersistentObject Object AutoDeletable List of all members.

Public Types

Enums
enum  Type {
  BOOL, INT, UNSIGNED_INT, FLOAT,
  DOUBLE, STRING, OBJECT, NONE
}
 The different types of data a NamedProperty may contain. More...

Public Member Functions

Constructors and Destructors
 NamedProperty (const string &name) throw ()
 Standard constructor.
 NamedProperty (const string &name, bool value) throw ()
 Constructor for bool-type properties.
 NamedProperty (const string &name, int value) throw ()
 Constructor for int-type properties.
 NamedProperty (const string &name, unsigned int value) throw ()
 Constructor for unsigned int-type properties.
 NamedProperty (const string &name, float value) throw ()
 Constructor for float-type properties.
 NamedProperty (const string &name, double value) throw ()
 Constructor for double-type properties.
 NamedProperty (const string &name, const string &str) throw ()
 Constructor for string-type properties.
 NamedProperty (const string &name, PersistentObject &po) throw ()
 Constructor for object-type properties.
 NamedProperty (const NamedProperty &) throw ()
 Copy constructor.
 ~NamedProperty () throw ()
 Destructor .
virtual void clear () throw ()
 Clear method.
Persistence
virtual void persistentWrite (PersistenceManager &pm, const char *name="") const throw (Exception::GeneralException)
 Write a persistent copy of the object.
virtual void persistentRead (PersistenceManager &pm) throw (Exception::GeneralException)
 Retrieve a persistent copy of the object.
Accessors
Type getType () const throw ()
 Return the type of the data stored in the property object.
string getName () const throw ()
 Return the name of the property.
bool getBool () const throw ()
 Return the data of the property object as bool.
int getInt () const throw ()
 Return the data of the property object as int.
float getFloat () const throw ()
 Return the data of the property object as float.
double getDouble () const throw ()
 Return the data of the property object as double.
unsigned int getUnsignedInt () const throw ()
 Return the data of the property object as unsigned int.
PersistentObjectgetObject () const throw ()
 Return the data of the property object as a pointer to a PersistentObject.
string getString () const throw ()
 Return the data of the property object as a string.
Predicates
bool operator== (const NamedProperty &np) const throw ()
 Equality operator Two instances are equal if they have the same name and the same value.
bool operator!= (const NamedProperty &np) const throw ()
 Inequality operator.

Detailed Description

Named Property Class.


Member Enumeration Documentation

enum NamedProperty::Type
 

The different types of data a NamedProperty may contain.

Enumeration values:
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.


Constructor & Destructor Documentation

NamedProperty::NamedProperty const string &  name  )  throw ()
 

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::NamedProperty const string &  name,
bool  value
throw ()
 

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::NamedProperty const string &  name,
int  value
throw ()
 

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::NamedProperty const string &  name,
unsigned int  value
throw ()
 

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::NamedProperty const string &  name,
float  value
throw ()
 

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::NamedProperty const string &  name,
double  value
throw ()
 

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::NamedProperty const string &  name,
const string &  str
throw ()
 

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::NamedProperty const string &  name,
PersistentObject po
throw ()
 

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::~NamedProperty  )  throw ()
 

Destructor .

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


Member Function Documentation

bool NamedProperty::getBool  )  const throw ()
 

Return the data of the property object as bool.

If the property object is not of BOOL type, false is returned.

double NamedProperty::getDouble  )  const throw ()
 

Return the data of the property object as double.

If the property object is not of DOUBLE type, 0.0 is returned.

float NamedProperty::getFloat  )  const throw ()
 

Return the data of the property object as float.

If the property object is not of FLOAT type, 0.0 is returned.

int NamedProperty::getInt  )  const throw ()
 

Return the data of the property object as int.

If the property object is not of INT type, 0 is returned.

PersistentObject* NamedProperty::getObject  )  const throw ()
 

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.

string NamedProperty::getString  )  const throw ()
 

Return the data of the property object as a string.

If the property object is not of STRING type, "" is returned.

unsigned int NamedProperty::getUnsignedInt  )  const throw ()
 

Return the data of the property object as unsigned int.

If the property object is not of UNSIGNED_INT type, 0 is returned.

bool NamedProperty::operator!= const NamedProperty np  )  const throw ()
 

Inequality operator.

See also:
operator ==

bool NamedProperty::operator== const NamedProperty np  )  const throw ()
 

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

virtual void NamedProperty::persistentWrite PersistenceManager pm,
const char *  name = ""
const throw (Exception::GeneralException) [virtual]
 

Write a persistent copy of the object.

Reimplemented from PersistentObject.