DataContainer Class Reference

#include <datacontainer.h>

Inheritance diagram for DataContainer:

Elements Molecule Node KCFMolecule Atom List of all members.

Public Member Functions

DataContainer construction functions
 DataContainer ()
 DataContainer (DataContainer &aDataContainer)
virtual ~DataContainer ()
Accessor functions
bool hasStringDescriptor (string aLabel)
bool hasFloatDescriptor (string aLabel)
bool hasIntDescriptor (string aLabel)
DataContainer manipulation functions
Descriptor< int > * addKindIntDescriptor (string aLabel, int aValue, string aUnit, string aComment)
Descriptor< int > * addKindIntDescriptor (Descriptor< int > *aDescriptor)
Descriptor< float > * addKindFloatDescriptor (string aLabel, float aValue, string aUnit, string aComment)
Descriptor< float > * addKindFloatDescriptor (Descriptor< float > *aDescriptor)
Descriptor< string > * addKindStringDescriptor (string aLabel, string aValue, string aUnit, string aComment)
Descriptor< string > * addKindStringDescriptor (Descriptor< string > *aDescriptor)
Descriptor< int > * addIntDescriptor (string aLabel, int aValue, string aUnit, string aComment)
Descriptor< float > * addFloatDescriptor (string aLabel, float aValue, string aUnit, string aComment)
Descriptor< string > * addStringDescriptor (string aLabel, string aValue, string aUnit, string aComment)
Descriptor< int > * setIntDescriptor (string aLabel, int aValue, string aUnit, string aComment, bool addIfMissing, bool silentError)
Descriptor< float > * setFloatDescriptor (string aLabel, float aValue, string aUnit, string aComment, bool addIfMissing, bool silentError)
Descriptor< string > * setStringDescriptor (string aLabel, string aValue, string aUnit, string aComment, bool addIfMissing, bool silentError)
Descriptor< int > * getIntDescriptor (string aLabel, bool silentError=true) throw ( CError )
long getPossibleValuesInIntDescriptor (string aDescriptorName, vector< int > *)
Descriptor< float > * getFloatDescriptor (string aLabel, bool silentError=true) throw ( CError )
Descriptor< string > * getStringDescriptor (string aLabel, bool silentError=true) throw ( CError )
virtual bool deleteDescriptor (string aString, bool found=false)
void deleteAllDescriptors ()
void addUnknownTypeDescriptor (string aName, string aValue)
Iterators
map< string, Descriptor< int
> * >::iterator 
beginIntDescriptor ()
map< string, Descriptor< int
> * >::iterator 
endIntDescriptor ()
map< string, Descriptor< float
> * >::iterator 
beginFloatDescriptor ()
map< string, Descriptor< float
> * >::iterator 
endFloatDescriptor ()
map< string, Descriptor< string
> * >::iterator 
beginStringDescriptor ()
map< string, Descriptor< string
> * >::iterator 
endStringDescriptor ()
Output functions
void describe () throw ( CError )
void describeShort () throw ( CError )

Protected Member Functions

void deleteAllKindDescriptors ()

Protected Attributes

bool flagElement
map< string, Descriptor< int > * > intDescriptors
map< string, Descriptor< float > * > floatDescriptors
map< string, Descriptor< string > * > stringDescriptors
map< string, Descriptor< int > * > * kindIntDescriptors
map< string, Descriptor< float > * > * kindFloatDescriptors
map< string, Descriptor< string > * > * kindStringDescriptors

Detailed Description

Container for scientific values of type int, float and string
Author:
Dr Jean-Luc Perret (luc@kuicr.kyoto-u.ac.jp), Kyoto University, Japan
Version:
0.1
Date:
8 Jan 2004
CLASS NAME: DataContainer

FOR: SNSF SPONSORED PROJECT

PURPOSE: Base Class implementing a collection of Descriptors and a collection of kind Descriptors ( of types int, float, and string )

DataContainer is a base class to be used to derive classs representing concepts which need to be described with real values (properties)

We distinguish two kind of properties: unique descriptors and kind descriptors. Unique descriptors are properties whose values are unique to an instance of the concept. Kind descriptors are properties whose values are shared among a group of concept instances.

