- Timestamp:
- Dec 14, 2010, 8:54:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network5/src/libraries/network/synchronisable/Synchronisable.h
r7163 r7759 65 65 }; 66 66 } 67 68 typedef uint8_t VariableID;69 70 /**71 * @brief: stores information about a Synchronisable72 *73 * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)74 * in an emulated bitset.75 * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream76 * Bit 32 is a bool and defines whether the variables are stored in diff mode77 * Byte 5 to 8: objectID_78 * Byte 9 to 12: classID_79 * Byte 13 to 16: creatorID_80 */81 class _NetworkExport SynchronisableHeader{82 friend class SynchronisableHeaderLight;83 private:84 uint8_t* data_;85 public:86 SynchronisableHeader(uint8_t* data)87 { data_ = data; }88 inline static uint32_t getSize()89 { return 14; }90 inline uint16_t getDataSize() const91 { return (*(uint16_t*)data_) & 0x7FFF; } //only use the first 15 bits92 inline void setDataSize(uint16_t size)93 { *(uint16_t*)(data_) = (size & 0x7FFF) | (*(uint16_t*)(data_) & 0x8000 ); }94 inline bool isDiffed() const95 { return ( (*(uint16_t*)data_) & 0x8000 ) == 0x8000; }96 inline void setDiffed( bool b)97 { *(uint16_t*)(data_) = (b << 15) | (*(uint16_t*)(data_) & 0x7FFF ); }98 inline uint32_t getObjectID() const99 { return *(uint32_t*)(data_+2); }100 inline void setObjectID(uint32_t objectID_)101 { *(uint32_t*)(data_+2) = objectID_; }102 inline uint32_t getClassID() const103 { return *(uint32_t*)(data_+6); }104 inline void setClassID(uint32_t classID_)105 { *(uint32_t*)(data_+6) = classID_; }106 inline uint32_t getCreatorID() const107 { return *(uint32_t*)(data_+10); }108 inline void setCreatorID(uint32_t creatorID_)109 { *(uint32_t*)(data_+10) = creatorID_; }110 inline void operator=(SynchronisableHeader& h)111 { memcpy(data_, h.data_, getSize()); }112 };113 67 114 68 /** … … 121 75 * Byte 5 to 8: objectID_ 122 76 */ 123 class _NetworkExport SynchronisableHeaderLight{ 124 private: 77 class _NetworkExport SynchronisableHeaderLight 78 { 79 protected: 125 80 uint8_t* data_; 126 81 public: … … 141 96 inline void setObjectID(uint32_t objectID_) 142 97 { *(uint32_t*)(data_+2) = objectID_; } 98 inline void operator=(SynchronisableHeaderLight& h) 99 { memcpy(data_, h.data_, SynchronisableHeaderLight::getSize()); } 100 }; 101 102 typedef uint8_t VariableID; 103 104 /** 105 * @brief: stores information about a Synchronisable 106 * 107 * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize) 108 * in an emulated bitset. 109 * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream 110 * Bit 32 is a bool and defines whether the variables are stored in diff mode 111 * Byte 5 to 8: objectID_ 112 * Byte 9 to 12: classID_ 113 * Byte 13 to 16: creatorID_ 114 */ 115 class _NetworkExport SynchronisableHeader: public SynchronisableHeaderLight 116 { 117 public: 118 SynchronisableHeader(uint8_t* data): SynchronisableHeaderLight(data) 119 {} 120 inline static uint32_t getSize() 121 { return SynchronisableHeaderLight::getSize()+8; } 122 inline uint32_t getClassID() const 123 { return *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()); } 124 inline void setClassID(uint32_t classID_) 125 { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()) = classID_; } 126 inline uint32_t getCreatorID() const 127 { return *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4); } 128 inline void setCreatorID(uint32_t creatorID_) 129 { *(uint32_t*)(data_+SynchronisableHeaderLight::getSize()+4) = creatorID_; } 143 130 inline void operator=(SynchronisableHeader& h) 144 131 { memcpy(data_, h.data_, getSize()); } 145 132 }; 133 134 // inline void operator=(SynchronisableHeaderLight& h1, SynchronisableHeader& h2) 135 // { 136 // memcpy(h1.data_, h2.data_, h1.getSize()); 137 // } 146 138 147 139 /**
Note: See TracChangeset
for help on using the changeset viewer.