Main Page Modules Class Hierarchy Compound List File List Compound Members

# chead.h

    00001 //==========================================================================
    00002 //   CHEAD.H  - header for
    00003 //                             OMNeT++
    00004 //            Discrete System Simulation in C++
    00005 //
    00006 //
    00007 //  Declaration of the following classes:
    00008 //    cHead     : head of a list of cObjs
    00009 //    cIterator : walks along a list
    00010 //
    00011 //==========================================================================
    00012
    00013 /*--------------------------------------------------------------*
    00014   Copyright (C) 1992-2003 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 __CHEAD_H
    00021 #define __CHEAD_H
    00022
    00023 #include "cobject.h"
    00024
    00025 //=== classes declared here
    00026 class  cIterator;
    00027 class  cHead;
    00028
    00029 //=== classes mentioned
    00030 class  cModuleInterface;
    00031 class  cModuleType;
    00032 class  cLinkType;
    00033 class  cFunctionType;
    00034 class  cNetworkType;
    00035 class  cEnum;
    00036
    00037 //==========================================================================
    00038
    00064 class SIM_API cHead : public cObject
    00065 {
    00066     friend class const_cIterator;
    00067     friend class cIterator;
    00068     friend class cObject;
    00069
    00070   public:
    00073
    00077     cHead(const char *name=NULL);
    00078
    00082     cHead(const cHead& h) : cObject(h)  {setName(h.name());operator=(h);}
    00083
    00088     virtual ~cHead()  {}
    00089
    00093     cHead& operator=(const cHead&)  {copyNotSupported();return *this;}
    00095
    00102     virtual cObject *dup() const  {return new cHead(*this);}
    00103
    00108     virtual void forEach(ForeachFunc f);
    00110
    00113
    00118     cObject *find(const char *objname) const;
    00119
    00123     int count() const;
    00125 };
    00126
    00127 //==========================================================================
    00128
    00132 class SIM_API cIterator
    00133 {
    00134   private:
    00135     cObject *p;
    00136
    00137   public:
    00141     cIterator(const cObject& h)    {p = &h ? h.firstchildp : NULL;}
    00142
    00146     void init(cObject& h)    {p = &h ? h.firstchildp : NULL;}
    00147
    00151     cObject *operator()() const    {return p;}
    00152
    00156     bool end() const  {return (bool)(p==NULL);}
    00157
    00161     cObject *operator++(int)  {if (!p) return NULL; cObject *t=p; p=p->nextp; return t;}
    00162 };
    00163
    00164
    00168 class SIM_API const_cIterator
    00169 {
    00170   private:
    00171     const cObject *p;
    00172
    00173   public:
    00177     const_cIterator(const cObject& h)    {p = &h ? h.firstchildp : NULL;}
    00178
    00182     void init(const cObject& h)    {p = &h ? h.firstchildp : NULL;}
    00183
    00187     const cObject *operator()() const  {return p;}
    00188
    00192     bool end() const  {return (bool)(p==NULL);}
    00193
    00197     const cObject *operator++(int)  {if (!p) return NULL; const cObject *t=p; p=p->nextp; return t;}
    00198 };
    00199
    00200 //==========================================================================
    00201
    00207
    00209 inline cNetworkType *findNetwork(const char *s)
    00210   {return (cNetworkType *)networks.find(s);}
    00211
    00213 inline cModuleType *findModuleType(const char *s)
    00214   {return (cModuleType *)modtypes.find(s);}
    00215
    00217 inline cModuleInterface *findModuleInterface(const char *s)
    00218   {return (cModuleInterface *)modinterfaces.find(s);}
    00219
    00221 inline cLinkType *findLink(const char *s)
    00222   {return (cLinkType *)linktypes.find(s);}
    00223
    00225 cFunctionType *findFunction(const char *s,int argcount);
    00226
    00228 inline cEnum *findEnum(const char *s)
    00229   {return (cEnum *)enums.find(s);}
    00231
    00232 #endif
    00233