ccomponenttype.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __CCOMPONENTTYPE_H
00017 #define __CCOMPONENTTYPE_H
00018
00019 #include <string>
00020 #include <map>
00021 #include <set>
00022 #include "cpar.h"
00023 #include "cgate.h"
00024 #include "cownedobject.h"
00025 #include "clistener.h"
00026
00027
00028 NAMESPACE_BEGIN
00029
00030 class cModule;
00031 class cChannel;
00032 class cProperties;
00033 class cIdealChannel;
00034 class cDelayChannel;
00035 class cDatarateChannel;
00036 class cObjectFactory;
00037
00038
00048 class SIM_API cComponentType : public cNoncopyableOwnedObject
00049 {
00050 protected:
00051 std::string qualifiedName;
00052 bool availabilityTested;
00053 bool available;
00054
00055 typedef std::map<std::string, cParImpl *> StringToParMap;
00056 StringToParMap sharedParMap;
00057
00058 struct Less {bool operator()(cParImpl *a, cParImpl *b) const;};
00059 typedef std::set<cParImpl *, Less> ParImplSet;
00060 ParImplSet sharedParSet;
00061
00062 struct SignalDesc { SimsignalType type; cObjectFactory *objectType; bool isNullable; };
00063 std::map<simsignal_t,SignalDesc> signalsSeen;
00064
00065 protected:
00066 friend class cComponent;
00067 friend class cModule;
00068 friend class cChannel;
00069 friend class cPar;
00070 friend class cGate;
00071
00072
00073 virtual cProperties *getProperties() const = 0;
00074
00075
00076 virtual cProperties *getParamProperties(const char *paramName) const = 0;
00077
00078
00079 virtual cProperties *getGateProperties(const char *gateName) const = 0;
00080
00081
00082
00083
00084 virtual cProperties *getSubmoduleProperties(const char *submoduleName, const char *submoduleType) const = 0;
00085
00086
00087
00088
00089 virtual cProperties *getConnectionProperties(int connectionId, const char *channelType) const = 0;
00090
00091
00092 virtual const char *getImplementationClassName() const = 0;
00093
00094
00095 virtual void applyPatternAssignments(cComponent *component) = 0;
00096
00097
00098 cParImpl *getSharedParImpl(const char *key) const;
00099 void putSharedParImpl(const char *key, cParImpl *value);
00100
00101
00102 cParImpl *getSharedParImpl(cParImpl *p) const;
00103 void putSharedParImpl(cParImpl *p);
00104
00105
00106 cObjectFactory *lookupClass(const char *className) const;
00107
00108 public:
00109
00110 virtual std::string getPackageProperty(const char *name) const {return "";}
00111
00112
00113 virtual bool isAvailable();
00114
00115
00116 virtual bool isInnerType() const {return false;}
00117
00118
00119 virtual std::string getCxxNamespace() const {return "";}
00120
00121
00122 virtual void checkSignal(simsignal_t signalID, SimsignalType type, cObject *obj = NULL);
00123
00124 public:
00130 cComponentType(const char *qname=NULL);
00131
00135 virtual ~cComponentType();
00137
00156 virtual const char *getFullName() const {return qualifiedName.c_str();}
00158
00163 static cComponentType *find(const char *qname);
00164
00169 static cComponentType *get(const char *qname);
00170 };
00171
00172
00180 class SIM_API cModuleType : public cComponentType
00181 {
00182 friend class cModule;
00183 protected:
00187 virtual cModule *createModuleObject() = 0;
00188
00195
00196 virtual void addParametersAndGatesTo(cModule *mod) = 0;
00197
00204 virtual void setupGateVectors(cModule *mod) = 0;
00205
00215 virtual void buildInside(cModule *mod) = 0;
00216
00222 cModule *instantiateModuleClass(const char *classname);
00223
00224 public:
00230 cModuleType(const char *qname=NULL);
00232
00238 virtual bool isNetwork() const = 0;
00239
00243 virtual bool isSimple() const = 0;
00245
00248
00255 virtual cModule *create(const char *name, cModule *parentmod);
00256
00262 virtual cModule *create(const char *name, cModule *parentmod, int vectorsize, int index);
00263
00277 virtual cModule *createScheduleInit(const char *name, cModule *parentmod);
00279
00284 static cModuleType *find(const char *qname);
00285
00290 static cModuleType *get(const char *qname);
00291 };
00292
00293
00299 class SIM_API cChannelType : public cComponentType
00300 {
00301 protected:
00302 static cChannelType *idealChannelType;
00303 static cChannelType *delayChannelType;
00304 static cChannelType *datarateChannelType;
00305
00306 protected:
00310 virtual cChannel *createChannelObject() = 0;
00311
00316 virtual void addParametersTo(cChannel *channel) = 0;
00317
00322 cChannel *instantiateChannelClass(const char *classname);
00323
00324 public:
00327
00331 cChannelType(const char *qname=NULL);
00332
00346 virtual cChannel *create(const char *name);
00348
00353 static cChannelType *find(const char *qname);
00354
00359 static cChannelType *get(const char *qname);
00360
00365 static cChannelType *getIdealChannelType();
00366
00371 static cChannelType *getDelayChannelType();
00372
00377 static cChannelType *getDatarateChannelType();
00378
00382 static _OPPDEPRECATED cIdealChannel *createIdealChannel(const char *name);
00383
00387 static _OPPDEPRECATED cDelayChannel *createDelayChannel(const char *name);
00388
00392 static _OPPDEPRECATED cDatarateChannel *createDatarateChannel(const char *name);
00393 };
00394
00395 NAMESPACE_END
00396
00397
00398 #endif
00399
00400