OMNeT++ API 6.1
Discrete Event Simulation Library
ccommbuffer.h
1 //=========================================================================
2 // CCOMMBUFFER.H - part of
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //=========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 2003-2017 Andras Varga
10  Copyright (C) 2006-2017 OpenSim Ltd.
11 
12  This file is distributed WITHOUT ANY WARRANTY. See the file
13  `license' for details on this and other legal matters.
14 *--------------------------------------------------------------*/
15 
16 #ifndef __OMNETPP_CCOMMBUFFER_H
17 #define __OMNETPP_CCOMMBUFFER_H
18 
19 #include <cstdint>
20 #include "cobject.h"
21 #include "simtime.h"
22 
23 namespace omnetpp {
24 
25 class opp_string;
26 
27 
41 class SIM_API cCommBuffer : public cObject
42 {
43  public:
47  virtual ~cCommBuffer() {}
48 
56  virtual bool isBufferEmpty() const = 0;
57 
63  virtual void assertBufferEmpty() = 0;
65 
71  virtual void pack(char d) = 0;
75  virtual void pack(unsigned char d) = 0;
79  virtual void pack(bool d) = 0;
83  virtual void pack(short d) = 0;
87  virtual void pack(unsigned short d) = 0;
91  virtual void pack(int d) = 0;
95  virtual void pack(unsigned int d) = 0;
99  virtual void pack(long d) = 0;
103  virtual void pack(unsigned long d) = 0;
107  virtual void pack(long long d) = 0;
111  virtual void pack(unsigned long long d) = 0;
115  virtual void pack(float d) = 0;
119  virtual void pack(double d) = 0;
123  virtual void pack(long double d) = 0;
127  virtual void pack(const char *d) = 0;
131  virtual void pack(const opp_string& d) = 0;
135  virtual void pack(SimTime d) = 0;
137 
143  virtual void pack(const char *d, int size) = 0;
147  virtual void pack(const unsigned char *d, int size) = 0;
151  virtual void pack(const bool *d, int size) = 0;
155  virtual void pack(const short *d, int size) = 0;
159  virtual void pack(const unsigned short *d, int size) = 0;
163  virtual void pack(const int *d, int size) = 0;
167  virtual void pack(const unsigned int *d, int size) = 0;
171  virtual void pack(const long *d, int size) = 0;
175  virtual void pack(const unsigned long *d, int size) = 0;
179  virtual void pack(const long long *d, int size) = 0;
183  virtual void pack(const unsigned long long *d, int size) = 0;
187  virtual void pack(const float *d, int size) = 0;
191  virtual void pack(const double *d, int size) = 0;
195  virtual void pack(const long double *d, int size) = 0;
199  void pack(char **d, int size) {pack((const char **)d,size);}
203  virtual void pack(const char **d, int size) = 0;
207  virtual void pack(const opp_string *d, int size) = 0;
211  virtual void pack(const SimTime *d, int size) = 0;
213 
219  virtual void unpack(char& d) = 0;
223  virtual void unpack(unsigned char& d) = 0;
227  virtual void unpack(bool& d) = 0;
231  virtual void unpack(short& d) = 0;
235  virtual void unpack(unsigned short& d) = 0;
239  virtual void unpack(int& d) = 0;
243  virtual void unpack(unsigned int& d) = 0;
247  virtual void unpack(long& d) = 0;
251  virtual void unpack(unsigned long& d) = 0;
255  virtual void unpack(long long& d) = 0;
259  virtual void unpack(unsigned long long& d) = 0;
263  virtual void unpack(float& d) = 0;
267  virtual void unpack(double& d) = 0;
271  virtual void unpack(long double& d) = 0;
275  void unpack(char *&d) {unpack((const char *&)d);}
279  virtual void unpack(const char *&d) = 0;
283  virtual void unpack(opp_string& d) = 0;
287  virtual void unpack(SimTime& d) = 0;
289 
295  virtual void unpack(char *d, int size) = 0;
299  virtual void unpack(unsigned char *d, int size) = 0;
303  virtual void unpack(bool *d, int size) = 0;
307  virtual void unpack(short *d, int size) = 0;
311  virtual void unpack(unsigned short *d, int size) = 0;
315  virtual void unpack(int *d, int size) = 0;
319  virtual void unpack(unsigned int *d, int size) = 0;
323  virtual void unpack(long *d, int size) = 0;
327  virtual void unpack(unsigned long *d, int size) = 0;
331  virtual void unpack(long long *d, int size) = 0;
335  virtual void unpack(unsigned long long *d, int size) = 0;
339  virtual void unpack(float *d, int size) = 0;
343  virtual void unpack(double *d, int size) = 0;
347  virtual void unpack(long double *d, int size) = 0;
351  void unpack(char **d, int size) {unpack((const char **)d,size);}
355  virtual void unpack(const char **d, int size) = 0;
359  virtual void unpack(opp_string *d, int size) = 0;
363  virtual void unpack(SimTime *d, int size) = 0;
365 
371  bool packFlag(bool flag) {pack(flag); return flag;}
372 
376  bool checkFlag() {bool flag; unpack(flag); return flag;}
377 
381  virtual void packObject(cObject *obj);
382 
386  virtual cObject *unpackObject();
388 };
389 
390 } // namespace omnetpp
391 
392 #endif
393 
omnetpp::cCommBuffer::checkFlag
bool checkFlag()
Definition: ccommbuffer.h:376
omnetpp::cObject
cObject is a lightweight class which serves as the root of the OMNeT++ class hierarchy....
Definition: cobject.h:92
omnetpp::cCommBuffer::pack
void pack(char **d, int size)
Definition: ccommbuffer.h:199
omnetpp::cCommBuffer::unpack
void unpack(char **d, int size)
Definition: ccommbuffer.h:351
omnetpp::opp_string
Lightweight string class, used internally in some parts of OMNeT++.
Definition: opp_string.h:39
omnetpp::SimTime
int64_t-based, base-10 fixed-point simulation time.
Definition: simtime.h:66
omnetpp::cCommBuffer::unpack
void unpack(char *&d)
Definition: ccommbuffer.h:275
omnetpp::cCommBuffer::packFlag
bool packFlag(bool flag)
Definition: ccommbuffer.h:371
omnetpp::cCommBuffer
Buffer for the communications layer of parallel simulation.
Definition: ccommbuffer.h:41
omnetpp::cCommBuffer::~cCommBuffer
virtual ~cCommBuffer()
Definition: ccommbuffer.h:47