Changeset 15:1c0347ed41c6 in xplra for src/client/c/hu/varadiistvan
- Timestamp:
- 01/28/13 18:37:00 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/client/c/hu/varadiistvan/xplra
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/client/c/hu/varadiistvan/xplra/XPlane.cc
r14 r15 132 132 //------------------------------------------------------------------------------ 133 133 134 int XPlane::getInt(const char* name) throw(Exception)134 void XPlane::getScalar(const char* name, uint8_t type) throw(Exception) 135 135 { 136 136 checkStream(); … … 138 138 stream->writeU8(Protocol::COMMAND_GET_SINGLE); 139 139 stream->writeString(name, strlen(name)); 140 stream->writeU8( Protocol::TYPE_INT);140 stream->writeU8(type); 141 141 if (!stream->flush()) checkStream(); 142 142 … … 144 144 checkStream(); 145 145 checkResult(result); 146 } 147 148 //------------------------------------------------------------------------------ 149 150 int XPlane::getInt(const char* name) throw(Exception) 151 { 152 getScalar(name, Protocol::TYPE_INT); 146 153 147 154 int value = stream->readS32(); 155 checkStream(); 156 return value; 157 } 158 159 //------------------------------------------------------------------------------ 160 161 float XPlane::getFloat(const char* name) throw(Exception) 162 { 163 getScalar(name, Protocol::TYPE_FLOAT); 164 165 float value = stream->readFloat(); 166 checkStream(); 167 return value; 168 } 169 170 //------------------------------------------------------------------------------ 171 172 double XPlane::getDouble(const char* name) throw(Exception) 173 { 174 getScalar(name, Protocol::TYPE_DOUBLE); 175 176 double value = stream->readDouble(); 148 177 checkStream(); 149 178 return value; -
src/client/c/hu/varadiistvan/xplra/XPlane.h
r14 r15 108 108 int getInt(const char* name) throw(Exception); 109 109 110 /** 111 * Get a float value. 112 */ 113 float getFloat(const char* name) throw(Exception); 114 115 /** 116 * Get a double value. 117 */ 118 double getDouble(const char* name) throw(Exception); 119 110 120 private: 111 121 /** … … 119 129 */ 120 130 void checkResult(uint8_t result) throw(ProtocolException); 131 132 /** 133 * Issue the command to get a single, scalar value. The result is 134 * also checked, but the value should be read by the caller. 135 */ 136 void getScalar(const char* name, uint8_t type) throw(Exception); 121 137 }; 122 138
Note:
See TracChangeset
for help on using the changeset viewer.