}
else if (requestAttributeMap["command"] == "ReleaseQueryEngine")
{
- pQueryEngine = (IQueryEngine *) stoi(
+ pQueryEngine = (IQueryEngine *) std::stoi(
requestAttributeMap["queryEngineId"]);
ReleaseQueryEngine(pQueryEngine);
{
int CQID = 0;
- pQueryEngine = (IQueryEngine *) stoi(
+ pQueryEngine = (IQueryEngine *) std::stoi(
requestAttributeMap["queryEngineId"]);
res = pQueryEngine->executeContextQuery(
}
else if (requestAttributeMap["command"] == "KillContextQuery")
{
- pQueryEngine = (IQueryEngine *) stoi(
+ pQueryEngine = (IQueryEngine *) std::stoi(
requestAttributeMap["queryEngineId"]);
- res = pQueryEngine->killContextQuery(stoi(requestAttributeMap["CQID"]));
+ res = pQueryEngine->killContextQuery(std::stoi(requestAttributeMap["CQID"]));
if (res != SSM_S_OK)
{
m_name = name;
m_type = type;
- m_pathSoftSensors = pathSoftSensors;
- m_pathSoftSensorsDescription = pathDescription;
+
+ if (pathSoftSensors.length() == 0)
+ {
+ SSM_CLEANUP_ASSERT(GetCurrentPath(&m_pathSoftSensors));
+ m_pathSoftSensors.append("/");
+ }
+ else
+ {
+ m_pathSoftSensors = pathSoftSensors;
+ }
+
+ if (pathDescription.length() == 0)
+ {
+ SSM_CLEANUP_ASSERT(GetCurrentPath(&m_pathSoftSensorsDescription));
+ m_pathSoftSensorsDescription.append("/");
+ m_pathSoftSensorsDescription.append(DEFAULT_PATH_SOFT_SENSORS);
+ }
+ else
+ {
+ m_pathSoftSensorsDescription = pathDescription;
+ }
+
SSM_CLEANUP_ASSERT(loadXMLFromFile(m_pathSoftSensorsDescription.c_str(), &dict));
SSM_CLEANUP_ASSERT(makeSSMResourceListForDictionaryData(dict, &m_lstSoftSensor));
SSMRESULT res = SSM_E_FAIL;
std::basic_ifstream< char > xmlFile(descriptionFilePath.c_str());
- if (descriptionFilePath.length() > 0 && xmlFile.fail())
- {
- //error while opening given path, return error
- SSM_CLEANUP_ASSERT(SSM_E_FAIL);
- }
-
- if (descriptionFilePath.length() == 0)
- {
- //No given path, try to open local Path
- std::string path;
- SSM_CLEANUP_ASSERT(GetCurrentPath(&path));
- path.append("/");
- path.append(DEFAULT_PATH_SOFT_SENSORS);
- xmlFile.open(path);
- }
-
//path loaded
if (!xmlFile.fail())
{
typedef void(*InitContext)(IN ICtxDelegate *);
InitContext InitializeContextFunction = NULL;
- if (m_pathSoftSensors.length() == 0)
- {
- SSM_CLEANUP_ASSERT(GetCurrentPath(&m_pathSoftSensors));
- }
-
- m_pathSoftSensors.append("/");
-
// load dll(so)
res = SSM_E_FAIL;
for (unsigned int i = 1; i <= SSM_MODEL_RETRY; ++i)
{
InitializeContextFunction = (InitContext)GetProcAddress(hModule, "InitializeContext");
}
-#else
- //sstream << "/data/data/com.example.javaproject/lib/lib" << modelName <<".so" << std::ends;
+#elif defined(LINUX)
sstream << m_pathSoftSensors << "lib" << softSensorName.c_str() << ".so" << std::ends;
void *hModule = NULL;
#endif
if (hModule == NULL)
{
- InitializeContextFunction = NULL;
- continue;
+ //load library failed. raise error
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+ //InitializeContextFunction = NULL;
+ //continue;
}
if (InitializeContextFunction != NULL)
{
for (size_t i = 0; i < attributeMap.size() / 3; i++)
{
- outputProperty["name"] = attributeMap.find(std::to_string(i * 3))->second;
- outputProperty["type"] = attributeMap.find(std::to_string(i * 3 + 1))->second;
- outputProperty["value"] = attributeMap.find(std::to_string(i * 3 + 2))->second;
+ outputProperty["name"] = attributeMap.find(toString(i * 3))->second;
+ outputProperty["type"] = attributeMap.find(toString(i * 3 + 1))->second;
+ outputProperty["value"] = attributeMap.find(toString(i * 3 + 2))->second;
ctxData.outputProperty.push_back(outputProperty);
}
//TODO: Temporally used for json parsing limitation
for (size_t i = 0; i < attributeMap.size() / 3; i++)
{
- outputProperty["name"] = attributeMap.find(std::to_string(i * 3))->second.front();
- outputProperty["type"] = attributeMap.find(std::to_string(i * 3 + 1))->second.front();
- outputProperty["value"] = attributeMap.find(std::to_string(i * 3 + 2))->second.front();
+ outputProperty["name"] = attributeMap.find(toString(i * 3))->second;
+ outputProperty["type"] = attributeMap.find(toString(i * 3 + 1))->second;
+ outputProperty["value"] = attributeMap.find(toString(i * 3 + 2))->second;
pSSMResource->outputProperty.push_back(outputProperty);
}
/////////////////////////////////////////////////////
std::shared_ptr<OC::OCResource> m_pResource;
IThreadClient *m_pResourceFinderClient;
IEvent *m_pEvent;
+
+ std::string toString(int t)
+ {
+ std::ostringstream os;
+ os << t;
+ return os.str();
+ }
};
enum RESOURCE_DISCOVER_STATE {RESOURCE_DISCOVER_REQUESTPROFILE, RESOURCE_DISCOVER_SETUP_RESOURCE};