dcrud  0.0.0
Distributed data and services
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
ClassID.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <io/ByteBuffer.hpp>
4 
5 namespace dcrud {
6 
7  class ClassID {
8  public:
9 
10  enum Type {
11 
26 
28  };
29 
30  static const unsigned int SIZE = 4;
31 
32  ClassID( byte p1 = 0, byte p2 = 0, byte p3 = 0, byte clazz = 0 ) :
33  _p1 ( p1 ),
34  _p2 ( p2 ),
35  _p3 ( p3 ),
36  _class( clazz )
37  {}
38 
39  ClassID( const ClassID & right ) :
40  _p1 ( right._p1 ),
41  _p2 ( right._p2 ),
42  _p3 ( right._p3 ),
43  _class( right._class )
44  {}
45 
46  ClassID & operator = ( const ClassID & right ) {
47  _p1 = right._p1;
48  _p2 = right._p2;
49  _p3 = right._p3;
50  _class = right._class;
51  return *this;
52  }
53 
54  static void serialize( Type type, io::ByteBuffer & buffer );
55 
56  static ClassID unserialize( io::ByteBuffer & buffer );
57 
58  bool operator == ( const ClassID & right ) const {
59  return compareTo( right ) == 0;
60  }
61 
62  bool operator < ( const ClassID & right ) const {
63  return compareTo( right ) < 0;
64  }
65 
66  int compareTo( const ClassID & right ) const;
67 
68  Type getType() const;
69 
70  void serialize( io::ByteBuffer & buffer ) const;
71 
72  std::string toString( void ) const;
73 
74  private:
75 
76  byte _p1;
77  byte _p2;
78  byte _p3;
79  byte _class;
80  };
81 }
static void serialize(Type type, io::ByteBuffer &buffer)
int compareTo(const ClassID &right) const
bool operator==(const ClassID &right) const
Definition: ClassID.hpp:58
ClassID & operator=(const ClassID &right)
Definition: ClassID.hpp:46
Type getType() const
ClassID(const ClassID &right)
Definition: ClassID.hpp:39
static const unsigned int SIZE
Definition: ClassID.hpp:30
std::string toString(void) const
static ClassID unserialize(io::ByteBuffer &buffer)
bool operator<(const ClassID &right) const
Definition: ClassID.hpp:62
ClassID(byte p1=0, byte p2=0, byte p3=0, byte clazz=0)
Definition: ClassID.hpp:32