CARMA C++
NetVar.h
1 // $Id: NetVar.h,v 1.3 2013/07/09 17:12:00 eml Exp $
2 
3 #ifndef SZA_UTIL_NETVAR_H
4 #define SZA_UTIL_NETVAR_H
5 
15 #include "carma/szautil/DataType.h"
16 
17 #include "carma/szautil/NetDat.h"
18 
19 namespace sza {
20  namespace util {
21 
22  class NetStruct;
23 
24  class NetVar : public NetDat {
25  public:
26 
30  NetVar(sza::util::DataType::Type type, void* vPtr, unsigned nEl, bool convert=false);
31 
32  // Constructor for resizeable vectors
33 
34  NetVar(sza::util::DataType::Type type, void* vPtr, bool convert=false);
35 
39  virtual ~NetVar();
40 
44  NetVar(const NetVar& netVar);
45  NetVar(NetVar& netVar);
46 
50  void deserialize(const std::vector<unsigned char>& bytes);
51 
52  unsigned nEl();
53 
54  void checkSize(const std::vector<unsigned char>& bytes);
55 
56  unsigned char* getPtr();
57 
58  unsigned size();
59 
60  bool isResizeable();
61 
62  public:
63 
64  // The type of this variable
65 
66  sza::util::DataType::Type type_;
67 
68  // True if this object is resizeable
69 
70  bool resizeable_;
71 
72  // Pointer to where the start of the memory resides for this
73  // variable
74 
75  void* vPtr_;
76 
77  // Number of elements in this variable
78 
79  unsigned nEl_;
80 
81  // Size in bytes of each data type
82 
83  unsigned nBytePerEl_;
84 
85  // True if we should convert to network byte order on serialization
86 
87  bool convert_;
88 
92  void serialize();
93 
97  void deserialize(const unsigned char* bytes);
98 
102  void prependNel(unsigned char* dest);
103  void parseNel(const unsigned char* src);
104  void setNel(unsigned nEl);
105  unsigned sizeOfPrefix();
106  void resize();
107  bool convert();
108 
109  }; // End class NetVar
110 
111  } // End namespace util
112 } // End namespace sza
113 
114 
115 
116 #endif // End #ifndef SZA_UTIL_NETVAR_H
Tagged: Tue Jun 22 22:32:16 UTC 2004.
Tagged: Wed Jul 6 13:41:09 PDT 2005.