Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

cenum.h

00001 //==========================================================================
00002 //   CENUM.H  - header for
00003 //                             OMNeT++
00004 //            Discrete System Simulation in C++
00005 //
00006 //
00007 //  Declaration of the following classes:
00008 //    cEnum : effective integer-to-string mapping
00009 //
00010 //==========================================================================
00011 
00012 /*--------------------------------------------------------------*
00013   Copyright (C) 1992-2003 Andras Varga
00014 
00015   This file is distributed WITHOUT ANY WARRANTY. See the file
00016   `license' for details on this and other legal matters.
00017 *--------------------------------------------------------------*/
00018 
00019 #ifndef __CENUM_H
00020 #define __CENUM_H
00021 
00022 #include "cobject.h"
00023 
00024 
00025 //==========================================================================
00026 
00036 class SIM_API cEnum : public cObject
00037 {
00038   private:
00039      struct sEnum {
00040           int key;
00041           char *string;
00042      };
00043      sEnum *vect;      // vector of objects
00044      int size;         // size of vector; always prime
00045      int items;        // number if items in the vector
00046 
00047   public:
00050 
00054     cEnum(const cEnum& cenum);
00055 
00059     cEnum(const char *name=NULL, int siz=17);
00060 
00064     virtual ~cEnum();
00065 
00070     cEnum& operator=(const cEnum& list);
00072 
00075 
00080     virtual cObject *dup() const  {return new cEnum(*this);}
00081 
00086     virtual void info(char *buf);
00088 
00091 
00095     void insert(int key, const char *str);
00096 
00101     const char *stringFor(int key);
00102 
00107     int lookup(const char *str, int fallback=-1);
00109 };
00110 
00111 //==========================================================================
00112 
00128 class SIM_API sEnumBuilder  //FIXME: make inner class to cEnum?
00129 {
00130   public:
00134     sEnumBuilder(const char *name, ...);
00135 };
00136 
00137 #endif
00138 

Generated at Mon Jun 16 23:37:31 2003 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001