- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/libraries/network/synchronisable/Synchronisable.h
r5929 r6412 66 66 67 67 /** 68 * @brief: stores information about a Synchronisable 69 * 68 * @brief: stores information about a Synchronisable 69 * 70 70 * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize) 71 71 * in an emulated bitset. … … 132 132 inline unsigned int getPriority() const { return this->objectFrequency_;} 133 133 inline uint8_t getSyncMode() const { return this->objectMode_; } 134 134 135 135 void setSyncMode(uint8_t mode); 136 136 … … 138 138 Synchronisable(BaseObject* creator); 139 139 template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false); 140 //template <class T> void unregisterVariable(T& var); 140 141 141 void setPriority(unsigned int freq){ objectFrequency_ = freq; } 142 142 … … 148 148 bool isMyData(uint8_t* mem); 149 149 bool doSync(int32_t id, uint8_t mode=0x0); 150 150 151 151 inline void setObjectID(uint32_t id){ this->objectID_ = id; objectMap_[this->objectID_] = this; } 152 152 inline void setClassID(uint32_t id){ this->classID_ = id; } … … 167 167 }; 168 168 169 // ================= Specialisation declarations170 171 // template <> _NetworkExport void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);172 template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);173 template <> _NetworkExport void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);174 template <> _NetworkExport void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);175 template <> _NetworkExport void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);176 template <> _NetworkExport void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);177 template <> _NetworkExport void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);178 template <> _NetworkExport void Synchronisable::registerVariable( Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);179 template <> _NetworkExport void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);180 template <> _NetworkExport void Synchronisable::registerVariable( Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);181 template <> _NetworkExport void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);182 template <> _NetworkExport void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);183 template <> _NetworkExport void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);184 185 169 template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 186 170 { 187 171 if (bidirectional) 188 172 { 189 syncList.push_back(new SynchronisableVariableBidirectional< constT>(variable, mode, cb));173 syncList.push_back(new SynchronisableVariableBidirectional<T>(variable, mode, cb)); 190 174 this->dataSize_ += syncList.back()->getSize(state_); 191 175 } 192 176 else 193 177 { 194 syncList.push_back(new SynchronisableVariable< constT>(variable, mode, cb));178 syncList.push_back(new SynchronisableVariable<T>(variable, mode, cb)); 195 179 if ( this->state_ == mode ) 196 180 this->dataSize_ += syncList.back()->getSize(state_); 197 181 } 198 182 } 199 183 184 template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional); 200 185 201 186 202 // template <class T> void Synchronisable::unregisterVariable(T& var){203 // std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin();204 // while(it!=syncList.end()){205 // if( ((*it)->getReference()) == &var ){206 // delete (*it);207 // syncList.erase(it);208 // return;209 // }210 // else211 // it++;212 // }213 // bool unregistered_nonexistent_variable = false;214 // assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:215 // // the variable has not been registered before216 // }217 218 219 187 } 220 188
Note: See TracChangeset
for help on using the changeset viewer.