cenum.h

00001 //==========================================================================
00002 //  CENUM.H - part of
00003 //
00004 //                     OMNeT++/OMNEST
00005 //            Discrete System Simulation in C++
00006 //
00007 //
00008 //  Declaration of the following classes:
00009 //    cEnum : effective integer-to-string mapping
00010 //
00011 //==========================================================================
00012 
00013 /*--------------------------------------------------------------*
00014   Copyright (C) 1992-2005 Andras Varga
00015 
00016   This file is distributed WITHOUT ANY WARRANTY. See the file
00017   `license' for details on this and other legal matters.
00018 *--------------------------------------------------------------*/
00019 
00020 #ifndef __CENUM_H
00021 #define __CENUM_H
00022 
00023 #include "cobject.h"
00024 
00025 
00026 //==========================================================================
00027 
00037 class SIM_API cEnum : public cObject
00038 {
00039   private:
00040      struct sEnum {
00041           int key;
00042           char *string;
00043      };
00044      sEnum *vect;      // vector of objects
00045      int size;         // size of vector; always prime
00046      int items;        // number if items in the vector
00047 
00048   public:
00051 
00055     cEnum(const cEnum& cenum);
00056 
00060     cEnum(const char *name=NULL, int siz=17);
00061 
00065     virtual ~cEnum();
00066 
00071     cEnum& operator=(const cEnum& list);
00073 
00076 
00081     virtual cPolymorphic *dup() const  {return new cEnum(*this);}
00082 
00087     virtual std::string info() const;
00089 
00092 
00096     void insert(int key, const char *str);
00097 
00102     const char *stringFor(int key);
00103 
00108     int lookup(const char *str, int fallback=-1);
00110 };
00111 
00112 #endif
00113 

Generated on Sat Oct 21 17:47:55 2006 for OMNeT++/OMNEST Simulation Library by  doxygen 1.4.6