JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getPropertyCount (JNIEnv *env, jclass clz, jlong pIModelDataInstance ) { IModelData *pModelData = (IModelData *)pIModelDataInstance; return pModelData->getPropertyCount(); }
JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_getPropertyValue (JNIEnv *env, jclass clz, jlong pIModelDataInstance, jint propertyIndex ) { IModelData *pModelData = (IModelData *)pIModelDataInstance; return env->NewStringUTF(pModelData->getPropertyValue(propertyIndex).c_str()); }
JNIEXPORT jint JNICALL Java_org_iotivity_service_ssm_CoreController_getDataId (JNIEnv *env, jclass clz, jlong pDataReaderInstance) { IModelData *pDataReader = (IModelData *)pDataReaderInstance; return pDataReader->getDataId(); }
/* APP. Level Callback Function for Observer of client. */ SSMRESULT SSMTestApp::onQueryEngineEvent(int cqid, IDataReader *pResult) { int dataCount = 0; IModelData *pModelData = NULL; std::vector<std::string> affectedModels; cout << "Event received! cqid = " << cqid << endl; pResult->getAffectedModels(&affectedModels); for (std::vector<std::string>::iterator itor = affectedModels.begin(); itor != affectedModels.end(); ++itor) { cout << "Printing " << *itor << " model" << endl; pResult->getModelDataCount(*itor, &dataCount); for (int i = 0; i < dataCount; i++) { pResult->getModelData(*itor, i, &pModelData); cout << "dataId: " << pModelData->getDataId() << endl; for (int j = 0; j < pModelData->getPropertyCount(); j++) { cout << "Type: " << pModelData->getPropertyName(j) << " Value: " << pModelData->getPropertyValue( j) << endl; } //TrajectoryDataOutput(pModelData); } } return SSM_S_OK; }
SSMRESULT onQueryEngineEvent(int cqid, IDataReader *pResult) { std::stringstream sstream; int dataCount = 0; IModelData *pModelData = NULL; std::vector<std::string> affectedModels; pResult->getAffectedModels(&affectedModels); for (std::vector<std::string>::iterator itor = affectedModels.begin(); itor != affectedModels.end(); ++itor) { printf("Printing %s\n", itor->c_str()); pResult->getModelDataCount(*itor, &dataCount); for (int i = 0; i < dataCount; i++) { pResult->getModelData(*itor, i, &pModelData); printf("dataId: %d\n", pModelData->getDataId()); for (int j = 0; j < pModelData->getPropertyCount(); j++) { sstream << "Type: " << pModelData->getPropertyName(j).c_str() << " Value: " << pModelData->getPropertyValue(j).c_str() << "<br>"; } } } sstream << std::ends; oicapp_util_put_msg(g_ad, sstream.str().c_str()); return SSM_S_OK; }
int CModelManager::getResourceId(const CString& name) { int resourceId = 0; for (TModelInfoVector::const_iterator it = m_models.begin(); it != m_models.end(); ++it, ++resourceId) { if (it->name == name) { return resourceId; } } // Recherche du modèle dans chaque répertoire du gestionnaire for (std::list<CString>::const_iterator itP = m_paths.begin(); itP != m_paths.end(); ++itP) { // On parcourt la liste des chargeurs for (std::list<CreateInstanceType>::iterator it = m_loaders.begin(); it != m_loaders.end(); ++it) { IModelData * modelData = (*it)(*itP + name); if (modelData) { int id = m_models.size(); modelData->loadFromFile(*itP + name); TModelDataInfos modelDataInfos; modelDataInfos.name = name; modelDataInfos.model = modelData; m_models.push_back(modelDataInfos); return id; } } } // Aucun chargeur ne prend en charge ce type de fichier return -1; }
SSMRESULT onQueryEngineEvent(IN int cqid, IN IDataReader *pResult) { int dataCount = 0; IModelData *pModelData = NULL; std::vector < std::string > affectedModels; std::map<std::string, std::string> queryEventResult; std::stringstream sstream; // QueryEngine Id queryEventResult["queryEngineId"] = m_queryEngineId; // CQID sstream << cqid; queryEventResult["CQID"] = sstream.str(); sstream.str(""); pResult->getAffectedModels(&affectedModels); // Affected Model Count sstream << affectedModels.size(); queryEventResult["modelCount"] = sstream.str(); sstream.str(""); //TODO: we assume that contains only one model at time for (std::vector< std::string >::iterator itor = affectedModels.begin(); itor != affectedModels.end(); ++itor) { // Model Name sstream << (*itor); queryEventResult["modelName"] = sstream.str(); sstream.str(""); pResult->getModelDataCount(*itor, &dataCount); // Data Count sstream << dataCount; queryEventResult["dataCount"] = sstream.str(); sstream.str(""); //FixME: we have to support multiple data count for (int i = 0; i < dataCount; i++) { pResult->getModelData(*itor, i, &pModelData); // Data Id sstream << pModelData->getDataId(); queryEventResult["dataId"] = sstream.str(); sstream.str(""); // Property Count sstream << pModelData->getPropertyCount(); queryEventResult["propertyCount"] = sstream.str(); sstream.str(""); for (int j = 0; j < pModelData->getPropertyCount(); j++) { // Property Name & Value sstream << pModelData->getPropertyValue(j).c_str(); queryEventResult[pModelData->getPropertyName(j).c_str()] = sstream.str(); sstream.str(""); } } } g_vecQueryEventResults.push_back(queryEventResult); //TODO: need to modify for notifying proper clients OCPlatform::notifyAllObservers(m_hSSMResource); return SSM_S_OK; }