OSB_LIB::NameList< Key, Comp > Class Template Reference

Collaboration diagram for OSB_LIB::NameList< Key, Comp >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<typename Key, typename Comp>
class OSB_LIB::NameList< Key, Comp >

Name and description of OSB objects.

The class allows to store the name and description of objects that are uniquely identified by Key.

Parameters:
Key Unique identifier of the objects.
Comp The key comparison function for strict weak ordering of Key.
The default is std::less<Key> (declared in namelistfwd.h).
Key is typically the object id of the class,
note that in the example below both definitions of DemoInfo are equivalent.

      Definition of struct Demo
      -------------------------
      #include <osbid.h>
      struct Demo {
          typedef Id<Demo> Oid;
          // ... other members
      };

      Client of NameList
      ------------------
      #include <osbid.h>
      #include <namelist.h>
      typedef NameList< Id<Demo> > DemoInfo;

      #include <demo.h>
      typedef NameList<Demo::Oid> DemoInfo;

Note:
If the list can not find a matching entry it uses nullEntry(), which by default contains an empty name and description.
A client that needs a non-empty name or description if the information about an object is not available should create an appropriate entry in the list.
See also:
NameListReader, Id1InfoReader, Id2InfoReader

Definition at line 106 of file namelist.h.

Public Types

Public Member Functions

Access to objects stored in the list.
Maintain the list.

Private Member Functions

Private Attributes

Classes


Member Typedef Documentation

template<typename Key, typename Comp>
typedef std::map<KeyType, Entry, Comp> OSB_LIB::NameList< Key, Comp >::Cont

STL container to store the entries.

Definition at line 125 of file namelist.h.

template<typename Key, typename Comp>
typedef Key OSB_LIB::NameList< Key, Comp >::KeyType

Uniform type for the key.

Definition at line 109 of file namelist.h.


Constructor & Destructor Documentation

template<typename Key, typename Comp>
OSB_LIB::NameList< Key, Comp >::NameList (  ) 

Default constructor.

Definition at line 381 of file namelist.h.

template<typename Key, typename Comp>
OSB_LIB::NameList< Key, Comp >::NameList ( const NameList< Key, Comp > &  rhs  ) 

Copy constructor: copies nullEntry_ if applicable.

Definition at line 389 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::nullEntry_, and OSB_LIB::NameList< Key, Comp >::setNullEntry().

template<typename Key, typename Comp>
OSB_LIB::NameList< Key, Comp >::~NameList (  ) 

Destructor: delete nullEntry_.

Definition at line 413 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::nullEntry_.


Member Function Documentation

template<typename Key, typename Comp>
void OSB_LIB::NameList< Key, Comp >::clear (  ) 

Clear the list and delete the null-entry.

Definition at line 426 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::entries_, and OSB_LIB::NameList< Key, Comp >::nullEntry_.

template<typename Key, typename Comp>
const std::string & OSB_LIB::NameList< Key, Comp >::des ( const Key &  key  )  const [inline]

Get the description of an object.

Definition at line 470 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::Entry::des_, and OSB_LIB::NameList< Key, Comp >::get().

template<typename Key, typename Comp>
const NameList< Key, Comp >::Cont & OSB_LIB::NameList< Key, Comp >::entries (  )  const

Get all entries.

Definition at line 420 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::entries_.

template<typename Key, typename Comp>
const NameList< Key, Comp >::Entry & OSB_LIB::NameList< Key, Comp >::get ( const Key &  key  )  const [inline]

Get the entry for one object.

Parameters:
key Key of the object.
Returns:
The entry for key or nullEntry() if key is not found.

Definition at line 451 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::entries_, and OSB_LIB::NameList< Key, Comp >::nullEntry().

Referenced by OSB_LIB::NameList< Key, Comp >::des(), and OSB_LIB::NameList< Key, Comp >::name().

template<typename Key, typename Comp>
const std::string & OSB_LIB::NameList< Key, Comp >::name ( const Key &  key  )  const [inline]

Get the name of an object.

Definition at line 462 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::get(), and OSB_LIB::NameList< Key, Comp >::Entry::name_.

template<typename Key, typename Comp>
const NameList< Key, Comp >::Entry * OSB_LIB::NameList< Key, Comp >::nullEntry (  )  const [private]

Get the default entry.

Creates nullEntry_ if needed.

Definition at line 477 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::nullEntry_.

Referenced by OSB_LIB::NameList< Key, Comp >::get(), and OSB_LIB::NameList< Key, Comp >::setNullEntry().

template<typename Key, typename Comp>
NameList< Key, Comp > & OSB_LIB::NameList< Key, Comp >::operator= ( const NameList< Key, Comp > &  rhs  ) 

Assignment operator.

It deletes and copies nullEntry_ if applicable.

Definition at line 398 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::nullEntry_, and OSB_LIB::NameList< Key, Comp >::setNullEntry().

template<typename Key, typename Comp>
NameList< Key, Comp >::Entry & OSB_LIB::NameList< Key, Comp >::operator[] ( const Key &  key  )  [inline]

Get the entry for a key.

Creates a new entry if needed.

Definition at line 435 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::entries_.

template<typename Key, typename Comp>
void OSB_LIB::NameList< Key, Comp >::setNullEntry ( const Entry nullEntry  ) 

Set the null entry.

Parameters:
nullEntry The entry to return from get() if a key is not found.

Definition at line 441 of file namelist.h.

References OSB_LIB::NameList< Key, Comp >::nullEntry(), and OSB_LIB::NameList< Key, Comp >::nullEntry_.

Referenced by OSB_LIB::NameList< Key, Comp >::NameList(), and OSB_LIB::NameList< Key, Comp >::operator=().


Member Data Documentation

template<typename Key, typename Comp>
Cont OSB_LIB::NameList< Key, Comp >::entries_ [private]

Map of entries.

Definition at line 190 of file namelist.h.

Referenced by OSB_LIB::NameList< Key, Comp >::clear(), OSB_LIB::NameList< Key, Comp >::entries(), OSB_LIB::NameList< Key, Comp >::get(), and OSB_LIB::NameList< Key, Comp >::operator[]().

template<typename Key, typename Comp>
Entry* OSB_LIB::NameList< Key, Comp >::nullEntry_ [mutable, private]

The default entry, always access via nullEntry().

Definition at line 192 of file namelist.h.

Referenced by OSB_LIB::NameList< Key, Comp >::clear(), OSB_LIB::NameList< Key, Comp >::NameList(), OSB_LIB::NameList< Key, Comp >::nullEntry(), OSB_LIB::NameList< Key, Comp >::operator=(), OSB_LIB::NameList< Key, Comp >::setNullEntry(), and OSB_LIB::NameList< Key, Comp >::~NameList().


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:11:41 2006 for OSB Library by  doxygen 1.4.7