OMNeT++ Simulation Library  6.0.3
cGate Class Reference

#include <cgate.h>

Description

Represents a module gate.

cGate object are created and managed by modules; the user typically does not want to directly create or destroy cGate objects. However, they are important if a simple module algorithm needs to know about its surroundings.

Inheritance diagram for cGate:
cObject noncopyable

Public Types

enum  Type
 

Public Member Functions

Redefined cObject member functions
virtual const char * getName () const override
 
virtual const char * getFullName () const override
 
virtual void forEachChild (cVisitor *v) override
 
virtual std::string str () const override
 
virtual cObjectgetOwner () const override
 
virtual bool deliver (cMessage *msg, const SendOptions &options, simtime_t at)
 
Connecting the gate.
cChannelconnectTo (cGate *gate, cChannel *channel=nullptr, bool leaveUninitialized=false)
 
void disconnect ()
 
cChannelreconnectWith (cChannel *channel, bool leaveUninitialized=false)
 
Transmission state.
cChannelgetTransmissionChannel () const
 
cChannelfindTransmissionChannel () const
 
cChannelgetIncomingTransmissionChannel () const
 
cChannelfindIncomingTransmissionChannel () const
 
Gate connectivity.
cGategetPreviousGate () const
 
cGategetNextGate () const
 
int getConnectionId () const
 
cGategetPathStartGate () const
 
cGategetPathEndGate () const
 
bool pathContains (cModule *module, int gateId=-1)
 
bool isConnectedOutside () const
 
bool isConnectedInside () const
 
bool isConnected () const
 
bool isPathOK () const
 
Display string.
cDisplayStringgetDisplayString ()
 
void setDisplayString (const char *dispstr)
 
- Public Member Functions inherited from cObject
 cObject ()
 
 cObject (const cObject &other)=default
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
bool isName (const char *s) const
 
virtual std::string getFullPath () const
 
virtual std::string getClassAndFullName () const
 
virtual std::string getClassAndFullPath () const
 
const cObjectgetThisPtr () const
 
virtual std::ostream & printOn (std::ostream &os) const
 
virtual cObjectdup () const
 
virtual void parsimPack (cCommBuffer *buffer) const
 
virtual void parsimUnpack (cCommBuffer *buffer)
 
virtual bool isOwnedObject () const
 
virtual bool isSoftOwner () const
 
cObjectfindObject (const char *name, bool deep=true)
 
virtual cClassDescriptorgetDescriptor () const
 
void copyNotSupported () const
 

Information about the gate.

bool isGateHalf () const
 
cGategetOtherHalf () const
 
const char * getBaseName () const
 
const char * getNameSuffix () const
 
cPropertiesgetProperties () const
 
Type getType () const
 
cModulegetOwnerModule () const
 
int getId () const
 
bool isVector () const
 
int getBaseId () const
 
int getIndex () const
 
int getVectorSize () const
 
int size () const
 
cChannelgetChannel () const
 
void setDeliverImmediately (bool d)
 
bool getDeliverImmediately () const
 
void setDeliverOnReceptionStart (bool d)
 
bool getDeliverOnReceptionStart () const
 
static const char * getTypeName (Type t)
 

Additional Inherited Members

- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Member Enumeration Documentation

◆ Type

enum Type

Gate type

Member Function Documentation

◆ getName()

virtual const char* getName ( ) const
overridevirtual

Returns the name of the the gate without the gate index in brackets.

Reimplemented from cObject.

◆ getFullName()

virtual const char* getFullName ( ) const
overridevirtual

Returns the full name of the gate, which is getName() plus the index in square brackets (e.g. "out[4]"). Redefined to add the index.

Reimplemented from cObject.

◆ forEachChild()

virtual void forEachChild ( cVisitor v)
overridevirtual

Calls v->visit(this) for each contained object. See cObject for more details.

Reimplemented from cObject.

◆ str()

virtual std::string str ( ) const
overridevirtual

Produces a one-line description of the object's contents. See cObject for more details.

Reimplemented from cObject.

◆ getOwner()

virtual cObject* getOwner ( ) const
overridevirtual

Returns the owner module of this gate.

Reimplemented from cObject.

◆ deliver()

virtual bool deliver ( cMessage msg,
const SendOptions options,
simtime_t  at 
)
virtual

This function is called internally by the send() functions and channel classes' deliver() to deliver the message to its destination. A false return value means that the message object should be deleted by the caller. (This is used e.g. with parallel simulation, for messages leaving the partition.)

◆ connectTo()

cChannel* connectTo ( cGate gate,
cChannel channel = nullptr,
bool  leaveUninitialized = false 
)

Connects the gate to another gate, using the given channel object (if one is specified). This method can be used to manually create connections for dynamically created modules. After the call, this gate's getNextGate() method will return the specified gate, and the specified gate's getPreviousGate() methods will return this gate.

