My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
NetDat.h
1 // $Id: NetDat.h,v 1.1.1.1 2009/07/06 23:57:25 eml Exp $
2 
3 #ifndef GCP_UTIL_NETDAT_H
4 #define GCP_UTIL_NETDAT_H
5 
15 #include <vector>
16 
17 namespace gcp {
18  namespace util {
19 
20  class NetStruct;
21  class NetUnion;
22 
23  class NetDat {
24  public:
25 
26  struct Info {
27  NetDat* datPtr_;
28  bool alloc_;
29 
30  Info() {
31  datPtr_ = 0;
32  alloc_ = false;
33  };
34 
35  Info(NetDat* datPtr, bool alloc) {
36  datPtr_ = datPtr;
37  alloc_ = alloc;
38  };
39 
40  Info(const Info& info) {
41  datPtr_ = info.datPtr_;
42  alloc_ = info.alloc_;
43  };
44  };
45 
49  NetDat();
50 
54  NetDat(const NetDat& netDat);
55  NetDat(NetDat& netDat);
56  void operator=(const NetDat& netDat);
57  void operator=(NetDat& netDat);
58 
62  virtual ~NetDat();
63 
67  virtual unsigned size();
68 
72  virtual std::vector<unsigned char>& getSerializedData();
73 
77  virtual void packSerializedData(unsigned char* bytes);
78 
82  virtual void deserialize(const std::vector<unsigned char>& bytes);
83 
87  unsigned maxSize();
88 
92  bool send(int fd);
93 
97  bool recv(int fd);
98 
99  protected:
100 
101  friend class NetStruct;
102  friend class NetUnion;
103 
107  std::vector<unsigned char> bytes_;
108 
112  unsigned maxSize_;
113 
117  virtual void resize(unsigned size);
118 
122  unsigned char* const getSerializedDataPtr();
123 
127  virtual void serialize();
128 
132  virtual void deserialize(const unsigned char* bytes)=0;
133 
137  virtual void checkSize(const std::vector<unsigned char>& bytes);
138 
139  }; // End class NetDat
140 
141  } // End namespace util
142 } // End namespace gcp
143 
144 
145 
146 #endif // End #ifndef GCP_UTIL_NETDAT_H
virtual void packSerializedData(unsigned char *bytes)
Definition: NetDat.cc:113
unsigned maxSize_
Definition: NetDat.h:112
Definition: compress.c:1548
bool recv(int fd)
Definition: NetDat.cc:185
NetDat()
Definition: NetDat.cc:15
virtual ~NetDat()
Definition: NetDat.cc:77
Definition: NetDat.h:26
Definition: NetStruct.h:21
virtual std::vector< unsigned char > & getSerializedData()
Definition: NetDat.cc:104
virtual void checkSize(const std::vector< unsigned char > &bytes)
Definition: NetDat.cc:137
virtual void serialize()
Definition: NetDat.cc:154
void operator=(const NetDat &netDat)
Definition: NetDat.cc:50
bool send(int fd)
Definition: NetDat.cc:164
virtual unsigned size()
Definition: NetDat.cc:82
std::vector< unsigned char > bytes_
Definition: NetDat.h:107
virtual void deserialize(const std::vector< unsigned char > &bytes)
Definition: NetDat.cc:149
virtual void resize(unsigned size)
Definition: NetDat.cc:95
Definition: NetDat.h:23
Definition: NetUnion.h:23
unsigned char *const getSerializedDataPtr()
Definition: NetDat.cc:124
unsigned maxSize()
Definition: NetDat.cc:87