00001 /* $Revision: 3 $ */ 00002 00003 /* $Id: stilentitytable.h 3 2006-01-10 18:53:38Z joel1234567 $ */ 00004 00005 /******************************************************************************* 00006 * Copyright (c) 2006 International Business Machines Corporation 00007 * All rights reserved. This program and the accompanying materials 00008 * are made available under the terms of the Common Public License v1.0 00009 * which accompanies this distribution, and is available at 00010 * http://www.opensource.org/licenses/cpl1.0.php 00011 * 00012 * Contributors: 00013 * Douglas Sprague, Joel Wheeler - initial API and implementation 00014 * 00015 * Modification Log: 00016 * $Log$ 00017 * Revision 1.1 2006/01/10 18:53:39 joel1234567 00018 * Initial revision 00019 * 00020 * 00021 *****************************************************************************/ 00022 00023 #ifndef STILEntityTable_H 00024 #define STILEntityTable_H 00025 00026 #include "stilcom.h" 00027 #include "stilentity.h" 00028 #include "stilcomstr.h" 00029 00030 #include <map> 00031 #include <vector> 00032 00033 00034 //--------------------------------------------------------------------------- 00040 //--------------------------------------------------------------------------- 00041 class STILEntityTable { 00042 00043 public: 00044 00047 typedef enum { 00048 NO_ALLOC, 00049 ALLOC 00050 } STILEntityTableAllocType; 00051 00052 // - Default Constructor to create and initialize a STILEntityTable object 00053 STILEntityTable(); 00054 00055 // - Constructor to create table with necessary initial symbols 00056 STILEntityTable(STILEntityTableAllocType); 00057 00058 // - Copy Constructor 00059 STILEntityTable(const STILEntityTable &); 00060 00061 // - Destructor which frees storage associated with the STILEntityTable 00062 ~STILEntityTable(); 00063 00064 // - The assignment operator -- Not Implemented! Link error if used 00065 STILEntityTable & operator=(const STILEntityTable &); 00066 00067 // - Initialize/reset the table 00068 void init(STILEntityTableAllocType table_type = NO_ALLOC); 00069 00070 // - Add a new entity to the table 00071 void addTableEntity(const STILEntity *); 00072 00073 // - Locate an entity in the table (returns NULL if not found) 00074 const STILEntity * locateTableEntity(const sstring&) const; 00075 00076 // - Get the number of entries in the table 00077 LONG size() const; 00078 00079 // - Index directly into the table 00080 const STILEntity* operator[](const LONG&) const; 00081 00082 00083 private: 00084 00085 typedef std::map<sstring, const STILEntity*>::const_iterator Iterator; 00086 00087 //add clone(), clearMem() funcs... (as private) if ALLOC type 00088 // - Reallocate a table's space 00089 void clearTable(); 00090 00091 // Map used to store symbols 00092 std::map<sstring, const STILEntity*> m_symtbl; 00093 00094 // Array used to index into the table 00095 std::vector<const STILEntity*> m_orderedTbl; 00096 00097 STILEntityTableAllocType m_tat; 00098 00099 }; // end STILEntityTable class 00100 00101 //-------------------------------------------------------------------------- 00109 //-------------------------------------------------------------------------- 00110 inline LONG STILEntityTable::size() const { return (m_symtbl.size()); } 00111 00112 #endif