Changeset 22:e29d792d1b5d in xplra for src/client/c/hu
- Timestamp:
- 02/04/13 18:47:38 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/client/c/hu/varadiistvan/xplra
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/client/c/hu/varadiistvan/xplra/MultiBuffer.cc
r21 r22 46 46 using xplra::Protocol; 47 47 48 using std::vector; 48 49 using std::string; 49 50 using std::min; … … 231 232 //------------------------------------------------------------------------------ 232 233 233 MultiBuffer::MultiBuffer(XPlane& xplane) throw() : 234 MultiBuffer::MultiBuffer(XPlane& xplane, uint8_t registerCommand, 235 uint8_t unregisterCommand) throw() : 234 236 data(0), 235 237 xplane(xplane), 236 unregisterCommand(0), 238 registerCommand(registerCommand), 239 unregisterCommand(unregisterCommand), 237 240 registeredID(-1) 238 241 { … … 329 332 xplane.checkStream(); 330 333 331 unregisterCommand = doRegister(); 334 xplane.stream->writeU8(registerCommand); 335 xplane.stream->writeU32(dataRefs.size()); 336 337 for(vector<DataRef>::const_iterator i = dataRefs.begin(); 338 i!=dataRefs.end(); ++i) 339 { 340 const DataRef& dataRef = *i; 341 xplane.stream->writeString(dataRef.name); 342 xplane.stream->writeU8(dataRef.type); 343 if (dataRef.isArray()) { 344 xplane.stream->writeS32(dataRef.length); 345 xplane.stream->writeS32(dataRef.offset); 346 } 347 } 332 348 333 349 xplane.stream->flush(); -
src/client/c/hu/varadiistvan/xplra/MultiBuffer.h
r19 r22 133 133 134 134 /** 135 * The command to use for registering the buffer. 136 */ 137 uint8_t registerCommand; 138 139 /** 135 140 * The command to unregister the buffer. 136 141 */ … … 147 152 * Construct an empty buffer for the given XPlane instance. 148 153 */ 149 MultiBuffer(XPlane& xplane) throw(); 154 MultiBuffer(XPlane& xplane, uint8_t registerCommand, 155 uint8_t unregisterCommand) throw(); 150 156 151 157 public: … … 452 458 453 459 protected: 454 /**455 * Perform the first part of the registration depending on the456 * actual type.457 */458 virtual uint8_t doRegister() throw(Exception) = 0;459 460 460 /** 461 461 * Perform the main part of the execution if the buffer is -
src/client/c/hu/varadiistvan/xplra/MultiGetter.cc
r19 r22 50 50 //------------------------------------------------------------------------------ 51 51 52 MultiGetter::MultiGetter(XPlane& xplane) throw() : 53 MultiBuffer(xplane, Protocol::COMMAND_REGISTER_GET_MULTI, 54 Protocol::COMMAND_UNREGISTER_GET_MULTI) 55 { 56 } 57 58 //------------------------------------------------------------------------------ 59 52 60 inline void MultiGetter::read(const DataRef& dataRef) throw(Exception) 53 61 { … … 79 87 } 80 88 } 81 }82 83 //------------------------------------------------------------------------------84 85 uint8_t MultiGetter::doRegister() throw(Exception)86 {87 xplane.stream->writeU8(Protocol::COMMAND_REGISTER_GET_MULTI);88 xplane.stream->writeU32(dataRefs.size());89 90 for(vector<DataRef>::const_iterator i = dataRefs.begin();91 i!=dataRefs.end(); ++i)92 {93 const DataRef& dataRef = *i;94 xplane.stream->writeString(dataRef.name);95 xplane.stream->writeU8(dataRef.type);96 if (dataRef.isArray()) {97 xplane.stream->writeS32(dataRef.length);98 xplane.stream->writeS32(dataRef.offset);99 }100 }101 102 return Protocol::COMMAND_UNREGISTER_GET_MULTI;103 89 } 104 90 -
src/client/c/hu/varadiistvan/xplra/MultiGetter.h
r19 r22 52 52 protected: 53 53 /** 54 * @see MultiBuffer::doRegister55 */56 virtual uint8_t doRegister() throw(Exception);57 58 /**59 54 * @see MultiBuffer::doExecute 60 55 */ … … 75 70 76 71 //------------------------------------------------------------------------------ 77 // Inline definitions78 //------------------------------------------------------------------------------79 80 inline MultiGetter::MultiGetter(XPlane& xplane) throw() :81 MultiBuffer(xplane)82 {83 }84 85 //------------------------------------------------------------------------------86 72 87 73 } /* namespace hu::varadiistvan::xplra */ } /* namespace hu::varadiistvan */ } /* namespace hu */ -
src/client/c/hu/varadiistvan/xplra/MultiSetter.cc
r21 r22 47 47 48 48 //------------------------------------------------------------------------------ 49 50 MultiSetter::MultiSetter(XPlane& xplane) throw() : 51 MultiBuffer(xplane, Protocol::COMMAND_REGISTER_SET_MULTI, 52 Protocol::COMMAND_UNREGISTER_SET_MULTI) 53 { 54 } 55 49 56 //------------------------------------------------------------------------------ 50 57 … … 76 83 } 77 84 } 78 }79 80 //------------------------------------------------------------------------------81 82 uint8_t MultiSetter::doRegister() throw(Exception)83 {84 // FIXME: only the commands differ from those of MultiGetter85 xplane.stream->writeU8(Protocol::COMMAND_REGISTER_SET_MULTI);86 xplane.stream->writeU32(dataRefs.size());87 88 for(vector<DataRef>::const_iterator i = dataRefs.begin();89 i!=dataRefs.end(); ++i)90 {91 const DataRef& dataRef = *i;92 xplane.stream->writeString(dataRef.name);93 xplane.stream->writeU8(dataRef.type);94 if (dataRef.isArray()) {95 xplane.stream->writeS32(dataRef.length);96 xplane.stream->writeS32(dataRef.offset);97 }98 }99 100 return Protocol::COMMAND_UNREGISTER_SET_MULTI;101 85 } 102 86 -
src/client/c/hu/varadiistvan/xplra/MultiSetter.h
r21 r22 52 52 protected: 53 53 /** 54 * @see MultiBuffer::doRegister55 */56 virtual uint8_t doRegister() throw(Exception);57 58 /**59 54 * @see MultiBuffer::doExecute 60 55 */ … … 75 70 76 71 //------------------------------------------------------------------------------ 77 // Inline definitions78 //------------------------------------------------------------------------------79 80 inline MultiSetter::MultiSetter(XPlane& xplane) throw() :81 MultiBuffer(xplane)82 {83 }84 85 //------------------------------------------------------------------------------86 72 87 73 } /* namespace hu::varadiistvan::xplra */ } /* namespace hu::varadiistvan */ } /* namespace hu */
Note:
See TracChangeset
for help on using the changeset viewer.