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,2001 Andras Varga
00014   Technical University of Budapest, Dept. of Telecommunications,
00015   Stoczek u.2, H-1111 Budapest, Hungary.
00016 
00017   This file is distributed WITHOUT ANY WARRANTY. See the file
00018   `license' for details on this and other legal matters.
00019 *--------------------------------------------------------------*/
00020 
00021 #ifndef __CENUM_H
00022 #define __CENUM_H
00023 
00024 #include "cobject.h"
00025 
00026 
00027 //==========================================================================
00028 
00038 class SIM_API cEnum : public cObject
00039 {
00040   private:
00041      struct sEnum {
00042           int key;
00043           char *string;
00044      };
00045      sEnum *vect;      // vector of objects
00046      int size;         // size of vector; always prime
00047      int items;        // number if items in the vector
00048 
00049   public:
00052 
00056     cEnum(const cEnum& cenum);
00057 
00061     cEnum(const char *name=NULL, int siz=17);
00062 
00066     virtual ~cEnum();
00067 
00072     cEnum& operator=(const cEnum& list);
00074 
00077 
00081     virtual const char *className() const  {return "cEnum";}
00082 
00087     virtual cObject *dup() const  {return new cEnum(*this);}
00088 
00093     virtual void info(char *buf);
00095 
00098 
00102     void insert(int key, const char *str);
00103 
00108     const char *stringFor(int key);
00109 
00114     int lookup(const char *str, int fallback=-1);
00116 };
00117 
00118 //==========================================================================
00119 
00135 class SIM_API sEnumBuilder  //FIXME: make inner class to cEnum?
00136 {
00137   public:
00141     sEnumBuilder(const char *name, ...);
00142 };
00143 
00144 #endif
00145 

Generated at Sat May 4 15:45:48 2002 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001