# ccommbuffer.h

    00001 //=========================================================================
    00002 //  CCOMMBUFFER.H - part of
    00003 //
    00004 //                  OMNeT++/OMNEST
    00005 //           Discrete System Simulation in C++
    00006 //
    00007 //   Written by:  Andras Varga, 2003
    00008 //
    00009 //=========================================================================
    00010
    00011 /*--------------------------------------------------------------*
    00012   Copyright (C) 2003-2005 Andras Varga
    00013   Monash University, Dept. of Electrical and Computer Systems Eng.
    00014   Melbourne, Australia
    00015
    00016   This file is distributed WITHOUT ANY WARRANTY. See the file
    00017   `license' for details on this and other legal matters.
    00018 *--------------------------------------------------------------*/
    00019
    00020 #ifndef __CCOMMBUFFER_H__
    00021 #define __CCOMMBUFFER_H__
    00022
    00023 #include "cpolymorphic.h"
    00024
    00025 // forward declaration:
    00026 class cCommBuffer;
    00027 class cObject;
    00028 class opp_string;
    00029
    00030
    00031
    00044 class SIM_API cCommBuffer : public cPolymorphic
    00045 {
    00046   public:
    00050     virtual ~cCommBuffer() {}
    00051
    00059     virtual bool isBufferEmpty() = 0;
    00060
    00066     virtual void assertBufferEmpty() = 0;
    00068
    00074     virtual void pack(char d) = 0;
    00078     virtual void pack(unsigned char d) = 0;
    00082     virtual void pack(bool d) = 0;
    00086     virtual void pack(short d) = 0;
    00090     virtual void pack(unsigned short d) = 0;
    00094     virtual void pack(int d) = 0;
    00098     virtual void pack(unsigned int d) = 0;
    00102     virtual void pack(long d) = 0;
    00106     virtual void pack(unsigned long d) = 0;
    00110     virtual void pack(float d) = 0;
    00114     virtual void pack(double d) = 0;
    00118     virtual void pack(long double d) = 0;
    00122     void pack(char *d)  {pack((const char *)d);}
    00126     virtual void pack(const char *d) = 0;
    00130     virtual void pack(opp_string& d) = 0;
    00132
    00138     virtual void pack(const char *d,  int size) = 0;
    00142     virtual void pack(unsigned char *d,  int size) = 0;
    00146     virtual void pack(bool *d, int size) = 0;
    00150     virtual void pack(short *d, int size) = 0;
    00154     virtual void pack(unsigned short *d, int size) = 0;
    00158     virtual void pack(int *d, int size) = 0;
    00162     virtual void pack(unsigned int *d, int size) = 0;
    00166     virtual void pack(long *d, int size) = 0;
    00170     virtual void pack(unsigned long *d, int size) = 0;
    00174     virtual void pack(float *d, int size) = 0;
    00178     virtual void pack(double *d, int size) = 0;
    00182     virtual void pack(long double *d, int size) = 0;
    00186     void pack(char **d, int size)  {pack((const char **)d,size);}
    00190     virtual void pack(const char **d, int size) = 0;
    00194     virtual void pack(opp_string *d, int size) = 0;
    00196
    00202     virtual void unpack(char& d) = 0;
    00206     virtual void unpack(unsigned char& d) = 0;
    00210     virtual void unpack(bool& d) = 0;
    00214     virtual void unpack(short& d) = 0;
    00218     virtual void unpack(unsigned short& d) = 0;
    00222     virtual void unpack(int& d) = 0;
    00226     virtual void unpack(unsigned int& d) = 0;
    00230     virtual void unpack(long& d) = 0;
    00234     virtual void unpack(unsigned long& d) = 0;
    00238     virtual void unpack(float& d) = 0;
    00242     virtual void unpack(double& d) = 0;
    00246     virtual void unpack(long double& d) = 0;
    00250     void unpack(char *&d)  {unpack((const char *&)d);}
    00254     virtual void unpack(const char *&d) = 0;
    00258     virtual void unpack(opp_string& d) = 0;
    00260
    00266     virtual void unpack(char *d, int size) = 0;
    00270     virtual void unpack(unsigned char *d, int size) = 0;
    00274     virtual void unpack(bool *d, int size) = 0;
    00278     virtual void unpack(short *d, int size) = 0;
    00282     virtual void unpack(unsigned short *d, int size) = 0;
    00286     virtual void unpack(int *d, int size) = 0;
    00290     virtual void unpack(unsigned int *d, int size) = 0;
    00294     virtual void unpack(long *d, int size) = 0;
    00298     virtual void unpack(unsigned long *d, int size) = 0;
    00302     virtual void unpack(float *d, int size) = 0;
    00306     virtual void unpack(double *d, int size) = 0;
    00310     virtual void unpack(long double *d, int size) = 0;
    00314     void unpack(char **d, int size)  {unpack((const char **)d,size);}
    00318     virtual void unpack(const char **d, int size) = 0;
    00322     virtual void unpack(opp_string *d, int size) = 0;
    00324
    00330     bool packFlag(bool flag)  {pack(flag); return flag;}
    00331
    00335     bool checkFlag() {bool flag; unpack(flag); return flag;}
    00336
    00340     virtual void packObject(cObject *obj);
    00341
    00345     virtual cObject *unpackObject();
    00347 };
    00348
    00349 #endif
    00350