This method invokes callInitialize() on the channel object, unless the compound module containing this connection is not yet initialized (then it assumes that this channel will be initialized as part of the compound module initialization process.) To leave the channel uninitialized, specify true for the leaveUninitialized parameter.

If the gate is already connected, an error will occur. The gate argument cannot be nullptr, that is, you cannot use this function to disconnect a gate; use disconnect() for that.

Note: When you set channel parameters after channel initialization, make sure the channel class is implemented so that the changes take effect; i.e. the channel should either override and properly handle handleParameterChange(), or should not cache any values from parameters.

◆ disconnect()

void disconnect ( )

Disconnects the gate, and also deletes the associated channel object if one has been set. disconnect() must be invoked on the source gate of the connection, i.e. on which the connectTo() was invoked to create the connection. After the call, this gate's getNextGate() method and the "next" gate's getPreviousGate() method will both return nullptr.

The method has no effect if the gate is not connected.

◆ reconnectWith()

cChannel* reconnectWith ( cChannel channel,
bool  leaveUninitialized = false 
)

Disconnects the gate, then connects it again to the same gate, with the given channel object (if not nullptr). The gate must be connected.

See also
connectTo()

◆ isGateHalf()

bool isGateHalf ( ) const

Returns true if this gate is half of an "inout gate" (which is made up of an input and an output gate object). The name of such a gate includes the "$i" (for the input half) or "$o" (for the output half) suffix.

See also
getBaseName(), getNameSuffix(), getOtherHalf()

◆ getOtherHalf()

cGate* getOtherHalf ( ) const

If this gate is one half of an "inout gate" (see isGateHalf()), this method returns the other half. For example, for a gate named "eth$o[5]" it returns the gate "eth$i[5]" and vice versa; otherwise it returns nullptr.

◆ getBaseName()

const char* getBaseName ( ) const

Returns the gate name without index and potential "$i"/"$o" suffix.

◆ getNameSuffix()

const char* getNameSuffix ( ) const

Returns the suffix part of the gate name ("$i", "$o" or "").

◆ getProperties()

cProperties* getProperties ( ) const

Returns the properties for this gate. Properties cannot be changed at runtime.

◆ getType()

Type getType ( ) const
inline

Returns the gate's type, cGate::INPUT or cGate::OUTPUT. (It never returns cGate::INOUT, because a cGate object is always either the input or the output half of an inout gate ("name$i" or "name$o").

◆ getTypeName()

static const char* getTypeName ( Type  t)
static

Returns the given type as a string.

◆ getOwnerModule()

cModule* getOwnerModule ( ) const

Returns a pointer to the owner module of the gate.

◆ getId()

int getId ( ) const

Returns the gate ID, which uniquely identifies the gate within the module. IDs are guaranteed to be contiguous within a gate vector: module->gate(id+index) == module->gate(id)+index.

Gate IDs are stable: they are guaranteed not to change during simulation. (This is a new feature of OMNeT++ 4.0. In earlier releases, gate IDs could change when the containing gate vector was resized.)

Note: As of OMNeT++ 4.0, gate IDs are no longer small integers, and cannot be used for iterating over the gates of a module. Use cModule::GateIterator for iteration.

◆ isVector()

bool isVector ( ) const
inline

Returns true if the gate is part of a gate vector.

◆ getBaseId()

int getBaseId ( ) const

If the gate is part of a gate vector, returns the ID of the first element in the gate vector. Otherwise, it returns the gate's ID.

◆ getIndex()

int getIndex ( ) const

If the gate is part of a gate vector, returns the gate's index in the vector. For non-vector gates it throws an error.

◆ getVectorSize()

int getVectorSize ( ) const

If the gate is part of a gate vector, returns the size of the vector. For non-vector gates it throws an error.

See also
cModule::gateSize()

◆ size()

int size ( ) const
inline

Alias for getVectorSize().

◆ getChannel()

cChannel* getChannel ( ) const
inline

Returns the channel object attached to this gate, or nullptr if there is no channel. This is the channel between this gate and this->getNextGate(), that is, channels are stored on the "from" side of the connections.

◆ setDeliverImmediately()

void setDeliverImmediately ( bool  d)

This method may only be invoked on input gates of simple modules, and sets the packet reception mode. The two packet reception modes are the default a.k.a. at-end mode (arg=false), and immediate mode (arg=true). See getDeliverImmediately() for the description of their operations.

See also
getDeliverImmediately()

◆ getDeliverImmediately()

bool getDeliverImmediately ( ) const
inline

Indicates reception mode for messages with nonzero transmission duration, i.e. packets. The default setting is false.

In the default a.k.a. at-end mode (retval=false), packets delivered to this gate are handed to the module when they are completely received. That is, the arrival time of the message time will include both the propagation delay and the transmission duration. For transmission update packets (where cPacket::isUpdate()==true), this mode ensures that the module only receives the final transmission update (the original packet and intermediate transmission updates will be swallowed by the simulation kernel). The duration of the packet can be obtained from the cPacket::getDuration() method. The cPacket::getRemainingDuration() method will return zero.