For example the class Atom is derived from DataContainer. Atoms have unique descriptors like a name, a start and stop probability. On the other hand atoms have many kind descriptors which are shared among atoms belonging to the same chemical element. The atomic number of all hydrogens is the same, but is different for carbons. Kind descriptors allow for this.

Kind desriptors are stored only once in memory and are then referenced by all class instances of the same kind can therefore be added at any time but should be removed with caution since many class instances may point to it. In chemcpp generic instances of Atoms are instanciated globally in the elements.h file by creation of an Elements instance and stored in the elements map. Kind descriptors are created at that time and will only be deleted with the deletion of the unique instance of Elements.

Memory allocation for unique descriptors on the other hand can be managed by the DataContainer class itself since only one instance of the derived class points to them. So deletion of the DataContainer causes the deletion of the descriptors.

Warning:
unique descriptors should not be referenced by something else than this container class.


Constructor & Destructor Documentation

DataContainer::DataContainer  ) 
 

class constructor.

DataContainer::DataContainer DataContainer aDataContainer  ) 
 

class constructor.

virtual DataContainer::~DataContainer  )  [virtual]
 

(virtual) class desctructor.


Member Function Documentation

Descriptor< float >* DataContainer::addFloatDescriptor string  aLabel,
float  aValue,
string  aUnit,
string  aComment
 

adds a float unique descriptor with a label, value, unit and comment. this descriptor will be deleted with the destruction of this class.

Examples:
atom_example.cpp.

Descriptor< int >* DataContainer::addIntDescriptor string  aLabel,
int  aValue,
string  aUnit,
string  aComment
 

adds an integer unique descriptor with a label, value, unit and comment. this descriptor will be deleted with the destruction of this class.

Descriptor< float >* DataContainer::addKindFloatDescriptor Descriptor< float > *  aDescriptor  ) 
 

adds an existing float descriptor to the float kind descriptor container. WARNING this descriptor will be deleted with the destruction of the Elements class.

Descriptor< float >* DataContainer::addKindFloatDescriptor string  aLabel,
float  aValue,
string  aUnit,
string  aComment
 

adds an float kind descriptor with a label, value, unit and comment to the float kind descriptor container. WARNING this descriptor will be deleted with the destruction of the Elements class.

Descriptor< int >* DataContainer::addKindIntDescriptor Descriptor< int > *  aDescriptor  ) 
 

adds an existing int descriptor to the int kind descriptor container. WARNING this descriptor will be deleted with the destruction of the Elements class.

Descriptor< int >* DataContainer::addKindIntDescriptor string  aLabel,
int  aValue,
string  aUnit,
string  aComment
 

adds an integer kind descriptor with a label, value, unit and comment to the int kind descriptor container. WARNING this descriptor will be deleted with the destruction of the Elements class.

Descriptor< string >* DataContainer::addKindStringDescriptor Descriptor< string > *  aDescriptor  ) 
 

adds an existing string descriptor to the string kind descriptor container. WARNING this descriptor will be deleted with the destruction of the Elements class.

Descriptor< string >* DataContainer::addKindStringDescriptor string  aLabel,
string  aValue,
string  aUnit,
string  aComment
 

adds a string kind descriptor with a label, value, unit and comment to the string kind descriptor container. WARNING this descriptor will be deleted with the destruction of the Elements class.

Descriptor< string >* DataContainer::addStringDescriptor string  aLabel,
string  aValue,
string  aUnit,
string  aComment
 

adds a string unique descriptor with a label, value, unit and comment. this descriptor will be deleted with the destruction of this class.

void DataContainer::addUnknownTypeDescriptor string  aName,
string  aValue
 

adds a descriptor to the datacontainer. If aName terminates with .string, a string descriptor will be added. If the aName terminates with a .integer, an integer descriptor will be added. If aName terminates with .float, a float descriptor will be added.

map< string, Descriptor< float >* >::iterator DataContainer::beginFloatDescriptor  )  [inline]
 

start iterator for float descriptors.

map< string, Descriptor< int >* >::iterator DataContainer::beginIntDescriptor  )  [inline]
 

start iterator for int descriptors.

map< string, Descriptor< string >* >::iterator DataContainer::beginStringDescriptor  )  [inline]
 

