projects
/
platform
/
upstream
/
iotivity.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported Upstream version 0.9.1
[platform/upstream/iotivity.git]
/
service
/
soft-sensor-manager
/
SSMCore
/
src
/
SSMInterface
/
SoftSensorManager.cpp
diff --git
a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.cpp
b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.cpp
index
0d0149e
..
0984c28
100644
(file)
--- a/
service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.cpp
+++ b/
service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.cpp
@@
-27,6
+27,7
@@
#include "SensorProcessor/ContextExecutor.h"
#include "SensorProcessor/ContextDataReader.h"
#include "SensorProcessor/ResourceFinder.h"
#include "SensorProcessor/ContextExecutor.h"
#include "SensorProcessor/ContextDataReader.h"
#include "SensorProcessor/ResourceFinder.h"
+#include "rapidxml/rapidxml.hpp"
inline bool operator<( const OID &lhs, const OID &rhs )
{
inline bool operator<( const OID &lhs, const OID &rhs )
{
@@
-43,7
+44,7
@@
void CSoftSensorManager::finalRelease()
{
}
{
}
-SSMRESULT CSoftSensorManager::initializeCore(
IN
std::string xmlDescription)
+SSMRESULT CSoftSensorManager::initializeCore(std::string xmlDescription)
{
SSMRESULT res = SSM_E_FAIL;
rapidxml::xml_document<> xmlDoc;
{
SSMRESULT res = SSM_E_FAIL;
rapidxml::xml_document<> xmlDoc;
@@
-58,69
+59,84
@@
SSMRESULT CSoftSensorManager::initializeCore(IN std::string xmlDescription)
std::string pathSoftSensors;
std::string pathDescription;
std::string pathSoftSensors;
std::string pathDescription;
-
xmlDoc.parse<0>((char *)xmlDescription.c_str()
);
+
std::string copyDescription = xmlDescription.c_str(
);
- root = xmlDoc.first_node();
-
- strKey = root->name();
-
- if (strKey != "SSMCore")
+ try
{
{
- return SSM_E_FAIL;
- }
+ xmlDoc.parse<0>((char *)copyDescription.c_str());
- for (itemSSMCore = root->first_node(); itemSSMCore; itemSSMCore = itemSSMCore->next_sibling())
- {
- strKey = itemSSMCore->name();
+ root = xmlDoc.first_node();
- if (
strKey == "Device"
)
+ if (
!root
)
{
{
- for (itemDevice = itemSSMCore->first_node(); itemDevice; itemDevice = itemDevice->next_sibling())
- {
- strKey = itemDevice->name();
+ throw rapidxml::parse_error("No Root Element", 0);
+ }
- if (strKey == "Name")
- {
- name = itemDevice->value();
- }
- else if (strKey == "Type")
- {
- type = itemDevice->value();
- }
- else
- {
- ;/*NULL*/
- }
- }
+ strKey = root->name();
+
+ if (strKey != "SSMCore")
+ {
+ throw rapidxml::parse_error("Invalid root tag name", 0);
}
}
- else if (strKey == "Config")
+
+ for (itemSSMCore = root->first_node(); itemSSMCore; itemSSMCore = itemSSMCore->next_sibling())
{
{
- for (itemDevice = itemSSMCore->first_node(); itemDevice; itemDevice = itemDevice->next_sibling())
- {
- strKey = itemDevice->name();
+ strKey = itemSSMCore->name();
- if (strKey == "SoftSensorRepository")
- {
- pathSoftSensors = itemDevice->value();
- }
- else if (strKey == "SoftSensorDescription")
+ if (strKey == "Device")
+ {
+ for (itemDevice = itemSSMCore->first_node(); itemDevice; itemDevice = itemDevice->next_sibling())
{
{
- pathDescription = itemDevice->value();
+ strKey = itemDevice->name();
+
+ if (strKey == "Name")
+ {
+ name = itemDevice->value();
+ }
+ else if (strKey == "Type")
+ {
+ type = itemDevice->value();
+ }
+ else
+ {
+ ;/*NULL*/
+ }
}
}
- else
+ }
+ else if (strKey == "Config")
+ {
+ for (itemDevice = itemSSMCore->first_node(); itemDevice; itemDevice = itemDevice->next_sibling())
{
{
- ;/*NULL*/
+ strKey = itemDevice->name();
+
+ if (strKey == "SoftSensorRepository")
+ {
+ pathSoftSensors = itemDevice->value();
+ }
+ else if (strKey == "SoftSensorDescription")
+ {
+ pathDescription = itemDevice->value();
+ }
+ else
+ {
+ ;/*NULL*/
+ }
}
}
}
}
+ else
+ {
+ ;/*NULL*/
+ }
}
}
- else
- {
- ;/*NULL*/
- }
+ }
+ catch (rapidxml::parse_error &e)
+ {
+ SSM_CLEANUP_ASSERT(SSM_E_INVALIDXML);
}
}
- SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase **)&m_pContextRepository));
SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ISensingEngine, (IBase **)&m_pSensingEngine));
SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ISensingEngine, (IBase **)&m_pSensingEngine));
+ SSM_CLEANUP_ASSERT(m_pSensingEngine->queryInterface(OID_IContextRepository,
+ (IBase **)&m_pContextRepository));
SSM_CLEANUP_ASSERT(m_pContextRepository->initRepository(name, type, pathSoftSensors,
pathDescription));
SSM_CLEANUP_ASSERT(m_pContextRepository->initRepository(name, type, pathSoftSensors,
pathDescription));
@@
-137,14
+153,22
@@
CLEANUP:
SSMRESULT CSoftSensorManager::startCore()
{
SSMRESULT CSoftSensorManager::startCore()
{
- //m_pSharingLayer->Start();
- return SSM_S_OK;
+ SSMRESULT res = SSM_E_FAIL;
+
+ SSM_CLEANUP_ASSERT(m_pContextRepository->startResourceFinder());
+
+CLEANUP:
+ return res;
}
SSMRESULT CSoftSensorManager::stopCore()
{
}
SSMRESULT CSoftSensorManager::stopCore()
{
- //m_pSharingLayer->Stop();
- return SSM_S_OK;
+ SSMRESULT res = SSM_E_FAIL;
+
+ SSM_CLEANUP_ASSERT(m_pContextRepository->stopResourceFinder());
+
+CLEANUP:
+ return res;
}
SSMRESULT CSoftSensorManager::terminateCore(bool factoryResetFlag)
}
SSMRESULT CSoftSensorManager::terminateCore(bool factoryResetFlag)
@@
-152,7
+176,7
@@
SSMRESULT CSoftSensorManager::terminateCore(bool factoryResetFlag)
return SSM_S_OK;
}
return SSM_S_OK;
}
-SSMRESULT CSoftSensorManager::createQueryEngine(
OUT
IQueryEngine **ppQueryEngine)
+SSMRESULT CSoftSensorManager::createQueryEngine(IQueryEngine **ppQueryEngine)
{
SSMRESULT res = SSM_E_FAIL;
IQueryEngineInternal *pQueryEngineInternal = NULL;
{
SSMRESULT res = SSM_E_FAIL;
IQueryEngineInternal *pQueryEngineInternal = NULL;
@@
-163,7
+187,7
@@
CLEANUP:
return res;
}
return res;
}
-unsigned long CSoftSensorManager::releaseQueryEngine(I
N I
QueryEngine *pQueryEngine)
+unsigned long CSoftSensorManager::releaseQueryEngine(IQueryEngine *pQueryEngine)
{
IQueryEngineInternal *pQueryEngineInternal = NULL;
pQueryEngineInternal = (IQueryEngineInternal *)(CQueryEngine *)pQueryEngine;
{
IQueryEngineInternal *pQueryEngineInternal = NULL;
pQueryEngineInternal = (IQueryEngineInternal *)(CQueryEngine *)pQueryEngine;
@@
-171,7
+195,7
@@
unsigned long CSoftSensorManager::releaseQueryEngine(IN IQueryEngine *pQueryEngi
return pQueryEngineInternal->release();
}
return pQueryEngineInternal->release();
}
-SSMRESULT CSoftSensorManager::getInstalledModelList(
OUT
std::vector<ISSMResource *> *pList)
+SSMRESULT CSoftSensorManager::getInstalledModelList(std::vector<ISSMResource *> *pList)
{
m_pSensingEngine->getList(pList);
{
m_pSensingEngine->getList(pList);
@@
-182,7
+206,7
@@
CSimpleMutex *g_mtxGlobalInstance = NULL;
std::map<OID, IBase *> *g_globalInstance = NULL;
IThreadPool *g_pThreadPool = NULL;
std::map<OID, IBase *> *g_globalInstance = NULL;
IThreadPool *g_pThreadPool = NULL;
-SSMRESULT CreateGlobalInstance(
IN const OID &objectID, OUT
IBase **ppvObject)
+SSMRESULT CreateGlobalInstance(
const OID &objectID,
IBase **ppvObject)
{
SSMRESULT res = SSM_E_NOINTERFACE;
{
SSMRESULT res = SSM_E_NOINTERFACE;
@@
-271,7
+295,7
@@
CLEANUP:
return res;
}
return res;
}
-SSMRESULT CreateInstance(
IN const OID &objectID, OUT
IBase **ppObject)
+SSMRESULT CreateInstance(
const OID &objectID,
IBase **ppObject)
{
SSMRESULT res = SSM_E_NOINTERFACE;
{
SSMRESULT res = SSM_E_NOINTERFACE;