Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Bank< T, K > Class Template Reference

#include <Bank.h>

Inheritance diagram for Bank< T, K >:
Inheritance graph
[legend]
Collaboration diagram for Bank< T, K >:
Collaboration graph
[legend]

Classes

struct  bank_id
 

Public Types

typedef K key_t
 Public key type. (Key type used in the public interface.)
 
typedef T value_t
 Base type of cloned objects.
 
typedef ClonerBase< T > cloner_t
 
typedef std::map< K, cloner_t * > map_t
 Base class.
 
typedef std::set< K > key_set_t
 For enumerating keys. More...
 

Public Member Functions

template<class D >
D & add (const K &key)
 Adds class D as an internal instance. More...
 
template<class D >
D & add ()
 
template<class D >
D & addExternal (const D &entry, const K &key)
 Adds class D using a copy constructor on an external instance. More...
 
bool has (const K &key) const
 Check if a cloner is defined for this key.
 
T & clone (const K &key) const
 Return a copy of the base instance.
 
const T & get (const K &key) const
 Returns the base instance.
 
T & get (const K &key)
 Returns the base instance.
 
template<class D >
map_t::const_iterator get () const
 Returns a map entry: pair<Key,D *>()
 
cloner_tgetCloner (const K &key) const
 Return the internal static entry.
 
const map_tgetMap () const
 
virtual const std::string & resolve (const K &key) const
 
void toStream (std::ostream &ostr=std::cout) const
 
key_set_tgetKeys ()
 

Static Public Member Functions

template<class D >
static Cloner< T, D > & getCloner ()
 

Protected Member Functions

drain::ClonerBase< T > & set (const std::string &key, drain::ClonerBase< T > &cloner)
 

Protected Attributes

key_set_t keys
 

Detailed Description

template<class T, class K = std::string>
class drain::Bank< T, K >

A single entry for each class D derived from T can be stored. The that \i base entry, any number of entries can be cloned. The cloned entries are of type D, yet accessible only through a reference of base class T .

Template Parameters
T- value type (base type for cloning)
K- key type

An entry may have several keys. Single-char keys (aliases) are provided by SuperBank

Member Typedef Documentation

◆ key_set_t

typedef std::set<K> key_set_t

For enumerating keys.

See also
getKeys().

Member Function Documentation

◆ add()

D& add ( const K &  key)
inline

Adds class D as an internal instance.

For each class D, a single static instance is created.

It is allowed to adding a class repeatedly with different keys.

Changing static to external instance and vice versa causes a warning.

◆ addExternal()

D& addExternal ( const D &  entry,
const K &  key 
)
inline

Adds class D using a copy constructor on an external instance.

For each class D, a single static instance is created.

It is allowed to adding a class repeatedly with different keys.

Changing static to external instance and vice versa causes a warning. Changing external instances is allowed.

◆ resolve()

virtual const std::string& resolve ( const K &  key) const
inlinevirtual

If K != std::string, this class must be derived and this function redefined.

Reimplemented in BankSuper< T >, and BankSuper< Command >.

◆ set()

drain::ClonerBase<T>& set ( const std::string &  key,
drain::ClonerBase< T > &  cloner 
)
inlineprotected

Raises a warning if cloner is changed from external to internal, or vice versa.


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