Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

PointerMap Template Class Reference

This is provided for use with objects which want to maintain a simple database of named objects. More...

#include <pointermap.h>

List of all members.

Public Types

typedef K key_type
 Key type of our local map. More...

typedef T* data_type
 Data element type of our local map. More...

typedef pair<const key_type,
data_type
value_type
 Element type of our local map. More...

typedef std::map< key_type,
data_type
map_type
 Type of our local map. More...

typedef map_type::iterator iterator
 Map's iterator. More...

typedef map_type::const_iterator const_iterator
 Map's const_iterator. More...


Public Methods

 PointerMap ()
virtual ~PointerMap ()
iterator begin ()
 Underlying map's begin(). More...

const_iterator begin () const
 Underlying map's begin(). More...

iterator end ()
 Underlying map's end(). More...

const_iterator end () const
 Underlying map's end(). More...

pair<iterator,bool> insert (const value_type& x)
 Insert into underlying map. More...

void set (const key_type& k, const data_type d)
 Instead of directly using the map's [], which has a tricky semantics, or find, which is cumbersome, map access is handled through named get and set member functions. More...

T* getptr (const key_type& k)
 Similar to map's [], but if the key is not present just returns a null pointer without adding a new entry. More...

const T* getptr (const key_type& k) const
 Const version of getptr. More...

void erase ()
 Remove all items from the map. More...

void erase (const key_type& k)
 Remove the item with the given key, if any, from the map. More...


Protected Attributes

map_type m
 Underlying container. More...


Detailed Description

template<class T, class K = string, bool owns_objects = true> template class PointerMap

This is provided for use with objects which want to maintain a simple database of named objects.

By default, the objects are assumed to be allocated on the heap and their memory management is handled by the database; if instead you wish to manage the memory yourself (e.g. for objects existing in more than one map) supply false for the owns_objects template parameter.

Definition at line 32 of file pointermap.h.


Member Typedef Documentation

template<classT, classK = string, boolowns_objects = true>
typedef map_type::const_iterator PointerMap<T, K, owns_objects>::const_iterator
 

Map's const_iterator.

Definition at line 51 of file pointermap.h.

template<classT, classK = string, boolowns_objects = true>
typedef T* PointerMap<T, K, owns_objects>::data_type
 

Data element type of our local map.

Definition at line 39 of file pointermap.h.

template<classT, classK = string, boolowns_objects = true>
typedef map_type::iterator PointerMap<T, K, owns_objects>::iterator
 

Map's iterator.

Definition at line 48 of file pointermap.h.

template<classT, classK = string, boolowns_objects = true>
typedef K PointerMap<T, K, owns_objects>::key_type
 

Key type of our local map.

Definition at line 36 of file pointermap.h.

template<classT, classK = string, boolowns_objects = true>
typedef std::map< key_type, data_type > PointerMap<T, K, owns_objects>::map_type
 

Type of our local map.

Definition at line 45 of file pointermap.h.

template<classT, classK = string, boolowns_objects = true>
typedef pair<const key_type, data_type> PointerMap<T, K, owns_objects>::value_type
 

Element type of our local map.

Definition at line 42 of file pointermap.h.


Constructor & Destructor Documentation

template<classT, classK = string, boolowns_objects = true>
PointerMap<T, K, owns_objects>::PointerMap<T, K, owns_objects> ( ) [inline]
 

Definition at line 54 of file pointermap.h.

template<classT, classK = string, boolowns_objects = true>
PointerMap<T, K, owns_objects>::~PointerMap<T, K, owns_objects> ( ) [inline, virtual]
 

Definition at line 55 of file pointermap.h.


Member Function Documentation

template<classT, classK = string, boolowns_objects = true>
const_iterator PointerMap<T, K, owns_objects>::begin ( ) const [inline]
 

Underlying map's begin().

Definition at line 59 of file pointermap.h.

template<classT, classK = string, boolowns_objects = true>
iterator PointerMap<T, K, owns_objects>::begin ( ) [inline]
 

Underlying map's begin().

Definition at line 58 of file pointermap.h.

Referenced by Eyes::activate().

template<classT, classK = string, boolowns_objects = true>
const_iterator PointerMap<T, K, owns_objects>::end ( ) const [inline]
 

Underlying map's end().

Definition at line 61 of file pointermap.h.

template<classT, classK = string, boolowns_objects = true>
iterator PointerMap<T, K, owns_objects>::end ( ) [inline]
 

Underlying map's end().

Definition at line 60 of file pointermap.h.

Referenced by Eyes::activate(), getptr(), and set().

template<classT, classK = string, boolowns_objects = true>
void PointerMap<T, K, owns_objects>::erase ( const key_type & k ) [inline]
 

Remove the item with the given key, if any, from the map.

Definition at line 110 of file pointermap.h.

template<classT, classK = string, boolowns_objects = true>
void PointerMap<T, K, owns_objects>::erase ( ) [inline]
 

Remove all items from the map.

Definition at line 102 of file pointermap.h.

Referenced by Eyes::uninit().

template<classT, classK = string, boolowns_objects = true>
const T * PointerMap<T, K, owns_objects>::getptr ( const key_type & k ) const [inline]
 

Const version of getptr.

Definition at line 93 of file pointermap.h.

template<classT, classK = string, boolowns_objects = true>
T * PointerMap<T, K, owns_objects>::getptr ( const key_type & k ) [inline]
 

Similar to map's [], but if the key is not present just returns a null pointer without adding a new entry.

Definition at line 87 of file pointermap.h.

Referenced by Eyes::activate(), and erase().

template<classT, classK = string, boolowns_objects = true>
pair< iterator,bool > PointerMap<T, K, owns_objects>::insert ( const value_type & x ) [inline]
 

Insert into underlying map.

Definition at line 63 of file pointermap.h.

Referenced by set().

template<classT, classK = string, boolowns_objects = true>
void PointerMap<T, K, owns_objects>::set ( const key_type & k,
const data_type d ) [inline]
 

Instead of directly using the map's [], which has a tricky semantics, or find, which is cumbersome, map access is handled through named get and set member functions.

It is illegal to supply an invalid pointer to set, since this class will handle the deallocation of the object pointed to.

Definition at line 72 of file pointermap.h.

Referenced by Eyes::init().


Member Data Documentation

template<classT, classK = string, boolowns_objects = true>
map_type PointerMap<T, K, owns_objects>::m [protected]
 

Underlying container.

Definition at line 119 of file pointermap.h.


The documentation for this class was generated from the following file:
Generated at Mon Aug 21 00:31:21 2000 for RF-LISSOM by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000