Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

idep_aliastable.h

Go to the documentation of this file.
00001 // idep_aliastable.h
00002 #ifndef INCLUDED_IDEP_ALIASTABLE
00003 #define INCLUDED_IDEP_ALIASTABLE
00004 
00005 // This leaf component defines 2 classes:
00006 //       idep_AliasTable: supports efficient (hashed) name to name mapping
00007 //   idep_AliasTableIter: iterate through the collection of name mappings
00008 
00009 #include <iosfwd>
00010 class idep_AliasTableLink;
00011 class idep_AliasTableIter;
00012 
00013 
00014 class idep_AliasTable {
00015     idep_AliasTableLink **d_table_p;            // hash table
00016     int d_size;                                 // size of hash table
00017     friend class idep_AliasTableIter;
00018 
00019   private:
00020     idep_AliasTable(const idep_AliasTable&);            // not implemented
00021     idep_AliasTable& operator=(const idep_AliasTable&); // not implemented
00022 
00023   public:
00024     // CREATORS
00025     idep_AliasTable(int sizeHint = 0); 
00026         // Create a new table; optionally specify expected number of entries.
00027     ~idep_AliasTable();                                       
00028 
00029     // MANIPULATORS
00030     int add(const char *alias, const char *originalName);
00031         // Add an alias to the table.  Returns 0 on success, 1 if the
00032         // identical alias/originalName was already present, -1 if an
00033         // alias with a different original name was present.  Under
00034         // no circumstances will an alias be overwritten with a new
00035         // original name.  (Neither alias nor originalName may be 0.)
00036 
00037     // ACCESSORS
00038     const char *lookup(const char *alias) const;
00039         // Return the original name if the alias exists, else 0.
00040 };
00041         
00042 std::ostream& operator<<(std::ostream& output, const idep_AliasTable& table);
00043     // Write the entire logical contents of the specified alias table in some 
00044     // reasonable format to the specified output stream.
00045         
00046 class idep_AliasTableIter {
00047     const idep_AliasTable& d_table;     // reference to const alias table
00048     idep_AliasTableLink *d_link_p;      // ptr to current link in table 
00049     int d_index;                        // index of current slot
00050 
00051   private:
00052     idep_AliasTableIter(const idep_AliasTableIter&);            // not impl.
00053     idep_AliasTableIter& operator=(const idep_AliasTableIter&); // not impl.
00054 
00055   public:
00056     // CREATORS
00057     idep_AliasTableIter(const idep_AliasTable& table);
00058         // Create an iterator for the specified table.
00059     ~idep_AliasTableIter();
00060 
00061     // MANIPULATORS
00062     void reset();
00063         // Reset this iterator to the start of the iteration.
00064 
00065     void operator++();
00066         // Advance state of iteration to next alias/originalName pair.
00067 
00068     // ACCESSORS
00069     operator const void *() const;
00070         // Return non-zero if current element is valid; else 0.
00071 
00072     const char *alias() const;
00073         // Return current alias name.
00074 
00075     const char *originalName() const;
00076         // Return the (original) name corresponding to current alias name. 
00077 };
00078 
00079 #endif
00080 
00081 

Generated on Mon Feb 15 11:06:48 2010 for loon by  doxygen 1.3.9.1