Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SSMCore / include / SSMInterface.h
1 /******************************************************************
2 *
3 * Copyright 2014 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 /**
22 * @file
23 *
24 * This file defines basic interface of Soft Sensor Manager.
25 */
26
27 #ifndef _SSMInterface_H_
28 #define _SSMInterface_H_
29
30 #include <string>
31 #include <vector>
32
33 namespace OIC
34 {
35     enum SSMRESULT
36     {
37         SSM_S_OK
38         , SSM_S_FALSE
39         , SSM_E_POINTER
40         , SSM_E_OUTOFMEMORY
41         , SSM_E_FAIL
42         , SSM_E_NOTINIT
43         , SSM_E_INITIALIZED
44         , SSM_E_INVALIDXML
45         , SSM_E_NOINTERFACE
46         , SSM_E_NOTIMPL
47     };
48
49     /**
50     * @class    IModelData
51     * @brief    This class represents context model data package
52     *
53     */
54     class IModelData
55     {
56         public:
57             /**
58             * Get affected DataId. ContextModel has plenty of data so \n
59             *         returned data is matched from given condition
60             *
61             * @return int - the affected DataId
62             */
63             virtual int getDataId() = 0;
64
65             /**
66             * ContextModel has at least one property that contains data \n
67             *         property is described from its specification.
68             *
69             * @return int - number of properties
70             */
71             virtual int getPropertyCount() = 0;
72
73             /**
74             * Retrieve propertyName
75             *
76             * @param propertyIndex - index of property to read
77             *
78             * @return std::string - property name
79             */
80             virtual std::string getPropertyName(int propertyIndex) = 0;
81
82             /**
83             * Retrieve propertyValue
84             *
85             * @param propertyIndex index of property to read
86             *
87             * @return std::string - property value
88             */
89             virtual std::string getPropertyValue(int propertyIndex) = 0;
90
91             /**
92             * Retrieve propertyValue using given name
93             *
94             * @param propertyName - property name looking for
95             *
96             * @return std::string - property name
97             */
98             virtual std::string getPropertyValueByName(std::string propertyName) = 0;
99         protected:
100             virtual ~IModelData() {};
101     };
102
103     /**
104     * @class    IDataReader
105     * @brief    This class represents context model data package's reader
106     *
107     * @see
108     */
109     class IDataReader
110     {
111         public:
112             /**
113             * Get affected ContextModels. The query can specify multiple ContextModels for retrieving data.
114             *
115             * @param pAffectedModels - affected ContextModel list
116             *
117             * @return SSMRESULT - return value of the API. Returns SSM_S_OK if success
118             */
119             virtual SSMRESULT getAffectedModels(std::vector<std::string> *pAffectedModels) = 0;
120
121             /**
122             * Get affected data count. There are multiple data can exist from given condition.
123             *
124             * @param modelName - affected ContextModel name
125             *
126             * @param pDataCount - affected dataId count
127             *
128             * @return SSMRESULT - return value of the API. Returns SSM_S_OK if success
129             */
130             virtual SSMRESULT getModelDataCount(std::string modelName, int *pDataCount) = 0;
131
132             /**
133             * Get actual Context Model data
134             *
135             * @param modelName - affected ContextModel name
136             *
137             * @param dataIndex - affected dataId index
138             *
139             * @param ppModelData - affected ContextModel data reader
140             *
141             * @return SSMRESULT - return value of the API. Returns SSM_S_OK if success
142             */
143             virtual SSMRESULT getModelData(std::string modelName, int dataIndex, IModelData **ppModelData) = 0;
144         protected:
145             virtual ~IDataReader() {};
146     };
147
148     /**
149     * @class    IQueryEngineEvent
150     * @brief    This class represents Query Engine's event that contains results
151     *
152     * @see
153     */
154     class IQueryEngineEvent
155     {
156         public:
157             /**
158             * Transmit result of SSMCore to Application layer
159             *
160             * @param cqid - entered ContextQuery ID
161             *
162             * @param pResult - result of SSMCore
163             *
164             * @return SSMRESULT - return value of the API. Returns SSM_S_OK if success
165             */
166             virtual SSMRESULT onQueryEngineEvent(int cqid, IDataReader *pResult) = 0;
167         protected:
168             virtual ~IQueryEngineEvent() {};
169     };
170
171     /**
172     * Initialize Soft sensor manager using given configuration information.
173     *
174     * @param xmlDescription - specification described in XML
175     *
176     * @return SSMRESULT - return value of the API. Returns SSM_S_OK if success
177     */
178     SSMRESULT InitializeSSM(std::string xmlDescription);
179
180     /**
181     * Terminates Soft sensor manager
182     *
183     * @return SSMRESULT - return value of the API. Returns SSM_S_OK if success
184     */
185     SSMRESULT TerminateSSM();
186
187     /**
188     * Execute query and return ContextQuery ID
189     *
190     * @param queryString - query for requesting data
191     *
192     * @param listener - listener for receiving data related to query
193     *
194     * @param cqid - ID of ContextQuery
195     *
196     * @return SSMRESULT - return value of the API. Returns SSM_S_OK if success
197     */
198     SSMRESULT RegisterQuery(std::string queryString, IQueryEngineEvent *listener, int &cqid);
199
200     /**
201     * Unregister registered query according to cqid
202     *
203     * @param cqid - Query corresponding to the cqid will be terminated
204     *
205     * @return SSMRESULT - return value of the API. Returns SSM_S_OK if success
206     */
207     SSMRESULT UnregisterQuery(int cqid);
208 }
209 #endif