TTEthernet Model for INET Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Buffer.h
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 #ifndef __TTETHERNETMODELV2_BUFFER_H_
17 #define __TTETHERNETMODELV2_BUFFER_H_
18 
19 #include <omnetpp.h>
20 #include <EtherFrame_m.h>
21 #include <list>
22 
23 namespace TTEthernetModel {
24 
25 class TTEApplicationBase;
26 class TTEAPIPriv;
27 class Callback;
28 
47 class Buffer : public cSimpleModule
48 {
49  public:
53  ~Buffer();
54 
60  virtual void handleParameterChange(const char* parname);
61 
62  protected:
66  std::list<cGate*> destinationGates;
70  std::map<TTEApplicationBase*, Callback*> receiveCallbacks;
74  std::map<TTEApplicationBase*, Callback*> transmitCallbacks;
75 
79 // unsigned long ctMask;
83 // unsigned long ctMarker;
87 // unsigned long ctId;
88 
89  private:
93  void initializeStatistics();
94 
95  protected:
101  virtual void initialize(int stage);
102 
108  virtual int numInitStages() const;
109 
120  void handleMessage(cMessage *msg);
121 
129  virtual void enqueue(EtherFrame *newFrame);
130 
139  virtual EtherFrame* dequeue();
140 
144  void recordPacketSent();
145 
151  void setIsEmpty(bool empty);
152 
153  public:
162  EtherFrame* getFrame();
163 
171  void putFrame(EtherFrame* frame);
172 
183  void addReceiveCallback(Callback *cb, TTEApplicationBase *application);
184 
193 
204  void addTransmitCallback(Callback *cb, TTEApplicationBase *application);
205 
214 
215  protected:
219  static simsignal_t txPkSignal;
220 
224  static simsignal_t latencySignal;
225 
226 };
227 }
228 
229 #endif