Changeset 10996 for code/branches/cpp11_v2/src/libraries/network
- Timestamp:
- Dec 30, 2015, 11:59:18 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/network/synchronisable/Synchronisable.h
r10769 r10996 38 38 #include <queue> 39 39 #include <set> 40 #include <type_traits> 40 41 41 42 #include "util/mbool.h" … … 203 204 }; 204 205 205 template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 206 { 206 namespace detail 207 { 208 template <class T, bool = std::is_enum<T>::value> 209 struct RealType; 210 template <class T> 211 struct RealType<T, true> { typedef typename std::underlying_type<T>::type type; }; 212 template <class T> 213 struct RealType<T, false> { typedef T type; }; 214 } 215 216 template <class T> 217 void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 218 { 219 typedef typename detail::RealType<T>::type RealType; 207 220 if (bidirectional) 208 221 { 209 syncList_.push_back(new SynchronisableVariableBidirectional< T>(variable, mode, cb));222 syncList_.push_back(new SynchronisableVariableBidirectional<RealType>(reinterpret_cast<RealType&>(variable), mode, cb)); 210 223 this->dataSize_ += syncList_.back()->getSize(state_); 211 224 } 212 225 else 213 226 { 214 syncList_.push_back(new SynchronisableVariable< T>(variable, mode, cb));227 syncList_.push_back(new SynchronisableVariable<RealType>(reinterpret_cast<RealType&>(variable), mode, cb)); 215 228 if ( this->state_ == mode ) 216 229 this->dataSize_ += syncList_.back()->getSize(state_); … … 218 231 } 219 232 220 template <class T> void Synchronisable::unregisterVariable(T& variable) 233 template <class T> 234 void Synchronisable::unregisterVariable(T& variable) 221 235 { 222 236 std::vector<SynchronisableVariableBase*>::iterator it = syncList_.begin(); … … 238 252 } 239 253 240 template <class T> void Synchronisable::registerVariable( std::set<T>& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 241 { 254 template <class T> 255 void Synchronisable::registerVariable( std::set<T>& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 256 { 257 typedef typename detail::RealType<T>::type RealType; 242 258 SynchronisableVariableBase* sv; 243 259 if (bidirectional) 244 sv = new SynchronisableVariableBidirectional<std::set< T>>(variable, mode, cb);260 sv = new SynchronisableVariableBidirectional<std::set<RealType>>(reinterpret_cast<std::set<RealType>&>(variable), mode, cb); 245 261 else 246 sv = new SynchronisableVariable<std::set< T>>(variable, mode, cb);262 sv = new SynchronisableVariable<std::set<RealType>>(reinterpret_cast<std::set<RealType>&>(variable), mode, cb); 247 263 syncList_.push_back(sv); 248 264 stringList_.push_back(sv);
Note: See TracChangeset
for help on using the changeset viewer.