MonotoneBoundedVector< ElementType, Monotone, Bound1, Bound2 > Class Template Reference

Key for monotone bounded vectors. More...

#include <MonotoneBoundedVector.h>

Inheritance diagram for MonotoneBoundedVector< ElementType, Monotone, Bound1, Bound2 >:
Inheritance graph
[legend]

List of all members.

Public Types

enum  
typedef Traits< ElementType,
StdVector, NoMap
Traits_
typedef StdVector< typename
NoMap< ElementType >
::OutputType_ > 
ConverterType_
typedef ConverterType_::InputType_ InputType_
typedef ConverterType_::OutputType_ OutputType_

Public Member Functions

 MonotoneBoundedVector (const string &name, size_t size=0)
 Constructs a MonotoneBoundedVector given its name and expected size.
 MonotoneBoundedVector (const string &name, const ElementType &bound1, size_t size=0)
 Constructs a MonotoneBoundedVector given its name, a bound and expected size.
 MonotoneBoundedVector (const string &name, const ElementType &bound1, const ElementType &bound2, size_t size=0)
 Constructs a MonotoneBoundedVector given its name, two bounds and expected size.
void checkSoFar (const StdVector< ElementType > &container) const
 Checks for monotonicity and boundness of the values.
void checkSize (size_t size) const
 Checks for the size of the vector of values.
string getName () const
 Gets Key's name.
void setName (const string &name)
 Sets name.
ElementType map (const value::Variant &variant) const
 Performs the mapping.

Private Attributes

const size_t size_
const Bound1< ElementType > bound1_
const Bound2< ElementType > bound2_

Detailed Description

template<typename ElementType, typename Monotone, template< typename > class Bound1 = NoBound, template< typename > class Bound2 = NoBound>
class keyvalue::key::MonotoneBoundedVector< ElementType, Monotone, Bound1, Bound2 >

Key for monotone bounded vectors.

This template is used for keys whose converter type is a StdVector holding a std::vector<ElementType> V (of size n) with bounded and ordered elements.

There are five types of monotonicity modeled by monotone classes:

Given a monotone class Monotone and two bound template classes Bound1 and Bound2 (See Bounded for more information on bound template classes), V will be accepted only if

where bound1_ and bound2_ are instances (for ElementType) of bound template classes Bound1 and Bound2, resp.

Additionally, at construction time, the key name and the expected size of the V are fixed. At the time the value for this key is requested, V's size and its expected size are compared. If they do not match, then V is rejected.

Example 1: A key for a vector of dates in strictly increasing order:

MonotoneBoundedVector<ptime, StrictlyIncreasing> dates("Dates");

Example 2: A key for a vector of prices which accepts positive numbers.

MonotoneBoundedVector<double, NoBound, Geq> prices("Prices", 0.0);

Example 3: Same as in Example 2 but accepting only 10 elements:

MonotoneBoundedVector<double, NoBound, Geq> prices("Prices", 0.0, 10);

Example 4: A key for a vector of 5 decreasing numbers in the interval (-2,2):

MonotoneBoundedVector<double, Decreasing, Greater, Less> a("A", -2.0, 2.0, 5);

Parameters:
ElementType : (template parameter) See description above;
Monotone : (template parameter) Monotone class;
Bound1 : (template parameter) 1st bound template class;
Bound2 : (template parameter) 2nd bound template class.

Constructor & Destructor Documentation

MonotoneBoundedVector ( const string &  name,
size_t  size = 0 
) [inline, explicit]

Constructs a MonotoneBoundedVector given its name and expected size.

Parameters:
name : The key name;
size : Expected size. By default, size = 0 which means there is no expected size, i.e., any stricktly positive size for the StdVector content will be accepted.
MonotoneBoundedVector ( const string &  name,
const ElementType &  bound1,
size_t  size = 0 
) [inline]

Constructs a MonotoneBoundedVector given its name, a bound and expected size.

Parameters:
name : The key name;
bound1 : The value to be wrapped by Bound1;
size : Expected size. By default, size = 0 which means there is no expected size, i.e., any stricktly positive size for the StdVector content will be accepted.
MonotoneBoundedVector ( const string &  name,
const ElementType &  bound1,
const ElementType &  bound2,
size_t  size = 0 
) [inline]

Constructs a MonotoneBoundedVector given its name, two bounds and expected size.

Parameters:
name : The key name;
bound1 : The value to be wrapped by Bound1;
bound2 : The value to be wrapped by Bound2;
size : Expected size. By default, size = 0 which means there is no expected size, i.e., any stricktly positive size for the StdVector content will be accepted.

Member Function Documentation

void checkSoFar ( const StdVector< ElementType > &  container  )  const [inline]

Checks for monotonicity and boundness of the values.

Parameters:
container : The StdVector containing the std::vector of to be checked.
Exceptions:
RuntimeError : If test fails.
void checkSize ( size_t  size  )  const [inline]

Checks for the size of the vector of values.

Parameters:
container : The StdVector containing the std::vector whose size should be checked.
Exceptions:
RuntimeError : If there is no expected size or if it does not agree with real size.
string getName (  )  const [inherited]

Gets Key's name.

Returns:
The Key's name.

Reimplemented from Key.

void setName ( const string &  name  )  [inherited]

Sets name.

Parameters:
name : The name.
ElementType map ( const value::Variant variant  )  const [inherited]

Performs the mapping.

This method retrieves the content of value::Variant and, by considering enabled lexical convertions, converts it to Output. (See LexicalToolKit documentation.)

Parameters:
variant : A value::Variant containing the input to be mapped.
Returns:
The mapping result.

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