TTEthernet Model for INET Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TTEthernetModel::BGBuffer Class Reference

Base class for a background (best-effort) buffer class. More...

#include <BGBuffer.h>

Inheritance diagram for TTEthernetModel::BGBuffer:
TTEthernetModel::Buffer TTEthernetModel::BGQueueBuffer

Protected Member Functions

virtual void initialize ()
 Initializes the module. More...
 
virtual void handleMessage (cMessage *msg)
 Is called when a new Frame is received in the buffer. More...
 
- Protected Member Functions inherited from TTEthernetModel::Buffer
virtual void initialize (int stage)
 Initializes the module. More...
 
virtual int numInitStages () const
 Returns the numer of initializaiton stages this module needs. More...
 
void handleMessage (cMessage *msg)
 Is called when a new Frame is received in the buffer. More...
 
virtual void enqueue (EtherFrame *newFrame)
 Is called to store an EtherFrame in the buffer. More...
 
virtual EtherFrame * dequeue ()
 Is called to get an EtherFrame from the buffer. More...
 
void recordPacketSent ()
 Emits a statistics signal that a frame was sent from the buffer. More...
 
void setIsEmpty (bool empty)
 Sets the status of the Buffer to empty or non-empty. More...
 

Additional Inherited Members

- Public Member Functions inherited from TTEthernetModel::Buffer
 ~Buffer ()
 Destructor. More...
 
virtual void handleParameterChange (const char *parname)
 Indicates a parameter has changed. More...
 
EtherFrame * getFrame ()
 Wrapper function arround dequeue(). More...
 
void putFrame (EtherFrame *frame)
 Wrapper function arround enqueue(). More...
 
void addReceiveCallback (Callback *cb, TTEApplicationBase *application)
 Adds a receive callback for an application to the buffer. More...
 
CallbackgetReceiveCallback (TTEApplicationBase *application)
 Returns the currently registered receive callback for an application. More...
 
void addTransmitCallback (Callback *cb, TTEApplicationBase *application)
 Adds a transmit callback for an application to the buffer. More...
 
CallbackgetTransmitCallback (TTEApplicationBase *application)
 Returns the currently registered transmit callback for an application. More...
 
- Protected Attributes inherited from TTEthernetModel::Buffer
std::list< cGate * > destinationGates
 Stores the Gates to that the messages are delivered. More...
 
std::map< TTEApplicationBase
*, Callback * > 
receiveCallbacks
 Stores the callbacks that are executed when a frame is added to the buffer. More...
 
std::map< TTEApplicationBase
*, Callback * > 
transmitCallbacks
 Stores the callbacks that are executed when a frame is removed from the buffer. More...
 
- Static Protected Attributes inherited from TTEthernetModel::Buffer
static simsignal_t txPkSignal = SIMSIGNAL_NULL
 Signal that is emitted every time a frame was sent. More...
 
static simsignal_t latencySignal = SIMSIGNAL_NULL
 Signal that contains the latency until the frame enters the buffer. More...
 

Detailed Description

Base class for a background (best-effort) buffer class.

Use the implementation BGQueueBuffer.

See Also
BGQueueBuffer, Buffer

Definition at line 33 of file BGBuffer.h.

Member Function Documentation

void TTEthernetModel::BGBuffer::handleMessage ( cMessage *  msg)
protectedvirtual

Is called when a new Frame is received in the buffer.

Extends the handleMessage(cMessage *msg) method in Buffer class. An incoming frame is directly dequeued. No buffering!

Parameters
msgThe incoming message

Definition at line 29 of file BGBuffer.cc.

30 {
32 
33  if (msg->arrivedOn("in") && destinationGates.size() > 0)
34  {
35  cMessage *outgoingMessage = dequeue();
36 
37  if(outgoingMessage){
38  //Send Message
39  for (std::list<cGate*>::iterator destGate = destinationGates.begin(); destGate != destinationGates.end(); ++destGate)
40  {
41  sendDirect(outgoingMessage->dup(), *destGate);
42  }
43  if(gate("out")->isConnected()){
44  send(outgoingMessage->dup(),"out");
45  }
46  //TODO: Message was not really transmitted! Maybe we find a better moment to execute the callback
47  for(std::map<TTEApplicationBase*,Callback*>::const_iterator iter = transmitCallbacks.begin();
48  iter != transmitCallbacks.end(); ++iter){
49  iter->first->executeCallback(iter->second);
50  }
52  delete msg;
53  }
54  }
55 }
void TTEthernetModel::BGBuffer::initialize ( )
protectedvirtual

Initializes the module.

Definition at line 23 of file BGBuffer.cc.

24 {
25  //Update displaystring
26  setIsEmpty(true);
27 }

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