TTEthernet Model for INET Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
BGBuffer.cc
Go to the documentation of this file.
1 //
2 // This program is free software: you can redistribute it and/or modify
3 // it under the terms of the GNU Lesser General Public License as published by
4 // the Free Software Foundation, either version 3 of the License, or
5 // (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public License
13 // along with this program. If not, see http://www.gnu.org/licenses/.
14 //
15 
16 #include "BGBuffer.h"
17 #include "TTEApplicationBase.h"
18 
19 namespace TTEthernetModel {
20 
21 Define_Module(BGBuffer);
22 
24 {
25  //Update displaystring
26  setIsEmpty(true);
27 }
28 
29 void BGBuffer::handleMessage(cMessage *msg)
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 }
56 
57 } //namespace