*/
inline int IsEqualOID(const OID &oid1, const OID &oid2)
{
- return (
- ((unsigned long *) &oid1)[0] == ((unsigned long *) &oid2)[0] &&
- ((unsigned long *) &oid1)[1] == ((unsigned long *) &oid2)[1] &&
- ((unsigned long *) &oid1)[2] == ((unsigned long *) &oid2)[2] &&
- ((unsigned long *) &oid1)[3] == ((unsigned long *) &oid2)[3]);
+ return (( oid1.data1 == oid2.data1) &&
+ ( oid1.data2 == oid2.data2) &&
+ ( oid1.data3 == oid2.data3) &&
+ ( oid1.data4[0] == oid2.data4[0]) &&
+ ( oid1.data4[1] == oid2.data4[1]) &&
+ ( oid1.data4[2] == oid2.data4[2]) &&
+ ( oid1.data4[3] == oid2.data4[3]) &&
+ ( oid1.data4[4] == oid2.data4[4]) &&
+ ( oid1.data4[5] == oid2.data4[5]) &&
+ ( oid1.data4[6] == oid2.data4[6]) &&
+ ( oid1.data4[7] == oid2.data4[7]));
}
/**
void CContextModel::registerSSMResource(IN ActivationType activationType, IN int targetDeviceDataId,
IN ISSMResource *pSSMResource)
{
- int *pData = NULL;
+ intptr_t *pData = NULL;
m_mtxActivationCount.lock();
switch (activationType)
case ACTIVATION_TYPE_SUBSCRIBE:
if (m_mapSubscribedDevice.find(targetDeviceDataId) == m_mapSubscribedDevice.end())
{
- pData = new int[2];
+ pData = new intptr_t [2];
pData[0] = STATUS_ACTIVATE;
- pData[1] = (int)pSSMResource;
+ pData[1] = reinterpret_cast<intptr_t>(pSSMResource);
m_pTasker->addTask(this, (void *)pData);
m_mapSubscribedDevice[targetDeviceDataId] = 1;
}
{
if (m_mapGetDevice.find(targetDeviceDataId) == m_mapGetDevice.end())
{
- pData = new int[2];
+ pData = new intptr_t[2];
pData[0] = STATUS_START_READ_VALUE;
- pData[1] = (int)pSSMResource;
+ pData[1] = reinterpret_cast<intptr_t>(pSSMResource);
m_pTasker->addTask(this, (void *)pData);
m_mapGetDevice[targetDeviceDataId] = 1;
}
void CContextModel::unregisterSSMResource(IN ActivationType activationType,
IN int targetDeviceDataId, IN ISSMResource *pSSMResource)
{
- int *pData = NULL;
+ intptr_t *pData = NULL;
m_mtxActivationCount.lock();
switch (activationType)
{
if (--m_mapSubscribedDevice[targetDeviceDataId] == 0)
{
- pData = new int[2];
+ pData = new intptr_t [2];
pData[0] = STATUS_DEACTIVATE;
- pData[1] = (int)pSSMResource;
+ pData[1] = reinterpret_cast<intptr_t>(pSSMResource);
m_pTasker->addTask(this, (void *)pData);
m_mapSubscribedDevice.erase(targetDeviceDataId);
}
{
if (--m_mapGetDevice[targetDeviceDataId] == 0)
{
- pData = new int[2];
+ pData = new intptr_t [2];
pData[0] = STATUS_STOP_READ_VALUE;
- pData[1] = (int)pSSMResource;
+ pData[1] = reinterpret_cast<intptr_t>(pSSMResource);
m_pTasker->addTask(this, (void *)pData);
}
}
void CContextModel::onExecute(IN void *pArg)
{
- int *pData = (int *)pArg;
+ intptr_t *pData = (intptr_t *)pArg;
if (m_pContextModelEvent)
{
void CContextModel::onTerminate(IN void *pArg)
{
- int *pData = (int *)pArg;
+ intptr_t *pData = (intptr_t *)pArg;
SAFE_ARRAY_DELETE(pData);
}
void CEvaluationEngine::onExecute(IN void *pArg)
{
std::map<int, IEvaluationEngineEvent *>::iterator itor;
- int *pData = (int *)pArg;
+ intptr_t *pData = (intptr_t *)pArg;
m_mtxTriggerId.lock();
itor = m_mapTriggers.find(pData[0]);
void CEvaluationEngine::onTerminate(IN void *pArg)
{
- int *pData = (int *)pArg;
+ intptr_t *pData = (intptr_t *)pArg;
SAFE_ARRAY_DELETE(pData);
}
SSMRESULT CEvaluationEngine::onWatcherTriggered(IN int triggerId, IN int dataId)
{
- int *pData = new int[2];
+ intptr_t *pData = new intptr_t[2];
pData[0] = triggerId;
pData[1] = dataId;
m_pTasker->addTask(this, (void *)pData);
sstream << "CREATE TRIGGER WatchInsertModel" << m_iTriggerId << " AFTER INSERT ON [ModelData" <<
modelId << "] WHEN ";
sstream << sstreamCondition.str().c_str() << " BEGIN SELECT OnSQLTrigger(" <<
- (int)this << ", " << m_iTriggerId << ", NEW.dataId); END;" << std::ends;
+ reinterpret_cast<intptr_t>(this) << ", " << m_iTriggerId << ", NEW.dataId); END;" << std::ends;
SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
sstream.str("");
sstream << "CREATE TRIGGER WatchUpdateModel" << m_iTriggerId << " AFTER UPDATE ON [ModelData" <<
modelId << "] WHEN ";
sstream << sstreamCondition.str().c_str() << " BEGIN SELECT OnSQLTrigger(" <<
- (int)this << ", " << m_iTriggerId << ", NEW.dataId); END;" << std::ends;
+ reinterpret_cast<intptr_t>(this) << ", " << m_iTriggerId << ", NEW.dataId); END;" << std::ends;
SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
m_mtxTriggerId.lock();
{
SSMRESULT res = SSM_E_FAIL;
- int *pMessage = (int *)pArg;
+ intptr_t *pMessage = (intptr_t *)pArg;
RESOURCE_EVENT_TYPE eventType = (RESOURCE_EVENT_TYPE)pMessage[0];
ISSMResource *pResource = (ISSMResource *)pMessage[1];
void CPropagationEngine::onTerminate(IN void *pArg)
{
- int *pMessage = (int *)pArg;
+ intptr_t *pMessage = (intptr_t *)pArg;
delete[] pMessage;
}
int CPropagationEngine::onResourceEvent(IN RESOURCE_EVENT_TYPE eventType,
IN ISSMResource *pSSMResource, IN std::string info)
{
- int *pMessage = new int[2];
+ intptr_t *pMessage = new intptr_t [2];
pMessage[0] = eventType;
- pMessage[1] = (int)pSSMResource;
+ pMessage[1] = reinterpret_cast<intptr_t>(pSSMResource);
return (int)m_pTasker->addTask(this, (void *)pMessage);
}
IContextModel *temp_contextmodel = NULL;
IContextModel *temp_contextmodel2 = NULL;
- int *pData = NULL;
+ intptr_t *pData = NULL;
CDataReader *pDataReader = NULL;
SSM_CLEANUP_ASSERT(pDataReader->addModelData((result_model_data_id)[i].modelName, &modelDataSet));
}
- pData = new int[3];
+ pData = new intptr_t [3];
pData[0] = EVENT_TYPE_OUTER;
pData[1] = userTriggerId;
- pData[2] = (int)pDataReader;
+ pData[2] = reinterpret_cast<intptr_t>(pDataReader);
m_pTasker->addTask(this, (void *)pData);
void CQueryEngine::onExecute(void *pArg)
{
- int *pData = (int *)pArg;
+ intptr_t *pData = (intptr_t *)pArg;
switch (pData[0])
{
void CQueryEngine::onTerminate(void *pArg)
{
- int *pData = (int *)pArg;
+ intptr_t *pData = (intptr_t *)pArg;
std::vector<result_model> *pResult = NULL;
CDataReader *pDataReader = NULL;
if (validateQueryResult(pConditionedQueryResult, pResult) == SSM_S_OK)
{
//We have valid data, let's deliver to application.
- int *pData = new int[3];
+ intptr_t *pData = new intptr_t [3];
pData[0] = EVENT_TYPE_INNER;
pData[1] = m_cqid;
- pData[2] = (int)pResult;
+ pData[2] = reinterpret_cast<intptr_t>(pResult);
m_pTasker->addTask(this, (void *)pData);
}
goto CLEANUP;
}
- sstream << (int) pQueryEngine;
+ sstream << reinterpret_cast<intptr_t>(pQueryEngine);
// Register QueryEngineEvent
queryEngineEvent = new CQueryEngineEvent(sstream.str(), m_hSSMResource);
void CContextExecutor::onExecute(IN void *pArg)
{
- int *pMessage = (int *)pArg;
+ intptr_t *pMessage = (intptr_t *)pArg;
RESOURCE_EVENT_TYPE eventType = (RESOURCE_EVENT_TYPE)pMessage[0];
ISSMResource *pResource = (ISSMResource *)pMessage[1];
void CContextExecutor::onTerminate(IN void *pArg)
{
- int *pMessage = (int *)pArg;
+ intptr_t *pMessage = (intptr_t *)pArg;
delete[] pMessage;
}
int CContextExecutor::onResourceEvent(RESOURCE_EVENT_TYPE eventType, ISSMResource *pSSMResource,
std::string info)
{
- int *pMessage = new int[2];
+ intptr_t *pMessage = new intptr_t [2];
pMessage[0] = eventType;
- pMessage[1] = (int)pSSMResource;
+ pMessage[1] = reinterpret_cast<intptr_t>(pSSMResource);
return (int)m_pTasker->addTask(this, (void *)pMessage);
}
InitContext InitializeContextFunction = NULL;
// load dll(so)
- res = SSM_E_FAIL;
- for (unsigned int i = 1; i <= SSM_MODEL_RETRY; ++i)
- {
- sstream.str("");
#ifdef WIN32
- sstream << m_pathSoftSensors << softSensorName.c_str() << ".dll" << std::ends;
+ sstream << m_pathSoftSensors << softSensorName.c_str() << ".dll" << std::ends;
- HINSTANCE hModule = NULL;
- hModule = LoadLibraryA(sstream.str().c_str());
+ HINSTANCE hModule = NULL;
+ hModule = LoadLibraryA(sstream.str().c_str());
- if (hModule != NULL)
- {
- InitializeContextFunction = (InitContext)GetProcAddress(hModule, "InitializeContext");
- }
+ if (hModule != NULL)
+ {
+ InitializeContextFunction = (InitContext)GetProcAddress(hModule, "InitializeContext");
+ }
#else
- //sstream << "/data/data/com.example.javaproject/lib/lib" << modelName <<".so" << std::ends;
- sstream << m_pathSoftSensors << "lib" << softSensorName.c_str() << ".so" << std::ends;
+ //sstream << "/data/data/com.example.javaproject/lib/lib" << modelName <<".so" << std::ends;
+ sstream << m_pathSoftSensors << "lib" << softSensorName.c_str() << ".so" << std::ends;
- void *hModule = NULL;
- hModule = dlopen(sstream.str().c_str(), RTLD_LOCAL | RTLD_LAZY);
+ void *hModule = NULL;
+ hModule = dlopen(sstream.str().c_str(), RTLD_LOCAL | RTLD_LAZY);
- if (hModule != NULL)
- {
- InitializeContextFunction = (InitContext)dlsym(hModule, "InitializeContext");
- }
+ if (hModule != NULL)
+ {
+ InitializeContextFunction = (InitContext)dlsym(hModule, "InitializeContext");
+ }
#endif
- if (hModule == NULL)
- {
- //load library failed. raise error
- SSM_CLEANUP_ASSERT(SSM_E_FAIL);
- //InitializeContextFunction = NULL;
- //continue;
- }
-
- if (InitializeContextFunction != NULL)
- {
- InitializeContextFunction(pDelegate);
- *hSoftSensor = hModule;
- res = SSM_S_OK;
- }
- else
- {
- //Unload module and return error
- SSM_CLEANUP_ASSERT(unloadSoftSensor(hModule));
- SSM_CLEANUP_ASSERT(SSM_E_FAIL);
- }
+ if (hModule == NULL)
+ {
+ //load library failed. raise error
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+ }
- break;
+ if (InitializeContextFunction != NULL)
+ {
+ InitializeContextFunction(pDelegate);
+ *hSoftSensor = hModule;
+ res = SSM_S_OK;
+ }
+ else
+ {
+ //Unload module and return error
+ SSM_CLEANUP_ASSERT(unloadSoftSensor(hModule));
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
}
CLEANUP:
SSM_CLEANUP_ASSERT(SSM_E_FAIL);
}
+ buffer[length] = '\0';
+
strPath = strrchr(buffer, '/');
if (strPath == NULL)
public:
/// Constructor
TemphumidResource() :
- m_humid(0), m_temp(0)
+ m_humid(0), m_temp(0), m_resourceHandle(0)
{
m_resourceUri = "/Thing_TempHumSensor";
m_resourceTypes.push_back(COAP_TYPE_NAME);
public:
/// Constructor
TemphumidResource() :
- m_humid(0), m_temp(0)
+ m_humid(0), m_temp(0), m_resourceHandle(0)
{
m_resourceUri = "/Thing_TempHumSensor1";
m_resourceTypes.push_back(COAP_TYPE_NAME);