Polaris: KeyDatabase< S, T > Class Template Reference

KeyDatabase< S, T > Class Template Reference

#include <KeyDatabase.h>

Inheritance diagram for KeyDatabase< S, T >:

Inheritance graph
[legend]
List of all members.

Public Member Functions

INLINE KeyDatabase ()
INLINE KeyDatabase (const KeyDatabase< S, T > &m)
virtual INLINE ~KeyDatabase ()
INLINE T & ins (S *key, T *data)
 Insert element with (key, data) into the database, and return a reference to '*data' (for purposes of programming convenience).
INLINE void del (S &del_key)
 delete element with key del_key
INLINE void print (ostream &out, char *sep1, char *sep2) const
 print database to out with sep1 between key and data and sep2 between each element of the database
INLINE KeyDatabase< S, T > & operator= (const KeyDatabase< S, T > &m)
 Copy operator completely copies the KeyDatabase.
INLINE Listablelistable_clone () const
 Needed for Listable class.
INLINE void print (ostream &o) const
 Needed for Listable class.

Protected Member Functions

virtual INLINE void _kill_key (BMKey &key)
 kill key

Detailed Description

template<class S, class T>
class KeyDatabase< S, T >

DESCRIPTION

KeyDatabase<key,data> owns(key,data), value(key)

A template for a database for owned keys of type S to owned objects of type T where:

    1.  'S' is a class with:
   
        a) <, == and << operators taking S& arguments.
        b) a copy constructor S(S &) to clone the
           input object or simple enough structure
           for the default copy constructor to work.
   
    2.  'T' is a class derived from Listable.

The database is implemented as a tree of pointers to whatever type is specified. Thus, all methods to insert elements into a database take a pointer to the key and data and do not allocate space. (i.e., the database aliases whatever is in the list). However, the database takes over ownership of the keys on insert and will delete both a database element and its associated key.

Definition at line 36 of file KeyDatabase.h.


Constructor & Destructor Documentation

template<class S, class T>
INLINE KeyDatabase< S, T >::KeyDatabase  ) 
 

< nothing to do

Definition at line 87 of file KeyDatabase.h.

template<class S, class T>
INLINE KeyDatabase< S, T >::KeyDatabase const KeyDatabase< S, T > &  m  ) 
 

< Invoke copy constructor

Definition at line 94 of file KeyDatabase.h.

template<class S, class T>
INLINE KeyDatabase< S, T >::~KeyDatabase  )  [virtual]
 

< Delete the information before the class disappears.

Definition at line 102 of file KeyDatabase.h.

References BaseMapRoot::clear().


Member Function Documentation

template<class S, class T>
INLINE void KeyDatabase< S, T >::_kill_key BMKey key  )  [protected, virtual]
 

kill key

Reimplemented from BaseMapRoot.

Definition at line 78 of file KeyDatabase.h.

template<class S, class T>
INLINE T & KeyDatabase< S, T >::ins S *  key,
T *  data
 

Insert element with (key, data) into the database, and return a reference to '*data' (for purposes of programming convenience).

If a node with an equivalent key already exists, delete the old one and replace it with the new one.

Definition at line 110 of file KeyDatabase.h.

References BMKey::_keyptr, BaseMapRoot::ins(), and BaseMapRoot::remove().

Referenced by clone_loop(), clone_loop_body(), and KeyDatabase< S, T >::operator=().

template<class S, class T>
INLINE void KeyDatabase< S, T >::del S &  del_key  ) 
 

delete element with key del_key

Definition at line 128 of file KeyDatabase.h.

References BMKey::_keyptr, and BaseMapRoot::remove().

template<class S, class T>
INLINE void KeyDatabase< S, T >::print ostream &  out,
char *  sep1,
char *  sep2
const
 

print database to out with sep1 between key and data and sep2 between each element of the database

Definition at line 145 of file KeyDatabase.h.

References BMKey::_keyptr, and ProtoDatabase< S, T >::_print().

Referenced by KeyDatabase< S, T >::print().

template<class S, class T>
INLINE KeyDatabase< S, T > & KeyDatabase< S, T >::operator= const KeyDatabase< S, T > &  m  ) 
 

Copy operator completely copies the KeyDatabase.

< Clear out current map

< Copy all the items one by one

Definition at line 161 of file KeyDatabase.h.

References BaseMapRoot::clear(), and KeyDatabase< S, T >::ins().

template<class S, class T>
INLINE Listable * KeyDatabase< S, T >::listable_clone  )  const [virtual]
 

Needed for Listable class.

Implements Listable.

Definition at line 177 of file KeyDatabase.h.

template<class S, class T>
INLINE void KeyDatabase< S, T >::print ostream &  o  )  const [virtual]
 

Needed for Listable class.

It invokes a non-virtual member function to print a representation of the data structure at this level of the Collection hierarchy, and, since it is not a class member function, it must be explicitly instantiated before use.

Implements Listable.

Definition at line 184 of file KeyDatabase.h.

References KeyDatabase< S, T >::print().


The documentation for this class was generated from the following file:
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:07:39 2005