JNIEXPORT jstring JNICALL Java_org_iotivity_service_ssm_CoreController_getPropertyName (JNIEnv *env, jclass clz, jlong pIModelDataInstance, jint propertyIndex ) { IModelData *pModelData = (IModelData *)pIModelDataInstance; return env->NewStringUTF(pModelData->getPropertyName(propertyIndex).c_str()); }
/* 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; }
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; }