Descriptor< T > Class Template Reference

#include <descriptor.h>

List of all members.

Public Member Functions

Descriptor construction functions
 Descriptor ()
 Descriptor (T avalue)
 Descriptor (string aLabel, T aValue, string aUnit, string aComment)
Accessor functions
void setValue (T)
void setLabel (string aLabel)
void setUnit (string aUnit)
void setComment (string aComment)
void setEmpty ()
T getValue (bool silentError=false) throw ( CError )
string getLabel ()
string getUnit ()
string getComment ()
bool isEmpty ()
Output functions
string toString ()
string toStringShort ()
void describe ()
void describeShort ()

Private Attributes

string label
T value
string unit
string comment
bool empty


Detailed Description

template<class T>
class Descriptor< T >

Template class for storing scientific values
Author:
Dr Jean-Luc Perret (luc@kuicr.kyoto-u.ac.jp), Kyoto University, Japan
Version:
0.3
Date:
17 Jan 2004
CLASS NAME: Descriptor

FOR: SNSF SPONSORED PROJECT

PURPOSE: Storage type for a general scientific descriptor with label, value, unit and comment

This template class implements the storage of a general scientific measurment It not only stores a value with its label, but also the units used, and a comment.

the label, unit and comment are all strings. The value however can be of any type since its type is a tamplate T. Creating a new descriptor can be done in that way:

(in this example we are interested in a descriptor for body temperature and we initialize its value to 37.5)

Descriptor<float> myDescriptor = new Descriptor<float>("temperature", 37.5, "degrees C", "body temperature");

If we don't want the descriptor to contain any value we can give it any value and call the setEmpty() function. After that any call to getValue() will throw an exception, until a value is assigned with setValue(T)

Descriptors of type int, float and string are used by the DataContainer class.


Constructor & Destructor Documentation

template<class T>
Descriptor< T >::Descriptor (   ) 
 

class constructor.

template<class T>
Descriptor< T >::Descriptor (  T  avalue  ) 
 

class constructor.

template<class T>
Descriptor< T >::Descriptor (  string  aLabel,
T  aValue,
string  aUnit,
string  aComment
) 
 

class constructor.


Member Function Documentation

template<class T>
void Descriptor< T >::describe (   ) 
 

prints a description of the descriptor to cout.

template<class T>
void Descriptor< T >::describeShort (   ) 
 

prints a description of the descriptor to cout omiting the comment.

template<class T>
string Descriptor< T >::getComment (   )  [inline]
 

returns the comment string.

template<class T>
string Descriptor< T >::getLabel (   )  [inline]
 

returns the label string.

template<class T>
string Descriptor< T >::getUnit (   )  [inline]
 

returns the unit string.

template<class T>
T Descriptor< T >::getValue (  bool  silentError = false  )  throw ( CError )
 

returns the value. Throws a CError exception if the descriptor has been setEmpty().

template<class T>
bool Descriptor< T >::isEmpty (   )  [inline]
 

returns true is the value was not set, false otherwise.

template<class T>
void Descriptor< T >::setComment (  string  aComment  )  [inline]
 

sets the comment of the descriptor.

template<class T>
void Descriptor< T >::setEmpty (   )  [inline]
 

empties the value of the Descriptor. isEmpty() function will then return true.

template<class T>
void Descriptor< T >::setLabel (  string  aLabel  )  [inline]
 

sets the label of the descriptor.

template<class T>
void Descriptor< T >::setUnit (  string  aUnit  )  [inline]
 

sets the unit of the descriptor.

template<class T>
void Descriptor< T >::setValue (  T   ) 
 

sets the value of the descriptor.

template<class T>
string Descriptor< T >::toString (   ) 
 

returns a string description of the descriptor.

template<class T>
string Descriptor< T >::toStringShort (   ) 
 

returns a string description of the descriptor omiting the comment.


Member Data Documentation

template<class T>
string Descriptor< T >::comment [private]
 

string representing a comment for the descriptor, example: body temperature.

template<class T>
bool Descriptor< T >::empty [private]
 

flag telling if the Descriptor is empty.

template<class T>
string Descriptor< T >::label [private]
 

string representing the descriptor name, example: temperature.

template<class T>
string Descriptor< T >::unit [private]
 

string representing the descriptor unit, example: degree C.

template<class T>
T Descriptor< T >::value [private]
 

variable representing the value of the descriptor, exemple: <float> 37.5.


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