16 #ifndef __OMNETPP_CGATE_H 17 #define __OMNETPP_CGATE_H 22 #include "cstringpool.h" 23 #include "opp_string.h" 24 #include "simtime_t.h" 25 #include "cexception.h" 37 class cDatarateChannel;
44 #define GATEID_LBITS 20 45 #define GATEID_HBITS (8*sizeof(int)-GATEID_LBITS) // default 12 46 #define GATEID_HMASK ((~0U)<<GATEID_LBITS) // default 0xFFF00000 47 #define GATEID_LMASK (~GATEID_HMASK) // default 0x000FFFFF 49 #define MAX_VECTORGATES ((1<<(GATEID_HBITS-1))-2) // default 2046 50 #define MAX_SCALARGATES ((1<<(GATEID_LBITS-1))-2) // default ~500000 51 #define MAX_VECTORGATESIZE ((1<<(GATEID_LBITS-1))-1) // default ~500000 66 friend class cModuleGates;
67 friend class cPlaceholderModule;
88 Name(
const char *name,
Type type);
89 bool operator<(
const Name& other)
const;
108 Desc() {owner=
nullptr; vectorSize=-1; name=
nullptr; input.gate=output.gate=
nullptr;}
109 bool inUse()
const {
return name!=
nullptr;}
110 Type getType()
const {
return name->type;}
111 bool isVector()
const {
return vectorSize>=0;}
112 const char *nameFor(
Type t)
const {
return (t==INOUT||name->type!=INOUT) ? name->name.c_str() : t==INPUT ? name->namei.c_str() : name->nameo.c_str();}
113 int indexOf(
const cGate *g)
const {
return (g->pos>>2)==-1 ? 0 : g->pos>>2;}
114 bool deliverOnReceptionStart(
const cGate *g)
const {
return g->pos&2;}
115 Type getTypeOf(
const cGate *g)
const {
return (g->pos&1)==0 ? INPUT : OUTPUT;}
116 bool isInput(
const cGate *g)
const {
return (g->pos&1)==0;}
117 bool isOutput(
const cGate *g)
const {
return (g->pos&1)==1;}
118 int gateSize()
const {
return vectorSize>=0 ? vectorSize : 1;}
119 void setInputGate(
cGate *g) {ASSERT(getType()!=OUTPUT && !isVector()); input.gate=g; g->desc=
this; g->pos=(-(1<<2));}
120 void setOutputGate(
cGate *g) {ASSERT(getType()!=INPUT && !isVector()); output.gate=g; g->desc=
this; g->pos=(-(1<<2))|1;}
121 void setInputGate(
cGate *g,
int index) {ASSERT(getType()!=OUTPUT && isVector()); input.gatev[index]=g; g->desc=
this; g->pos=(index<<2);}
122 void setOutputGate(
cGate *g,
int index) {ASSERT(getType()!=INPUT && isVector()); output.gatev[index]=g; g->desc=
this; g->pos=(index<<2)|1;}
123 static int capacityFor(
int size) {
return size<8 ? (size+1)&~1 : size<32 ? (size+3)&~3 : size<256 ? (size+15)&~15 : (size+63)&~63;}
136 static int lastConnectionId;
146 static void clearFullnamePool();
149 void installChannel(
cChannel *chan);
152 void checkChannels()
const;
154 #ifdef SIMFRONTEND_SUPPORT 156 virtual bool hasChangedSince(int64_t lastRefreshSerial);
165 virtual const char *getName()
const override;
172 virtual const char *getFullName()
const override;
178 virtual void forEachChild(
cVisitor *v)
override;
184 virtual std::string str()
const override;
189 virtual cObject *getOwner()
const override;
252 bool isGateHalf()
const;
259 cGate *getOtherHalf()
const;
264 const char *getBaseName()
const;
269 const char *getNameSuffix()
const;
287 static const char *getTypeName(
Type t);
292 cModule *getOwnerModule()
const;
318 int getBaseId()
const;
337 int size()
const {
return getVectorSize();}
356 void setDeliverOnReceptionStart(
bool d);
388 cChannel *getTransmissionChannel()
const;
394 cChannel *findTransmissionChannel()
const;
404 cChannel *getIncomingTransmissionChannel()
const;
411 cChannel *findIncomingTransmissionChannel()
const;
444 cGate *getPathStartGate()
const;
450 cGate *getPathEndGate()
const;
455 bool pathContains(
cModule *module,
int gateId=-1);
464 bool isConnectedOutside()
const;
473 bool isConnectedInside()
const;
480 bool isConnected()
const;
486 bool isPathOK()
const;
502 void setDisplayString(
const char *dispstr);
Lightweight string class, used internally in some parts of OMNeT++.
Definition: opp_string.h:39
The message class in OMNeT++. cMessage objects may represent events, messages, jobs or other entities...
Definition: cmessage.h:95
int getVectorSize() const
Definition: cgate.h:332
Type getType() const
Definition: cgate.h:282
Represents a module gate.
Definition: cgate.h:63
Root of the OMNeT++ class hierarchy. cObject is a lightweight class without any data members...
Definition: cobject.h:58
int64_t-based, base-10 fixed-point simulation time.
Definition: simtime.h:66
cGate * getNextGate() const
Definition: cgate.h:429
int size() const
Definition: cgate.h:337
bool getDeliverOnReceptionStart() const
Definition: cgate.h:365
This class represents modules in the simulation.
Definition: cmodule.h:47
bool isVector() const
Definition: cgate.h:312
Enables traversing the tree of (cObject-rooted) simulation objects.
Definition: cvisitor.h:56
Utility class, to make it impossible to call the operator= and copy constructor of any class derived ...
Definition: cobject.h:311
Definition: cabstracthistogram.h:21
int getIndex() const
Definition: cgate.h:324
A collection of properties (cProperty).
Definition: cproperties.h:34
cChannel * getChannel() const
Definition: cgate.h:344
Represents a display string.
Definition: cdisplaystring.h:58
cGate * getPreviousGate() const
Definition: cgate.h:422
Base class for channels.
Definition: cchannel.h:34
Type
Definition: cgate.h:73
int getConnectionId() const
Definition: cgate.h:438