Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's quick Index  

HxNameTable Class Reference

Class definition of a name table. More...

#include <HxNameTable.h>

Inheritance diagram for HxNameTable::

List of all members.

Public Types

typedef size_t sizeType
 The type of the Id's. More...


Public Methods

 HxNameTable ()
 Constructor. More...

virtual ~HxNameTable ()
 Destructor. More...

void insert (HxString name, sizeType id)
 Insert name,id combination. More...

sizeType getId (HxString name)
 Get the id for this name. More...

HxString getName (sizeType id) const
 Get the name for this id. More...

std::vector< HxStringgetNames () const
 Get all names in the table. More...

std::ostream & put (std::ostream &) const
 Put the table on the stream. More...


Detailed Description

Class definition of a name table.

A name table is used to maintain a list of name,id combinations. The id's are unique.


Member Typedef Documentation

typedef size_t HxNameTable::sizeType
 

The type of the Id's.


Constructor & Destructor Documentation

HxNameTable::HxNameTable  
 

Constructor.

00015 {
00016 }

HxNameTable::~HxNameTable   [virtual]
 

Destructor.

00019 {
00020 }


Member Function Documentation

void HxNameTable::insert HxString    name,
sizeType    i
 

Insert name,id combination.

00024 {
00025     Map::iterator ptr;
00026     HxString oldName("");
00027 
00028     if (i >= _index.size()) {
00029         _index.insert(_index.end(), i-_index.size()+1, HxString(""));
00030     }
00031 
00032     oldName = _index[i];
00033     if ((!oldName.empty()) && (oldName != name)) {
00034         ptr = _map.find(oldName);
00035         if (ptr != _map.end()) {
00036             _map.erase(ptr);
00037         }
00038     }
00039 
00040     if ((ptr = _map.find(name)) != _map.end()) {
00041         _index[(*ptr).second] = "";
00042     }
00043 
00044     _map[name] = i;
00045     _index[i] = name;
00046 }

HxNameTable::sizeType HxNameTable::getId HxString    name
 

Get the id for this name.

00050 {
00051     Map::iterator ptr = _map.find(name);
00052     if (ptr != _map.end()) {
00053         return (*ptr).second;
00054     } else {
00055         _index.push_back(name);
00056         _map.insert(Entry(name, _index.size()-1));
00057         return _index.size()-1;
00058     }
00059 }

HxString HxNameTable::getName sizeType    id const
 

Get the name for this id.

00063 {
00064     return id < _index.size() ? _index[id] : HxString("");
00065 }

std::vector< HxString > HxNameTable::getNames   const
 

Get all names in the table.

00069 {
00070     return _index;
00071 }

std::ostream & HxNameTable::put std::ostream &    os const
 

Put the table on the stream.

00075 {
00076     Map::const_iterator     mapPtr;
00077     Index::const_iterator   idxPtr;
00078     sizeType                i;
00079 
00080     os << "MAP" << STD_ENDL;
00081     for (mapPtr = _map.begin(); mapPtr != _map.end(); ++mapPtr) {
00082         os << (*mapPtr).first << " " << (*mapPtr).second << STD_ENDL;
00083     }
00084     os << "INDEX" << STD_ENDL;
00085     for (i=0, idxPtr = _index.begin(); idxPtr != _index.end(); ++i, ++idxPtr) {
00086         os << i << " " << *idxPtr << STD_ENDL;
00087     }
00088 
00089     return os;
00090 }


The documentation for this class was generated from the following files:
Generated on Tue Feb 3 14:19:06 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001