StdSingle< ElementType > Class Template Reference

Converter from value::Single to ElementType. More...

#include "keyvalue/key/converter/StdSingle.h"

List of all members.

Public Types

typedef value::Single InputType_
 Compulsory member.
typedef ElementType OutputType_
 Compulsory member.

Public Member Functions

 StdSingle (const InputType_ &input, OutputType_ *cache)
 Compulsory constructor.
bool isEmpty () const
 Compulsory member: Checks if conversion has finished.
value::Variant pop ()
 Compulsory member: Gets next input element.
void insert (const ElementType &element)
 Compulsory member: Inserts a new element into the output container.
OutputType_ getOutput () const
 Compulsory member: Gets output container.
bool mustUpdate () const
 Compulsory member: Informs if cached value is up to date.

Private Attributes

const InputType_input_
OutputType_ *const cache_
OutputType_ output_
bool empty_
bool mustUpdate_

Detailed Description

template<typename ElementType>
class keyvalue::key::StdSingle< ElementType >

Converter from value::Single to ElementType.

Values provided by the end users must be converted to other types before being forwarded to the core library. This converter is used when the input value is a value::Single.

StdSingle together with StdVector and StdMatrix might serve as samples for bridge developers who want to implement their own converters. A few constraints have to be verified. Reading documentation for these three classes before implement any converter is strongly advisable.

These constraints are such that for converters taking value::Single as input there is little (if any) room for other converters. However, converters taking value::Vector or value::Matrix can be tailored to specific core library needs.

The constraints are composed by certain typedefs and methods that must be member of any converter. They will be explained below.

Parameters:
ElementType : The output type.
Return values:
InputType_ : value::Single;
OutputType_ : ElementType.

Member Typedef Documentation

Compulsory member.

typedef ElementType OutputType_

Compulsory member.

Notice that getOutput() returns an OutputType_ object by value. Hence, it is advisable for this type to be cheap-to-copy.


Constructor & Destructor Documentation

StdSingle ( const InputType_ input,
OutputType_ cache 
) [inline]

Compulsory constructor.

Internally, the converter must store a copy of the input and a copy of previously cached output (if any). It have also to compare the new computed output with the cached one to see if anything dependent on the cached output must bu updated. (See mustUpdate().)

Parameters:
input : Input data.
cache : A pointer to the previoulsy cached value if there exist one. Otherwise, a null pointer must be given.

Member Function Documentation

bool isEmpty (  )  const [inline]

Compulsory member: Checks if conversion has finished.

Returns:
This methods must return true if all elements of input data have been processed. Otherwise, it must returns false.
value::Variant pop (  )  [inline]

Compulsory member: Gets next input element.

Returns:
A copy of next input element to be processed.
void insert ( const ElementType &  element  )  [inline]

Compulsory member: Inserts a new element into the output container.

Parameters:
element : The element to be inserted into the output container.
StdSingle< ElementType >::OutputType_ getOutput (  )  const [inline]

Compulsory member: Gets output container.

Returns:
A copy of output container.
bool mustUpdate (  )  const [inline]

Compulsory member: Informs if cached value is up to date.

Returns:
This method returns true if cached value is out of date. Otherwise it returns false.

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