7 #ifndef DAVID_SDK_CLIENT_JSON_RPC_H
8 #define DAVID_SDK_CLIENT_JSON_RPC_H
10 #include "davidSDK/IModules.h"
11 #include "davidSDK/TcpClient.h"
12 #include "davidSDK/json/json.h"
85 void ExecuteRpc(Json::Value& response,
const Json::Value& rpc);
98 void PrepareRpc(Json::Value& rpc,
const std::string method);
115 const Json::Value& v = jsonParams[paramName];
116 if (v.type() == Json::nullValue)
123 GetJsonParamValue(value, v);
125 catch (std::runtime_error&)
141 const Json::Value& v = jsonParams[paramName];
142 if (v.type() != Json::nullValue)
147 GetJsonParamValue(value, v);
148 optionalValue = value;
150 catch (std::runtime_error&)
158 void GetJsonParamValue(
int &result,
const Json::Value &v) { result=v.asInt(); }
159 void GetJsonParamValue(uint32_t &result,
const Json::Value &v) { result=v.asUInt(); }
160 void GetJsonParamValue(
bool &result,
const Json::Value &v) { result=v.asBool(); }
161 void GetJsonParamValue(
double &result,
const Json::Value &v) { result=v.asDouble(); }
162 void GetJsonParamValue(
float &result,
const Json::Value &v) { result=(float)v.asDouble(); }
163 void GetJsonParamValue(std::string &result,
const Json::Value &v) { result=v.asString(); }
166 void GetJsonParamValue(std::vector<T> &result,
const Json::Value &v)
168 if (!v.isArray())
throw std::runtime_error(
"not an array");
170 result.resize(v.size());
171 for (Json::Value::UInt i=0; i<v.size(); ++i) GetJsonParamValue(result[i], v[i]);
176 IStructuredLightScanner* m_sls;
177 IShapeFusion* m_fusion;
179 ITurntable* m_turntable;
180 IMainWindow* m_mainWindow;
183 Json::StyledWriter m_writer;
184 Json::Reader m_reader;
193 #endif // DAVID_SDK_CLIENT_JSON_RPC_H