1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 * @file IQueryEngineEvent.java
23 * @brief This file provides a class that represents Query Engine's event that contains results
27 package org.iotivity.service.ssm;
30 * @class IQueryEngineEvent
31 * @brief This is an interface class for sample applications.It handles the response from
32 * SSMCore received asynchronously on making a query with the SSMCore.
33 * Application should implement the pure virtual function OnQueryEngineEvent.
34 * The Application should call registerQuery() and add a listener.
39 int cqid = SoftSensorManager.registerQuery(edtQuery.getText().toString(), mQueryEngineEventListener);
40 mRunningQueries.add(cqid);
42 private IQueryEngineEvent mQueryEngineEventListener = new IQueryEngineEvent()
45 public void onQueryEngineEvent(int cqid, DataReader result)
47 List<String> models = result.GetAffectedModels();
49 for(String modelName : models)
51 int dataCount = result.GetModelDataCount(modelName);
52 for(int i=0; i < dataCount; i++)
54 ModelData modelData = result.GetModelData(modelName, i);
55 for(int j=0; j < modelData.GetPropertyCount(); j++)
57 PrintLog("Name: " + modelData.GetPropertyName(j) +
58 " Value: " + modelData.GetPropertyValue(j));
65 public abstract class IQueryEngineEvent
69 * Transmits result of SSMCore to Application layer
70 * This abstract method needs to be implemeted by application
71 * as a precondition for query engine implementation.
74 * - ContextQuery ID of the registered query
77 * - data received from SSMCore
82 public abstract void onQueryEngineEvent(int cqid, DataReader result);