Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

ctypes.h

00001 //==========================================================================
00002 //   CTYPES.H  - header for
00003 //                             OMNeT++
00004 //            Discrete System Simulation in C++
00005 //
00006 //  Declaration of the following functions:
00007 //    createOne( char *classname )
00008 //
00009 //  Declaration of the following classes:
00010 //    cModuleInterface: defines a module interface (gates+parameters)
00011 //    cModuleType     : module class + interface pairs
00012 //    cLinkType       : channel type (propagation delay, error rate, data rate)
00013 //    cNetworkType    : network
00014 //    cClassRegister  : creates an object of a specific type
00015 //    cInspectorFactory : inspector creation
00016 //
00017 //==========================================================================
00018 
00019 /*--------------------------------------------------------------*
00020   Copyright (C) 1992-2001 Andras Varga
00021   Technical University of Budapest, Dept. of Telecommunications,
00022   Stoczek u.2, H-1111 Budapest, Hungary.
00023 
00024   This file is distributed WITHOUT ANY WARRANTY. See the file
00025   `license' for details on this and other legal matters.
00026 *--------------------------------------------------------------*/
00027 
00028 #ifndef __CTYPES_H
00029 #define __CTYPES_H
00030 
00031 #include <stdarg.h>
00032 #include "chead.h"
00033 #include "cobject.h"
00034 
00035 //=========================================================================
00036 //=== classes declared here
00037 class  cModuleInterface;
00038 class  cModuleType;
00039 class  cLinkType;
00040 class  cNetworkType;
00041 class  cFunctionType;
00042 class  cInspectorFactory;
00043 
00044 //=== class mentioned
00045 class  cModule;
00046 class  cPar;
00047 
00048 //=== function types used by cModuleType & cLinkType
00049 
00055 typedef cModule *(*ModuleCreateFunc)(const char *, cModule *);
00056 
00062 typedef cPar *(*ParCreateFunc)();
00063 
00064 //==========================================================================
00065 
00066 //
00067 // Used internally by cModuleInterface
00068 //
00069 // FIXME: why not inner class?
00070 struct sDescrItem {
00071     char what;
00072     char *name;
00073     char *types;
00074     char type;
00075 };
00076 
00113 class SIM_API cModuleInterface : public cObject
00114 {
00115     // structures used in a cModuleInterface
00116     struct sGateInfo {
00117        char *name;
00118        char type;
00119        bool vect;
00120     };
00121 
00122     struct sParamInfo {
00123        char *name;
00124        char *types;
00125     };
00126 
00127     struct sMachineInfo {
00128        char *name;
00129     };
00130 
00131   protected:
00132     int ngate;
00133     sGateInfo *gatev;
00134     int nparam;
00135     sParamInfo *paramv;
00136     int nmachine;            // NET
00137     sMachineInfo *machinev;  // NET
00138 
00139   private:
00140     // internal
00141     void allocate(int ngte, int npram, int nmach);
00142 
00143     // internal
00144     void check_consistency();
00145 
00146     // internal
00147     void setup(sDescrItem *descr_table);
00148 
00149   public:
00152 
00156     cModuleInterface(const char *name, sDescrItem *descr_table);
00157 
00161     cModuleInterface(const cModuleInterface& mi);
00162 
00166     virtual ~cModuleInterface();
00167 
00171     cModuleInterface& operator=(const cModuleInterface& mi);
00173 
00176 
00180     virtual const char *className() const {return "cModuleInterface";}
00181 
00186     virtual cObject *dup() const  {return new cModuleInterface(*this);}
00188 
00191 
00195     void addParametersGatesTo(cModule *module);
00196 
00202     void checkParametersOf(cModule *module);
00204 };
00205 
00206 //==========================================================================
00207 
00225 class SIM_API cModuleType : public cObject
00226 {
00227     friend class cModule;
00228   private:
00229     char *interface_name;
00230     cModuleInterface *interface;
00231     ModuleCreateFunc create_func;
00232 
00233   public:
00236 
00240     cModuleType(const char *classname, const char *interf_name, ModuleCreateFunc cf);
00241 
00245     cModuleType(const cModuleType& mi);
00246 
00250     virtual ~cModuleType();
00251 
00255     cModuleType& operator=(const cModuleType& mi);
00257 
00260 
00264     virtual const char *className() const {return "cModuleType";}
00265 
00270     virtual cObject *dup() const     {return new cModuleType(*this);}
00272 
00275 
00281     cModule *create(const char *name, cModule *parentmod, bool local=true);
00282 
00287     void buildInside(cModule *mod);
00288 
00305     cModule *createScheduleInit(char *name, cModule *parentmod);
00307 };
00308 
00309 
00310 //==========================================================================
00311 
00321 class SIM_API cLinkType : public cObject
00322 {
00323   private:
00324     cPar *(*delayfunc)();     // delay
00325     cPar *(*errorfunc)();     // bit error rate
00326     cPar *(*dataratefunc)();  // data rate
00327 
00328   public:
00331 
00337     cLinkType(const char *name, cPar *(*d)(), cPar *(*e)(), cPar *(*dr)() );
00338 
00342     cLinkType(const cLinkType& li);
00343 
00347     virtual ~cLinkType()    {}
00348 
00352     cLinkType& operator=(const cLinkType& o);
00354 
00357 
00361     virtual const char *className() const {return "cLinkType";}
00362 
00367     virtual cObject *dup() const     {return new cLinkType(*this);}
00369 
00372 
00377     cPar *createDelay() const;
00378 
00383     cPar *createError() const;
00384 
00389     cPar *createDataRate() const;
00391 };
00392 
00393 //==========================================================================
00394 
00402 class SIM_API cNetworkType : public cObject
00403 {
00404   public:  //FIXME: ????
00405     void (*setupfunc)();
00406 
00407   public:
00410 
00414     cNetworkType(const cNetworkType& n)  {setName(n.name());operator=(n);}
00415 
00419     cNetworkType(const char *name, void (*f)()) :
00420       cObject(name,(cObject *)&networks), setupfunc(f) {}
00421 
00425     virtual ~cNetworkType() {}
00426 
00430     cNetworkType& operator=(const cNetworkType&)  {copyNotSupported();return *this;}
00432 
00435 
00439     virtual const char *className() const {return "cNetworkType";}
00440 
00445     virtual cObject *dup() const     {return new cNetworkType(*this);}
00447 };
00448 
00449 //==========================================================================
00450 
00458 class SIM_API cFunctionType : public cObject
00459 {
00460   public:
00461     MathFunc f;   //FIXME: add getter funcs!!!
00462     int argcount;
00463   public:
00466 
00470     cFunctionType(const cFunctionType& ft)  {setName(ft.name());operator=(ft);}
00471 
00475     cFunctionType(const char *name, MathFunc f0, int argc) :
00476       cObject(name,(cObject *)&functions) {f=f0;argcount=argc;}
00477 
00481     virtual ~cFunctionType() {}
00482 
00486     cFunctionType& operator=(const cFunctionType&)  {copyNotSupported();return *this;}
00488 
00491 
00495     virtual const char *className() const {return "cFunctionType";}
00496 
00501     virtual cObject *dup() const  {return new cFunctionType(*this);}
00503 };
00504 
00505 cFunctionType *findfunctionbyptr(MathFunc f);
00506 
00507 //==========================================================================
00508 
00518 class SIM_API cClassRegister : public cObject
00519 {
00520     void *(*creatorfunc)();
00521 
00522   public:
00525 
00529     cClassRegister(const cClassRegister& c)  {setName(c.name());operator=(c);}
00530 
00534     cClassRegister(const char *name, void *(*f)()) :
00535       cObject(name,(cObject *)&classes), creatorfunc(f) {}
00536 
00540     virtual ~cClassRegister() {}
00541 
00545     cClassRegister& operator=(const cClassRegister&)  {copyNotSupported();return *this;}
00547 
00550 
00554     virtual const char *className() const {return "cClassRegister";}
00555 
00560     virtual cObject *dup() const  {return new cClassRegister(*this);}
00562 
00565 
00570     void *createOne() const  {return creatorfunc();}
00572 };
00573 
00579 
00589 SIM_API void *createOne(const char *classname);
00591 
00592 //==========================================================================
00593 
00601 class SIM_API cInspectorFactory : public cObject
00602 {
00603     TInspector *(*inspFactoryFunc)(cObject *,int,void *);
00604 
00605   public:
00608 
00612     cInspectorFactory(const cInspectorFactory& ifc)  {setName(ifc.name());operator=(ifc);}
00613 
00617     cInspectorFactory(const char *name, TInspector *(*f)(cObject *,int,void *));
00618 
00622     virtual ~cInspectorFactory() {}
00623 
00627     cInspectorFactory& operator=(const cInspectorFactory&)  {copyNotSupported();return *this;}
00629 
00632 
00636     virtual const char *className() const {return "cInspectorFactory";}
00637 
00642     virtual cObject *dup() const  {return new cInspectorFactory(*this);}
00644 
00647 
00654     TInspector *createInspectorFor(cObject *object,int type,void *data);
00656 };
00657 
00658 
00659 #endif
00660 
00661 

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