start iterator for string descriptors.

void DataContainer::deleteAllDescriptors  ) 
 

deletes all unique descriptors from ***Descriptors. deletes the objects and removes pointer from the Hash, does not remove kind descriptors.

void DataContainer::deleteAllKindDescriptors  )  [protected]
 

called by the destructor if flagElement == true.

virtual bool DataContainer::deleteDescriptor string  aString,
bool  found = false
[virtual]
 

deletes the unique descriptor aString from Descriptors. deletes the object and removes pointer from the Hash, does not remove kind descriptors.

void DataContainer::describe  )  throw ( CError )
 

writes a description of all labels to cout (unique and kind descriptors).

Reimplemented in Atom, and Molecule.

void DataContainer::describeShort  )  throw ( CError )
 

writes a description of unique descriptors only to cout (no kind descriptors).

Reimplemented in Atom, and Molecule.

map< string, Descriptor< float >* >::iterator DataContainer::endFloatDescriptor  )  [inline]
 

end iterator for float descriptors.

map< string, Descriptor< int >* >::iterator DataContainer::endIntDescriptor  )  [inline]
 

end iterator for int descriptors.

map< string, Descriptor< string >* >::iterator DataContainer::endStringDescriptor  )  [inline]
 

end iterator for string descriptors.

Descriptor< float >* DataContainer::getFloatDescriptor string  aLabel,
bool  silentError = true
throw ( CError )
 

returns a float property (unique or kind descriptor).

Examples:
atom_example.cpp.

Descriptor< int >* DataContainer::getIntDescriptor string  aLabel,
bool  silentError = true
throw ( CError )
 

returns a int property (unique or kind descriptor).

long DataContainer::getPossibleValuesInIntDescriptor string  aDescriptorName,
vector< int > * 
 

fills a vector with the possible values of a int descriptor and returns the number of possible values.

Descriptor< string >* DataContainer::getStringDescriptor string  aLabel,
bool  silentError = true
throw ( CError )
 

returns a string property (unique or kind descriptor).

bool DataContainer::hasFloatDescriptor string  aLabel  ) 
 

returns true if the datacontainer has a float descriptor with label aLabel.

bool DataContainer::hasIntDescriptor string  aLabel  ) 
 

returns true if the datacontainer has an int descriptor with label aLabel.

bool DataContainer::hasStringDescriptor string  aLabel  ) 
 

returns true if the datacontainer has a string descriptor with label aLabel.

Descriptor< float >* DataContainer::setFloatDescriptor string  aLabel,
float  aValue,
string  aUnit,
string  aComment,
bool  addIfMissing,
bool  silentError
 

sets the value of float label (unique or kind descriptor).

Descriptor< int >* DataContainer::setIntDescriptor string  aLabel,
int  aValue,
string  aUnit,
string  aComment,
bool  addIfMissing,
bool  silentError
 

sets the value of an int label (unique or kind descriptor).

Descriptor< string >* DataContainer::setStringDescriptor string  aLabel,
string  aValue,
string  aUnit,
string  aComment,
bool  addIfMissing,
bool  silentError
 

sets the value of a string label (unique or kind descriptor).


Member Data Documentation

bool DataContainer::flagElement [protected]
 

false if this datacontainer was constructed by copy of an existingdatacontainer. Useful for destruction.

map< string, Descriptor< float >* > DataContainer::floatDescriptors [protected]
 

hash of pointers on Float descriptors.

map< string, Descriptor< int >* > DataContainer::intDescriptors [protected]
 

hash of pointers on Integer descriptors.

map< string, Descriptor< float >* >* DataContainer::kindFloatDescriptors [protected]
 

hash of pointers on Float kind descriptors.

map< string, Descriptor< int >* >* DataContainer::kindIntDescriptors [protected]
 

hash of pointers on Integer kind descriptors.

map< string, Descriptor< string >* >* DataContainer::kindStringDescriptors [protected]
 

hash of pointers on String kind descriptors.

map< string, Descriptor< string >* > DataContainer::stringDescriptors [protected]
 

hash of pointers on String descriptors.


The documentation for this class was generated from the following file:
Generated on Wed Nov 28 12:12:51 2007 for ChemCpp by  doxygen 1.4.6