Changeset 6:8dd4ca9966d0 in xplra for src/xplra/GetDataRefTask.cc
- Timestamp:
- 01/03/13 19:09:46 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/xplra/GetDataRefTask.cc
r4 r6 30 30 31 31 #include "GetDataRefTask.h" 32 #include "Protocol.h" 32 33 33 34 #include "xplcommon/Util.h" … … 35 36 //------------------------------------------------------------------------------ 36 37 38 using xplra::GetDataRefTask; 39 using xplra::GetIntDataRefTask; 40 using xplra::GetFloatDataRefTask; 41 using xplra::GetDoubleDataRefTask; 42 43 using xplcommon::DataStream; 44 45 using std::string; 46 47 //------------------------------------------------------------------------------ 48 49 GetDataRefTask* GetDataRefTask::create(uint8_t& result, DataStream& stream) 50 { 51 result = Protocol::RESULT_OK; 52 53 string name = stream.readString(); 54 uint8_t type = stream.readU8(); 55 if (!stream) return 0; 56 57 if (type==Protocol::TYPE_INT) { 58 return new GetIntDataRefTask(name); 59 } else if (type==Protocol::TYPE_FLOAT) { 60 return new GetFloatDataRefTask(name); 61 } else if (type==Protocol::TYPE_DOUBLE) { 62 return new GetDoubleDataRefTask(name); 63 } else if (type==Protocol::TYPE_FLOAT_ARRAY || 64 type==Protocol::TYPE_INT_ARRAY || 65 type==Protocol::TYPE_BYTE_ARRAY) 66 { 67 int length = stream.readS32(); 68 int offset = stream.readS32(); 69 if (!stream) return 0; 70 71 if (type==Protocol::TYPE_FLOAT_ARRAY) { 72 return new GetFloatArrayDataRefTask(name, length, offset); 73 } else if (type==Protocol::TYPE_INT_ARRAY) { 74 return new GetIntArrayDataRefTask(name, length, offset); 75 } else { 76 return new GetByteArrayDataRefTask(name, length, offset); 77 } 78 } else { 79 result = Protocol::RESULT_INVALID_TYPE; 80 return 0; 81 } 82 } 83 84 //------------------------------------------------------------------------------ 85 //------------------------------------------------------------------------------ 86 87 void GetIntDataRefTask::writeValue(DataStream& stream) 88 { 89 stream.writeS32(getValue()); 90 } 91 92 //------------------------------------------------------------------------------ 93 94 void GetFloatDataRefTask::writeValue(DataStream& stream) 95 { 96 stream.writeFloat(getValue()); 97 } 98 99 //------------------------------------------------------------------------------ 100 101 void GetDoubleDataRefTask::writeValue(DataStream& stream) 102 { 103 stream.writeDouble(getValue()); 104 } 37 105 38 106 //------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.