Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SDK / java / org / iotivity / service / ssm / IQueryEngineEvent.java
1 /******************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20 /**
21  * @file    IQueryEngineEvent.java
22  *
23  * @brief    This file provides a class that represents Query Engine's event that contains results
24  *
25  */
26
27 package org.iotivity.service.ssm;
28
29     /**
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.
35     *
36     *<pre>
37     Sample code :
38
39         int cqid = SoftSensorManager.registerQuery(edtQuery.getText().toString(), mQueryEngineEventListener);
40         mRunningQueries.add(cqid);
41
42         private IQueryEngineEvent mQueryEngineEventListener = new IQueryEngineEvent()
43         {
44         @Override
45         public void onQueryEngineEvent(int cqid, DataReader result)
46         {
47                 List<String> models = result.GetAffectedModels();
48
49                 for(String modelName : models)
50                 {
51                     int dataCount = result.GetModelDataCount(modelName);
52                     for(int i=0; i < dataCount; i++)
53                     {
54                         ModelData modelData = result.GetModelData(modelName, i);
55                         for(int j=0; j < modelData.GetPropertyCount(); j++)
56                         {
57                             PrintLog("Name: " + modelData.GetPropertyName(j) +
58                                 " Value: " + modelData.GetPropertyValue(j));
59                         }
60                     }
61                 }
62         }
63         };</pre>
64     */
65 public abstract class IQueryEngineEvent
66 {
67
68         /**
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.
72          *
73          * @param cqid 
74          *              - ContextQuery ID of the registered query
75          *
76          * @param result 
77          *              - data received from SSMCore
78          *
79          * @return void
80          *
81          */
82         public abstract void onQueryEngineEvent(int cqid, DataReader result);
83 }