libmoost
moost::configurable::binder Class Reference

binder is a helper class that aids synchronized binding/setting/getting of nested configurations. More...

#include <binder.h>

Inheritance diagram for moost::configurable::binder:
Collaboration diagram for moost::configurable::binder:

List of all members.

Public Member Functions

 binder ()
 Constructs a binder.
virtual ~binder ()
 Destroys binder.
void read (std::istream &source)
 read properties from source, and set defaults where properties omitted
void write (std::ostream &dest, int indent=0) const
 write properties to dest
void set (const std::string &key, const std::string &value)
 set a particular binding to value
void get (const std::string &key, std::string &value) const
 get the value of a particular binding and store it in value
void list (std::vector< std::pair< std::string, std::string > > &items)
 list all bindings and their values
void set_default ()
 set default values to all bindings

Protected Member Functions

void child (const std::string &key, persistable &value)
 add persistable as subcomponent with name key
template<typename T >
void bind (const std::string &key, T &value)
 add reference to field with name key
template<typename T >
void bind (const std::string &key, T &value, const T &default_value)
 add reference to field with name key with a default value

Private Types

typedef std::map< std::string,
persistable * > 
route_map

Private Attributes

route_map m_routes
std::vector< persistable * > m_bindings

Detailed Description

binder is a helper class that aids synchronized binding/setting/getting of nested configurations.

Inherit from binder to obtain property getting/setting superpowers. Define your bindings in your ctor using the helper functions child and bind (see the tests for examples).

Definition at line 51 of file binder.h.


Member Typedef Documentation

typedef std::map<std::string, persistable * > moost::configurable::binder::route_map [private]

Definition at line 55 of file binder.h.


Constructor & Destructor Documentation

Constructs a binder.

Definition at line 77 of file binder.h.

binder::~binder ( ) [virtual]

Destroys binder.

Definition at line 37 of file binder.cpp.


Member Function Documentation

template<typename T >
void moost::configurable::binder::bind ( const std::string &  key,
T &  value 
) [protected]

add reference to field with name key

Definition at line 102 of file binder.h.

template<typename T >
void moost::configurable::binder::bind ( const std::string &  key,
T &  value,
const T &  default_value 
) [protected]

add reference to field with name key with a default value

Definition at line 109 of file binder.h.

void binder::child ( const std::string &  key,
persistable value 
) [protected]

add persistable as subcomponent with name key

Definition at line 43 of file binder.cpp.

void binder::get ( const std::string &  key,
std::string &  value 
) const [virtual]

get the value of a particular binding and store it in value

set one key/value pair

Implements moost::configurable::configurable.

Definition at line 160 of file binder.cpp.

Here is the call graph for this function:

void binder::list ( std::vector< std::pair< std::string, std::string > > &  items) [virtual]

list all bindings and their values

Implements moost::configurable::configurable.

Definition at line 188 of file binder.cpp.

Here is the call graph for this function:

void binder::read ( std::istream &  source) [virtual]

read properties from source, and set defaults where properties omitted

set all key/value pairs

Implements moost::configurable::persistable.

Definition at line 49 of file binder.cpp.

Here is the caller graph for this function:

void binder::set ( const std::string &  key,
const std::string &  value 
) [virtual]

set a particular binding to value

get one key/value pair

Implements moost::configurable::configurable.

Definition at line 132 of file binder.cpp.

Here is the call graph for this function:

void binder::set_default ( ) [virtual]

set default values to all bindings

Implements moost::configurable::persistable.

Definition at line 209 of file binder.cpp.

void binder::write ( std::ostream &  dest,
int  indent = 0 
) const [virtual]

write properties to dest

get all key/value pairs

Implements moost::configurable::persistable.

Definition at line 108 of file binder.cpp.

Here is the call graph for this function:


Member Data Documentation

Definition at line 59 of file binder.h.

Definition at line 57 of file binder.h.


The documentation for this class was generated from the following files: