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