Calculator< Tag > Class Template Reference

Primary template class for Calculator's specializations. More...

#include "keyvalue/mngt/Calculator.h"

Inheritance diagram for Calculator< Tag >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

const char * getName () const
 Gets Calculator's name.
value::Result getResult (const DataSet &data) const
 Gets result of processing a DataSet.
value::Result getResult (const value::Variant &data) const
 Gets result of processing a value::Variant.
virtual value::Value getValue (const DataSet &data) const
 Gets the result of processing a DataSet.
virtual value::Value getValue (const value::Variant &data) const
 Gets the result of processing a value::Variant.

Static Public Member Functions

static CalculatorgetInstance ()
 Gets the unique instance of a Calculator specialization.

Static Protected Member Functions

static void setGetter (Calculator &(*getter)())
 Sets the point of acess to the unique instance of a Calculator specialization.

Static Private Member Functions

static CalculatorgetSingleton ()
 Gets the unique instance of a Calculator specialization.

Static Private Attributes

static Calculator &(* getter_ )()

Detailed Description

template<typename Tag>
class keyvalue::Calculator< Tag >

Primary template class for Calculator's specializations.

Each calculator computes a value based on the information stored in a DataSet. In practice, a calculator is a specialization of this template class which is parametrized on the type of computation performed.

Some methods are declared here but not implemented. Clients must implement missing methods in each specialization.

Parameters:
Tag : Identifier used to distingush between different Calculators.

Member Function Documentation

Calculator< Tag > & getInstance (  )  [inline, static]

Gets the unique instance of a Calculator specialization.

For each type of computation there should be only one instance of a Calculator specialization. Therefore, each Calculator specialization is a singleton and this method provides a global point of access to it.

return A reference to the unique instance of a Calculator specialization.

Reimplemented in XCalculator< Tag >.

const char* getName (  )  const [virtual]

Gets Calculator's name.

Implementation must be provided by specializations. (For an example see keyvalue/bridge/processor/DataSetNames.cpp.)

Returns:
The name.

Implements Processor.

value::Result getResult ( const DataSet data  )  const [inline, virtual]

Gets result of processing a DataSet.

A redirection to getValue(const DataSet& data).

Parameters:
data : DataSet to be processed.
Returns:
The result.

Implements Processor.

value::Result getResult ( const value::Variant data  )  const [inline, virtual]

Gets result of processing a value::Variant.

A redirection to getValue(const value::Variant& data).

Parameters:
data : value::Variant to be processed.
Returns:
The result.

Implements Processor.

virtual value::Value getValue ( const DataSet data  )  const [virtual]

Gets the result of processing a DataSet.

Implementation must be provided by specializations. (For an example see keyvalue/bridge/processor/DataSetNames.cpp.)

Parameters:
data : Input DataSet.
Returns:
The calculated value.
value::Value getValue ( const value::Variant data  )  const [inline, virtual]

Gets the result of processing a value::Variant.

The implementation provided here throws an exception to indicate that a Calculator specialization cannot constructs the object given just a value::Variant input. Use XCalculator to make it possible.

Parameters:
data : Input value::Variant.
Returns:
The calculated value.

Reimplemented in XCalculator< Tag >.

void setGetter ( Calculator< Tag > &(*)()  getter  )  [inline, static, protected]

Sets the point of acess to the unique instance of a Calculator specialization.

Each specialization of this template class must be a singleton and the getInstance() method above gives acess to this unique instance.

However, trough public inheritance, a Buider specialization can be extended to an XCalculator one. In this case, the unique accesible instance of a Calculator specialization must be an instance of an XCalculator specialization. Therefore, each XCalculator specialization must register itself as the provider of the unique instance of the Calculator specialization which is returned by getInstance().

The registration is done by calling this method and providing a global point of access to the unique instance of the Calculator specialization.

Parameters:
: A pointer to a funtion which returns a reference to the unique instance of a Calculator specialization.
Calculator< Tag > & getSingleton (  )  [inline, static, private]

Gets the unique instance of a Calculator specialization.

By default, the global point of acess to the unique instace of a Calculator specialization is this method. To change it one must use setGetter().

return A reference to the unique instance of a Calculator specialization.

Reimplemented in XCalculator< Tag >.


Generated on Sat Mar 20 15:08:30 2010 for KeyValue by  doxygen 1.6.1