In immediate mode (retval=true), packets and transmission updates will be delivered to the module "immediately", after applying the propagation delay only, and excluding the transmission duration. The remaining transmission duration can be obtained from the cPacket::getRemainingDuration() method. The total transmission duration of the packet can be obtained from the cPacket::getDuration() method. For non-update packets (cPacket::isUpdate()==false), the two methods will return the same value.

See also
setDeliverImmediately()

◆ setDeliverOnReceptionStart()

void setDeliverOnReceptionStart ( bool  d)
inline

Renamed to setDeliverImmediately() – please use the new name.

◆ getDeliverOnReceptionStart()

bool getDeliverOnReceptionStart ( ) const
inline

Renamed to getDeliverImmediately() – please use the new name.

◆ getTransmissionChannel()

cChannel* getTransmissionChannel ( ) const

Typically invoked on an output gate, this method returns the channel in the connection path that supports datarate (as determined by cChannel::isTransmissionChannel(); it is guaranteed that there can be at most one such channel per path). If there is no such channel, an error is thrown.

This method only checks the segment of the connection path that starts at this gate, so, for example, it is an error to invoke it on a simple module input gate.

Note: this method searches the connection path linearly, so at performance-critical places it may be better to cache its return value (provided that connections are not removed or created dynamically during simulation.)

See also
cChannel::isTransmissionChannel()

◆ findTransmissionChannel()

cChannel* findTransmissionChannel ( ) const

Like getTransmissionChannel(), but returns nullptr instead of throwing an error if there is no transmission channel in the path.

◆ getIncomingTransmissionChannel()

cChannel* getIncomingTransmissionChannel ( ) const

Typically invoked on an input gate, this method searches the reverse path (i.e. calls getPreviousGate() repeatedly) for the transmission channel. It is guaranteed that there can be at most one such channel per path. If no transmission channel is found, the method throws an error.

See also
getTransmissionChannel(), cChannel::isTransmissionChannel()

◆ findIncomingTransmissionChannel()

cChannel* findIncomingTransmissionChannel ( ) const

Like getIncomingTransmissionChannel(), but returns nullptr instead of throwing an error if there is no transmission channel in the reverse path.

◆ getPreviousGate()

cGate* getPreviousGate ( ) const
inline

Returns the previous gate in the series of connections (the path) that contains this gate, or nullptr if this gate is the first one in the path. (E.g. for a simple module output gate, this function will return nullptr.)

◆ getNextGate()

cGate* getNextGate ( ) const
inline

Returns the next gate in the series of connections (the path) that contains this gate, or nullptr if this gate is the last one in the path. (E.g. for a simple module input gate, this function will return nullptr.)

◆ getConnectionId()

int getConnectionId ( ) const
inline

Returns an ID that uniquely identifies the connection between this gate and the next gate in the path (see getNextGate()) during the lifetime of the simulation. (Disconnecting and then reconnecting the gate results in a new connection ID being assigned.) The method returns -1 if the gate is unconnected.

◆ getPathStartGate()

cGate* getPathStartGate ( ) const

Return the ultimate source of the series of connections (the path) that contains this gate.

◆ getPathEndGate()

cGate* getPathEndGate ( ) const

Return the ultimate destination of the series of connections (the path) that contains this gate.

◆ pathContains()

bool pathContains ( cModule module,
int  gateId = -1 
)

Determines if a given module is in the path containing this gate.

◆ isConnectedOutside()

bool isConnectedOutside ( ) const

Returns true if the gate is connected outside (i.e. to one of its sibling modules or to the parent module).

This means that for an input gate, getPreviousGate() must be non-nullptr; for an output gate, getNextGate() must be non-nullptr.

◆ isConnectedInside()

bool isConnectedInside ( ) const

Returns true if the gate (of a compound module) is connected inside (i.e. to one of its submodules).

This means that for an input gate, getNextGate() must be non-nullptr; for an output gate, getPreviousGate() must be non-nullptr.

◆ isConnected()

bool isConnected ( ) const

Returns true if the gate fully connected. For a compound module gate this means both isConnectedInside() and isConnectedOutside() are true; for a simple module, only isConnectedOutside() is checked.

◆ isPathOK()

bool isPathOK ( ) const

Returns true if the path (chain of connections) containing this gate starts and ends at a simple module.

◆ getDisplayString()

cDisplayString& getDisplayString ( )

Returns the display string for the gate, which controls the appearance of the connection arrow starting from gate. The display string is stored in the channel associated with the connection. If there is no channel, this call creates an installs a cIdealChannel to hold the display string.

◆ setDisplayString()

void setDisplayString ( const char *  dispstr)

Shortcut to getDisplayString().set(dispstr).


The documentation for this class was generated from the following file: