iotivity 0.9.0
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SSMCore / src / Common / InternalInterface.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 #ifndef _InternalInterface_H_
21 #define _InternalInterface_H_
22
23 #include "SSMInterface/SSMModelDefinition.h"
24 #include "Common/PlatformLayer.h"
25
26 class CallbackData
27 {
28     public:
29         TypeofEvent m_callType;
30         std::string m_name;
31         IEvent     *m_pCallbackEvent;
32         CallbackData()
33         {
34             m_callType = SSM_ONCE;
35             m_pCallbackEvent = NULL;
36         }
37
38         CallbackData(TypeofEvent type, std::string name, IEvent *pCallbackEvent)
39         {
40             m_name = name;
41             m_pCallbackEvent = pCallbackEvent;
42             m_callType = type;
43         }
44 };
45
46 struct DictionaryData
47 {
48     std::string rootName;
49     std::vector<std::map<std::string, std::string> > attributeProperty;
50     std::vector<std::map<std::string, std::string> > outputProperty;
51     std::vector<std::string> appInputs;
52     std::vector<std::string> inputs;
53     std::string attributePropertyCount;
54     std::string outputPropertyCount;
55     std::string inputCount;
56     std::string appInputCount;
57     std::vector<std::vector<std::string> > enterConditions;
58 };
59
60 enum PARSE_TYPE {SSM_UNKNOWN, SSM_ROOT_NAME, SSM_HIGH_CONTEXT_NAME, SSM_ATTRIBUTE, SSM_OUTPUT, SSM_APP_INPUTS, SSM_INPUTS, SSM_INPUT, SSM_ENTER_CONDITIONS};
61 enum DICTIONARY_TYPE {LOW, HIGH, SENSOR, USER};
62
63 static const OID OID_IContextRepository = { 0x611144b0, 0xf036, 0x44a1, { 0xba, 0xe6, 0x6a, 0x92, 0xe1, 0xf0, 0xcc, 0x53 } };
64 /**
65  * @class    IContextRepository
66  * @brief    Interface for context manifest
67  *           parse, get, set context manifest. provide device information
68  *
69  * @see
70  */
71 class IContextRepository : public IBase
72 {
73     public:
74         /**
75         * @fn           getSoftSensorList
76         * @brief        Get high level context resource list
77         *
78         * @param        [out] std::vector<ISSMResource*> *pSoftSensorList - High level context list
79         * @return       SSMRESULT
80         *                   SSM_S_OK
81         *                   , SSM_S_FALSE
82         *                   , SSM_E_POINTER
83         *                   , SSM_E_OUTOFMEMORY
84         *                   , SSM_E_FAIL
85         *                   , SSM_E_NOINTERFACE
86         *                   , SSM_E_NOTIMPL
87         *
88         * @warning
89         * @exception
90         * @see
91         */
92         virtual SSMRESULT getSoftSensorList(OUT std::vector<ISSMResource *> *pSoftSensorList) = 0 ;
93
94         /**
95         * @fn           getPrimitiveSensorList
96         * @brief        Get low level context resource list
97         *
98         * @param        [out] std::vector<ISSMResource*> *pPrimitiveSensorList - Low level context list
99         * @return       SSMRESULT
100         *                   SSM_S_OK
101         *                   , SSM_S_FALSE
102         *                   , SSM_E_POINTER
103         *                   , SSM_E_OUTOFMEMORY
104         *                   , SSM_E_FAIL
105         *                   , SSM_E_NOINTERFACE
106         *                   , SSM_E_NOTIMPL
107         *
108         * @warning
109         * @exception
110         * @see
111         */
112         virtual SSMRESULT getPrimitiveSensorList(OUT std::vector<ISSMResource *> *pPrimitiveSensorList) = 0
113                 ;
114
115         /**
116         * @fn           initRepository
117         * @brief        initialize repository using given info
118         *
119         * @param        [in] std::string name - Device name
120         * @param        [in] std::string type - Device Type
121         * @param        [in] std::string pathSoftSensors - SoftSensors Repository path
122         * @param        [in] std::string pathDescription - SoftSensors Description path
123         * @return       SSMRESULT
124         *
125         * @warning
126         * @exception
127         * @see
128         */
129         virtual SSMRESULT initRepository(IN std::string name, IN std::string type,
130                                          IN std::string pathSoftSensors, IN std::string pathDescription) = 0;
131
132         virtual SSMRESULT registerResourceFinderEvent(IN IResourceEvent *pResourceEvent) = 0;
133         virtual SSMRESULT startResourceFinder() = 0;
134         virtual SSMRESULT onResourceFound(IN ISSMResource *pSensor) = 0;
135         virtual SSMRESULT onResourceLost(IN ISSMResource *pSensor) = 0;
136
137         virtual SSMRESULT startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent) = 0;
138         virtual SSMRESULT stopObserveResource(IN ISSMResource *pSensor) = 0;
139
140         virtual SSMRESULT loadSoftSensor(IN std::string softSensorName, IN ICtxDelegate *pDelegate,
141                                          OUT void **hSoftSensor) = 0;
142         virtual SSMRESULT unloadSoftSensor(IN void *hSoftSensor) = 0;
143 };
144
145 struct ModelProperty
146 {
147     enum Type {TYPE_NUMERIC, TYPE_INTEGER, TYPE_REAL, TYPE_TEXT};
148     std::string     propertyName;
149     std::string     propertyValue;
150     Type            propertyType;
151 };
152
153 typedef std::vector<ModelProperty> ModelPropertyVec;
154
155 struct ModelCondition
156 {
157     enum Predicate {PREDICATE_EQ, PREDICATE_NEQ, PREDICATE_GT, PREDICATE_LT, PREDICATE_GTE, PREDICATE_LTE};
158     ModelProperty   modelProperty;
159     Predicate       predicate;
160 };
161
162 typedef std::vector<ModelCondition> ModelConditionVec;
163
164 /**
165 * @class    IEvaluationEngineEvent
166 * @brief    IEvaluationEngineEvent Interface
167 *            This class represents event interface that listening IEvaluationEngine's results
168 *
169 * @see
170 */
171 class IEvaluationEngineEvent : public IBase
172 {
173     public:
174         /**
175         * @fn     onWatchModelData
176         * @brief Called when Model data meets given conditions.
177         *
178         * @param [in] int triggerId - Trigger id.
179         * @param [in] int dataId - Affected data's Id
180         *
181         * @return SSMRESULT
182         * @warning
183         * @exception
184         * @see
185         */
186         virtual SSMRESULT onWatchModelData(IN int triggerId, IN int dataId) = 0;
187 };
188
189 static const OID OID_IEvaluationEngine = { 0x5a59a9f3, 0x7506, 0x4a3a, { 0xb9, 0x34, 0xcb, 0x51, 0xd, 0xb4, 0xed, 0x53 } };
190 /**
191 * @class    IEvaluationEngine
192 * @brief    IEvaluationEngine Interface
193 *            This class represents Evaluation Engine
194 *
195 * @see
196 */
197 class IEvaluationEngine : public IBase
198 {
199     public:
200         /**
201         * @fn     initializeEngine
202         * @brief Initialize EvaluationEngine with database
203         *
204         * @param NONE
205         *
206         * @return SSMRESULT
207         * @warning
208         * @exception
209         * @see
210         */
211         virtual SSMRESULT initializeEngine() = 0;
212
213         /**
214         * @fn     terminateEngine
215         * @brief Terminate engine and dump to file if required
216         *
217         * @param NONE
218         *
219         * @return void
220         * @warning
221         * @exception
222         * @see
223         */
224         virtual void terminateEngine() = 0;
225
226         /**
227         * @fn     createModel
228         * @brief Create new context model
229         *
230         * @param [in] int parentModelId - Parent Context Model id that related to Model hierarchy.
231         * @param [in] const char *newModelName - Represent model's name
232         * @param [in] ModelPropertyVec *pModelProperties - Represent model's properties that exposed to CQL
233         * @param [out] int *pModelId - Created model's id
234         *
235         * @return SSMRESULT
236         * @warning
237         * @exception
238         * @see
239         */
240         virtual SSMRESULT createModel(IN int parentModelId, IN const char *newModelName,
241                                       IN ModelPropertyVec *pModelDescs, OUT int *pModelId) = 0;
242         //virtual SSMRESULT GetModelSchema(IN int modelId, OUT ModelPropertyVec *pModelProperties) = 0;
243
244         /**
245         * @fn     addModelData
246         * @brief Add model data to Context Model
247         *
248         * @param [in] int modelId - model id that created CreateModel's execution.
249         * @param [in] int parentModelId - parent model id that created CreateModel's execution.
250         * @param [in] int parentDataId - Specify current model's parent Context Model's dataId
251         * @param [in] ModelPropertyVec *pData - Packed data for adding
252         * @param [out] int *pDataId - Returned dataId that newly added
253         *
254         * @return SSMRESULT
255         * @warning
256         * @exception
257         * @see
258         */
259         virtual SSMRESULT addModelData(IN int modelId, IN int parentModelId, IN int parentDataId,
260                                        IN ModelPropertyVec *pModelValues, OUT int *pDataId) = 0;
261
262         /**
263         * @fn     updateModelData
264         * @brief Update model data to Context Model
265         *
266         * @param [in] int modelId - model id that created CreateModel's execution.
267         * @param [in] int dataId - DataId that provided AddModelData's execution
268         * @param [in] ModelPropertyVec *pData - Packed data for updating
269         *
270         * @return SSMRESULT
271         * @warning
272         * @exception
273         * @see
274         */
275         virtual SSMRESULT updateModelData(IN int modelId, IN int dataId,
276                                           IN ModelPropertyVec *pModelValues) = 0;
277
278         //virtual SSMRESULT DeleteModel(IN int modelId) = 0;
279
280         /**
281         * @fn     deleteModelData
282         * @brief Delete model data using given index
283         *
284         * @param [in] int modelId - model id that created CreateModel's execution.
285         * @param [in] int dataId - DataId that provided AddModelData's execution
286         *
287         * @return SSMRESULT
288         * @warning
289         * @exception
290         * @see
291         */
292         virtual SSMRESULT deleteModelData(IN int modelId, IN int dataId) = 0;
293
294         //virtual SSMRESULT GetModelId(IN const char *modelName, OUT int *pModelId) = 0;
295
296         /**
297         * @fn     getModelData
298         * @brief Get model data
299         *
300         * @param [in] int modelId - model id that created CreateModel's execution.
301         * @param [in] int dataId - DataId that provided AddModelData's execution
302         * @param [out] ModelPropertyVec *pData - Packed data
303         *
304         * @return SSMRESULT
305         * @warning
306         * @exception
307         * @see
308         */
309         virtual SSMRESULT getModelData(IN int modelId, IN int dataId,
310                                        OUT ModelPropertyVec *pModelProperties) = 0;
311
312         /**
313         * @fn     getModelDataSet
314         * @brief Get model data set
315         *
316         * @param [in] int modelId - model id that created CreateModel's execution.
317         * @param [in] int startIndex - Starting index of model data
318         * @param [in] int count - Number of data to retrieve
319         * @param [out] vector<ModelPropertyVec> *pData - Packed data
320         * @param [out] int *pLastIndex - Index of last data
321         *
322         * @return SSMRESULT
323         * @warning
324         * @exception
325         * @see
326         */
327         virtual SSMRESULT getModelDataSet(IN int modelId, IN int startIndex, IN int count,
328                                           OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex) = 0;
329
330         /**
331         * @fn     getConditionedModelData
332         * @brief Get affected data from given conditions
333         *
334         * @param [in] int modelId - model id that created CreateModel's execution.
335         * @param [in] ModelConditionVec *pModelConditions - Conditions for data retrieving
336         * @param [out] IntVec   *pDataIds - Searched dataId sets.
337         *
338         * @return SSMRESULT
339         * @warning
340         * @exception
341         * @see
342         */
343         virtual SSMRESULT getConditionedModelData(IN int modelId, IN ModelConditionVec *pModelConditions,
344                 OUT IntVec *pDataIds) = 0;
345
346         /**
347         * @fn     watchModelData
348         * @brief Watching data from given conditions
349         *
350         * @param [in] int modelId - model id that created CreateModel's execution.
351         * @param [in] ModelConditionVec *pModelConditions - Conditions for data triggering
352         * @param [in] IEvaluationEngineEvent *pEvaluationEngineEvent - Event interface where triggered event listening
353         * @param [out] int *pTriggerId - Identifier which trigger is activated
354         *
355         * @return SSMRESULT
356         * @warning
357         * @exception
358         * @see
359         */
360         virtual SSMRESULT watchModelData(IN int modelId, IN ModelConditionVec *pModelConditions,
361                                          IN IEvaluationEngineEvent *pEvaluationEngineEvent, OUT int *pTriggerId) = 0;
362
363         /**
364         * @fn     dropWatchModelData
365         * @brief Stop watching data
366         *
367         * @param [in] int triggerId - Identifier which trigger to drop
368         *
369         * @return SSMRESULT
370         * @warning
371         * @exception
372         * @see
373         */
374         virtual SSMRESULT dropWatchModelData(IN int triggerId) = 0;
375
376         /**
377         * @fn     getParentDataId
378         * @brief Get parent dataId related to model hierarchy
379         *
380         * @param [in] int modelId - model id that created CreateModel's execution.
381         * @param [in] int dataId - DataId that current model's
382         * @param [in] int parentModelId - Designated parent Context Model's id
383         * @param [out] int *pParentDataId - Designated parent Context Model's data's Id
384         *
385         * @return SSMRESULT
386         * @warning
387         * @exception
388         * @see
389         */
390         virtual SSMRESULT getParentDataId(IN int modelId, IN int dataId, IN int parentModelId,
391                                           OUT int *pParentDataId) = 0;
392
393         /**
394         * @fn     getChildDataId
395         * @brief Get child dataId related to model hierarchy
396         *
397         * @param [in] int modelId - model id that created CreateModel's execution.
398         * @param [in] int dataId - DataId that current model's
399         * @param [in] int childModelId - Designated child Context Model's id
400         * @param [out] IntVec *pChildDataIds - Designated child Context Model's data's Id
401         *
402         * @return SSMRESULT
403         * @warning
404         * @exception
405         * @see
406         */
407         virtual SSMRESULT getChildDataId(IN int modelId, IN int dataId, IN int childModelId,
408                                          OUT IntVec *pChildDataIds) = 0;
409
410         //For decision tree
411         //virtual SSMRESULT GetPathToRoot(IN int currentModelId, OUT IntVec *pPath) = 0;
412         //virtual SSMRESULT GetModelHierarchy(IN int rootModelId, OUT StringVec *pPath) = 0;
413         //virtual SSMRESULT GetDataHierarchy(IN int rootModelId, IN int dataId, OUT StringVec *pPath) = 0;
414 };
415
416 /**
417 * @class    IConditionedModelEvent
418 * @brief    IConditionedModelEvent Interface
419 *            This class represents event interface that listening IConditionedModel's results
420 *
421 * @see
422 */
423 class IConditionedModelEvent
424 {
425     public:
426         /**
427         * @fn     onConditionedModelTriggered
428         * @brief Called when each Conditioned Model meets the conditions
429         *
430         * @param [in] int triggerId - trigger id that which Conditioned Model triggered
431         *
432         * @return SSMRESULT
433         * @warning
434         * @exception
435         * @see
436         */
437         virtual SSMRESULT onConditionedModelTriggered(IN int triggerId) = 0;
438         virtual ~IConditionedModelEvent() {};
439 };
440
441 class IContextModel;
442
443 static const OID OID_IConditionedModel = { 0xdc71abc7, 0x5a02, 0x418a, { 0xad, 0x1e, 0xc0, 0x1, 0x9, 0x6b, 0x32, 0x6d } };
444 /**
445 * @class    IConditionedModel
446 * @brief    IConditionedModel Interface
447 *            This class represents Context Model's data search from given conditions
448 *
449 * @see
450 */
451 class IConditionedModel : public IBase
452 {
453     public:
454         /**
455         * @fn     getBaseContextModel
456         * @brief Get base Context Model interface
457         *
458         * @param [out] IContextModel **ppBaseContextModel - Interface pointer for retrieving base Context Model interface.
459         *
460         * @return SSMRESULT
461         * @warning
462         * @exception
463         * @see
464         */
465         virtual SSMRESULT getBaseContextModel(OUT IContextModel **ppBaseContextModel) = 0;
466
467         /**
468         * @fn     registerConditionedModelEvent
469         * @brief Register for receiving triggered event from given conditions
470         *
471         * @param [in] IConditionedModelEvent *pConditionedModelEvent - Interface for listening events.
472         *
473         * @return SSMRESULT
474         * @warning
475         * @exception
476         * @see
477         */
478         virtual SSMRESULT registerConditionedModelEvent(IN IConditionedModelEvent *pConditionedModelEvent) =
479             0;
480
481         /**
482         * @fn     activateTrigger
483         * @brief Activate trigger using given conditions
484         *
485         * @param [out] int *pTriggerId - Activated trigger id.
486         *
487         * @return SSMRESULT
488         * @warning
489         * @exception
490         * @see
491         */
492         virtual SSMRESULT activateTrigger(OUT int *pTriggerId) = 0;
493
494         /**
495         * @fn     deactivateTrigger
496         * @brief Deactivate trigger that activated
497         *
498         * @param NONE
499         *
500         * @return SSMRESULT
501         * @warning
502         * @exception
503         * @see
504         */
505         virtual SSMRESULT deactivateTrigger() = 0;
506
507         /**
508         * @fn     hasAffectedData
509         * @brief Quries if current Conditioned Model has affected data
510         *
511         * @param NONE
512         *
513         * @return bool
514         * @warning
515         * @exception
516         * @see
517         */
518         virtual bool hasAffectedData() = 0;
519
520         /**
521         * @fn     getAffectedData
522         * @brief Get affected data from given conditions includes triggered data
523         *
524         * @param [out] IntVec   *pDataIds - Affected dataId sets.
525         *
526         * @return SSMRESULT
527         * @warning
528         * @exception
529         * @see
530         */
531         virtual SSMRESULT getAffectedData(OUT IntVec *pDataIds) = 0;
532
533         /**
534         * @fn     getWatchCondition
535         * @brief Get watching conditions created from Context Model
536         *
537         * @param [out] ModelConditionVec *pModelConditions - Affected dataId sets.
538         *
539         * @return SSMRESULT
540         * @warning
541         * @exception
542         * @see
543         */
544         virtual SSMRESULT getWatchCondition(OUT ModelConditionVec *pModelConditions) = 0;
545 };
546
547 static const OID OID_IConditionedQueryResult = { 0x4a24e85b, 0x8903, 0x4cf5, { 0x88, 0x7b, 0x65, 0xc2, 0xc3, 0x9e, 0x42, 0xfd } };
548 /**
549 * @class    IConditionedQueryResult
550 * @brief    IConditionedQueryResult Interface
551 *            This class represents executed CQL's result data
552 *
553 * @see
554 */
555 class IConditionedQueryResult : public IBase
556 {
557     public:
558         /**
559         * @fn     getConditionedModelCount
560         * @brief Get conditioned model count
561         *
562         * @param NONE
563         *
564         * @return unsigned int
565         * @warning
566         * @exception
567         * @see
568         */
569         virtual unsigned int getConditionedModelCount() = 0;
570
571         /**
572         * @fn     getConditionedContextModel
573         * @brief Get conditioned model by index
574         *
575         * @param [in] unsigned int conditionedModelIndex - Index of Conditioned Model interface for retrieving
576         * @param [out] IConditionedModel *pConditionedModel - Conditioned Model interface that contains results
577         *
578         * @return SSMRESULT
579         * @warning
580         * @exception
581         * @see
582         */
583         virtual SSMRESULT getConditionedContextModel(IN unsigned int conditionedModelIndex,
584                 OUT IConditionedModel **ppConditionedModel) = 0;
585 };
586
587 /**
588 * @class    IConditionedQueryEvent
589 * @brief    IConditionedQueryEvent Interface
590 *            This class represents event interface that listening IConditionedQuery's results
591 *
592 * @see
593 */
594 class IConditionedQueryEvent
595 {
596     public:
597         /**
598         * @fn onConditionedQueryEvent
599         * @brief IConditionedQueryEvent interface's event callbacks for receiving query results
600         *
601         * @param [in] std::string ContextQuery - Entered ContetxQuery
602         * @param [out] int* cqid - ID of ContextQuery
603         * @return SSMRESULT
604         * @warning
605         * @exception
606         * @see
607         */
608         virtual SSMRESULT onConditionedQueryEvent(IN int userTriggerId,
609                 IN IConditionedQueryResult *pConditionedQueryResult) = 0;
610         virtual ~IConditionedQueryEvent() {};
611 };
612
613 static const OID OID_IConditionedQuery = { 0xd61373d1, 0x9727, 0x4a84, { 0x98, 0x14, 0x4c, 0xf, 0xed, 0x25, 0x52, 0xe3 } };
614 /**
615 * @class    IConditionedQuery
616 * @brief    IConditionedQuery Interface
617 *            This class represents parsed CQL for data retrieving
618 *
619 * @see
620 */
621 class IConditionedQuery : public IBase
622 {
623     public:
624         /**
625         * @fn     registerConditionedModel
626         * @brief Register Conditioned Model for tracking triggers
627         *
628         * @param [in] IConditionedModel *pConditionedModel - Interface of Conditioned Model
629         *
630         * @return SSMRESULT
631         * @warning
632         * @exception
633         * @see
634         */
635         virtual SSMRESULT registerConditionedModel(IN IConditionedModel *pConditionedModel) = 0;
636
637         /**
638         * @fn     activateTriggers
639         * @brief Activate triggers for data evaluating. This changed related ContextModel's status to running
640         *
641         * @param [in] int userTriggerId - Specify TriggerId for event listening
642         *
643         * @return SSMRESULT
644         * @warning
645         * @exception
646         * @see
647         */
648         virtual SSMRESULT activateTriggers(IN int userTriggerId) = 0;
649
650         /**
651         * @fn     deactivateTriggers
652         * @brief Deactivate triggers for data evaluating.
653         *
654         * @param [in] int userTriggerId - Specify TriggerId for event listening
655         *
656         * @return SSMRESULT
657         * @warning
658         * @exception
659         * @see
660         */
661         virtual SSMRESULT deactivateTriggers() = 0;
662
663         /**
664         * @fn     getConditionedQueryResult
665         * @brief Retrieves conditioned data from current cached data
666         *
667         * @param [out] IConditionedQueryResult **ppConditionedQueryResult - Interface of result reader
668         *
669         * @return SSMRESULT
670         * @warning
671         * @exception
672         * @see
673         */
674         virtual SSMRESULT getConditionedQueryResult(OUT IConditionedQueryResult **ppConditionedQueryResult)
675             = 0;
676
677         /**
678         * @fn     hasAllConditionedModels
679         * @brief Retrieves current conditioned query has all Conditioned ContextModels for evaluating
680         *
681         * @param NONE
682         *
683         * @return bool
684         * @warning
685         * @exception
686         * @see
687         */
688         virtual bool hasAllConditionedModels() = 0;
689 };
690
691 static const OID OID_IContextModel = { 0xcc56003c, 0xa036, 0x4f27, { 0x9c, 0xb3, 0xdc, 0xaf, 0x1f, 0xb0, 0x81, 0x58 } };
692 /**
693 * @class    IContextModel
694 * @brief    IContextModel Interface
695 *            This class represents Context Model
696 *
697 * @see
698 */
699 class IContextModel : public IBase
700 {
701     public:
702         enum Status {STATUS_ACTIVATE, STATUS_DEACTIVATE, STATUS_START_READ_VALUE, STATUS_STOP_READ_VALUE};
703         enum ActivationType {ACTIVATION_TYPE_GET, ACTIVATION_TYPE_SUBSCRIBE};
704         enum ConstructionType {CONSTRUCTION_TYPE_INTERNAL, CONSTRUCTION_TYPE_EXTERNAL, CONSTRUCTION_TYPE_REMOTE};
705
706         /**
707         * @fn     getModelId
708         * @brief Get current model's id used for Evaluation Engine
709         *
710         * @param NONE
711         *
712         * @return int
713         * @warning
714         * @exception
715         * @see
716         */
717         virtual int getModelId() = 0;
718
719         /**
720         * @fn     getModelName
721         * @brief Get current model's name
722         *
723         * @param NONE
724         *
725         * @return std::string
726         * @warning
727         * @exception
728         * @see
729         */
730         virtual std::string getModelName() = 0;
731
732         /**
733         * @fn     getConstructionType
734         * @brief Get current model's constructionType defined when created
735         *
736         * @param NONE
737         *
738         * @return IContextModel::ConstructionType
739         * @warning
740         * @exception
741         * @see
742         */
743         virtual ConstructionType getConstructionType() = 0;
744
745         /**
746         * @fn     getParentDataId
747         * @brief Get parent dataId related to model hierarchy
748         *
749         * @param [in] int dataId - DataId that current model's
750         * @param [in] IContextModel *pParentModel - Designated parent Context Model
751         * @param [out] int *pParentDataId - Designated parent Context Model's data's Id
752         *
753         * @return SSMRESULT
754         * @warning
755         * @exception
756         * @see
757         */
758         virtual SSMRESULT getParentDataId(IN int dataId, IN IContextModel *pParentModel,
759                                           OUT int *pParentDataId) = 0;
760
761         /**
762         * @fn     getChildDataId
763         * @brief Get child dataId related to model hierarchy
764         *
765         * @param [in] int dataId - DataId that current model's
766         * @param [in] IContextModel *pChildModel - Designated child Context Model
767         * @param [out] int *pParentDataId - Designated child Context Model's data's Id
768         *
769         * @return SSMRESULT
770         * @warning
771         * @exception
772         * @see
773         */
774         virtual SSMRESULT getChildDataId(IN int dataId, IN IContextModel *pChildModel,
775                                          OUT IntVec *pPath) = 0;
776
777         /**
778         * @fn     activate
779         * @brief Activate current model's working. Each call to activate will increase internal reference counter
780         *
781         * @param [in] ActivationType activationType - Specify current model's working type
782         * @param [in] int targetDeviceDataId - Specify target device's dataId
783         *
784         * @return SSMRESULT
785         * @warning
786         * @exception
787         * @see
788         */
789         virtual SSMRESULT activate(IN ActivationType activationType, IN int targetDeviceDataId) = 0;
790
791         /**
792         * @fn     deactivate
793         * @brief Deactivate current model's working. Each call to deactivate will decrease internal reference counter\n
794         *        and finally deactivated when counter is 0
795         *
796         * @param [in] ActivationType activationType - Specify current model's working type
797         * @param [in] int targetDeviceDataId - Specify target device's dataId
798         *
799         * @return SSMRESULT
800         * @warning
801         * @exception
802         * @see
803         */
804         virtual SSMRESULT deactivate(IN ActivationType activationType, IN int targetDeviceDataId) = 0;
805         //virtual SSMRESULT GetModelSchema(OUT ModelPropertyVec *pModelProperties) = 0;
806
807         /**
808         * @fn     addModelData
809         * @brief Add model data to Context Model
810         *
811         * @param [in] int parentDataId - Specify current model's parent Context Model's dataId
812         * @param [in] ModelPropertyVec *pData - Packed data for adding
813         * @param [out] int *pDataId - Returned dataId that newly added
814         *
815         * @return SSMRESULT
816         * @warning
817         * @exception
818         * @see
819         */
820         virtual SSMRESULT addModelData(IN int parentDataId, IN ModelPropertyVec *pData,
821                                        OUT int *pDataId) = 0;
822
823         /**
824         * @fn     updateModelData
825         * @brief Update model data to Context Model
826         *
827         * @param [in] int dataId - DataId that provided AddModelData's execution
828         * @param [in] ModelPropertyVec *pData - Packed data for updating
829         *
830         * @return SSMRESULT
831         * @warning
832         * @exception
833         * @see
834         */
835         virtual SSMRESULT updateModelData(IN int dataId, IN ModelPropertyVec *pData) = 0;
836
837         /**
838         * @fn     deleteModelData
839         * @brief Delete model data using given index
840         *
841         * @param [in] int dataId - DataId that provided AddModelData's execution
842         *
843         * @return SSMRESULT
844         * @warning
845         * @exception
846         * @see
847         */
848         virtual SSMRESULT deleteModelData(IN int dataId) = 0;
849
850         /**
851         * @fn     getModelData
852         * @brief Get model data
853         *
854         * @param [in] int dataId - DataId that provided AddModelData's execution
855         * @param [out] ModelPropertyVec *pData - Packed data
856         *
857         * @return SSMRESULT
858         * @warning
859         * @exception
860         * @see
861         */
862         virtual SSMRESULT getModelData(IN int dataId, OUT ModelPropertyVec *pData) = 0;
863
864         /**
865         * @fn     getModelDataSet
866         * @brief Get model data set
867         *
868         * @param [in] int startIndex - Starting index of model data
869         * @param [in] int count - Number of data to retrieve
870         * @param [out] vector<ModelPropertyVec> *pData - Packed data
871         * @param [out] int *pLastIndex - Index of last data
872         *
873         * @return SSMRESULT
874         * @warning
875         * @exception
876         * @see
877         */
878         virtual SSMRESULT getModelDataSet(IN int startIndex, IN int count,
879                                           OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex) = 0;
880
881         /**
882         * @fn     createConditionedModel
883         * @brief Create Conditioned Model for data searching or triggering
884         *
885         * @param [in] ModelConditionVec *pModelConditionVec - Conditions that searching or triggering
886         * @param [out] IConditionedModel **ppConditionedModel - Created Conditioned Model interface
887         *
888         * @return SSMRESULT
889         * @warning
890         * @exception
891         * @see
892         */
893         virtual SSMRESULT createConditionedModel(IN ModelConditionVec *pModelConditionVec,
894                 OUT IConditionedModel **ppConditionedModel) = 0;
895         //virtual SSMRESULT CleanUpModelData() = 0;
896
897         /**
898         * @fn     setLifeTime
899         * @brief Sets current model data's lifeTime
900         *
901         * @param [in] int seconds - model data's lifeTime
902         *
903         * @return NONE
904         * @warning
905         * @exception
906         * @see
907         */
908         virtual void setLifeTime(std::string seconds) = 0;
909 };
910
911 /**
912 * @class    IContextModelEvent
913 * @brief    IContextModelEvent Interface
914 *            This class represents event interface for tracking IContextModel events
915 *
916 * @see
917 *
918 * Copyright 2013 by Samsung Electronics, Inc.,
919 *
920 * This software is the confidential and proprietary information
921 * of Samsung Electronics, Inc. ("Confidential Information").  You
922 * shall not disclose such Confidential Information and shall use
923 * it only in accordance with the terms of the license agreement
924 * you entered into with Samsung.
925 */
926 class IContextModelEvent
927 {
928     public:
929         /**
930         * @fn     onModelStatusChange
931         * @brief Called when ContextModel wants to activate or deactivate
932         *
933         * @param [in] IContextModel::Status newStatus - Context Model's new status
934         * @param [in] ISSMResource *pSSMResource - Instance of actual resource
935         * @param [in] IContextModel *pModel - Affected Context Model
936         *
937         * @return SSMRESULT
938         * @warning
939         * @exception
940         * @see
941         */
942         virtual SSMRESULT onModelStatusChange(IN IContextModel::Status newStatus,
943                                               IN ISSMResource *pSSMResource, IN IContextModel *pModel) = 0;
944         virtual ~IContextModelEvent() {}
945 };
946
947 /**
948 * @class    IContextModelAccessor
949 * @brief    IContextModelAccessor Interface
950 *            This class represents context model accessors
951 *
952 * @see
953 */
954 class IContextModelAccessor
955 {
956     public:
957         /**
958         * @fn     onQueryContextModel
959         * @brief Called when ContextModelAccessor wants to query installed ContextModel
960         *
961         * @param [in] std::string modelName - ContextModel name to find out
962         * @param [out] IContextModel **ppContextModel - Interface of quried ContextModel
963         *
964         * @return SSMRESULT
965         * @warning
966         * @exception
967         * @see
968         */
969         virtual SSMRESULT onQueryContextModel(IN std::string modelName,
970                                               OUT IContextModel **ppContextModel) = 0;
971         virtual ~IContextModelAccessor() {}
972 };
973
974 static const OID OID_IContextDataReader = { 0x65ce481, 0xc5dd, 0x41dc, { 0xa3, 0xc1, 0xa4, 0x98, 0xc9, 0xa8, 0xcc, 0xd5 } };
975 /**
976 * @class    IContextDataReader
977 * @brief    IContextDataReader Interface
978 *            This class represents context model database reader for context model developers
979 *
980 * @see
981 */
982 class IContextDataReader : public IBase
983 {
984     public:
985         /**
986         * @fn     registerContextModelAccessor
987         * @brief Called when ContextModelAccessor wants to query installed ContextModel
988         *
989         * @param [in] IContextModelAccessor *pContextModelAccessor - Instance of implemented IContextModelAccessor interface
990         *
991         * @return SSMRESULT
992         * @warning
993         * @exception
994         * @see
995         */
996         virtual SSMRESULT registerContextModelAccessor(IN IContextModelAccessor *pContextModelAccessor) = 0;
997
998         /**
999         * @fn     getContextData
1000         * @brief Retrieve ContextData using given ContextModel name and dataId
1001         *
1002         * @param [in] std::string modelName - ContextModel name
1003         * @param [in] int startIndex - Starting index of model data
1004         * @param [in] int count - Number of data to retrieve
1005         * @param [out] std::vector<ContextData> *data - ContextData set
1006         * @param [out] int *pLastIndex - Index of last data
1007         *
1008         * @return SSMRESULT
1009         * @warning
1010         * @exception
1011         * @see
1012         */
1013         virtual SSMRESULT getContextData(IN std::string modelName, IN int startIndex, IN int count,
1014                                          OUT std::vector<ContextData> *data, OUT int *pLastIndex) = 0;
1015 };
1016
1017 typedef std::vector<std::pair<std::string, ModelConditionVec> > QueryCondition;
1018
1019 static const OID OID_IPropagationEngine = { 0xeb7e3d6c, 0x2cae, 0x43b3, { 0xb9, 0xae, 0x1b, 0xa, 0x6c, 0xdd, 0x9, 0xeb } };
1020 /**
1021 * @class    IPropagationEngine
1022 * @brief    IPropagationEngine Interface
1023 *            This class represents propagation engine that manages ContextModel's automation
1024 *
1025 * @see
1026 */
1027 class IPropagationEngine : public IBase
1028 {
1029     public:
1030         /**
1031         * @fn     getContextModel
1032         * @brief Retrieve ContextModel interface specified name
1033         *
1034         * @param [in] std::string modelName - ContextModel's name that looking for
1035         * @param [out] IContextModel **ppContextModel - Interface pointer for retrieving
1036         *
1037         * @return SSMRESULT
1038         * @warning
1039         * @exception
1040         * @see
1041         */
1042         virtual SSMRESULT getContextModel(IN std:: string modelName,
1043                                           OUT IContextModel **ppContextModel) = 0;
1044
1045         /**
1046         * @fn     createConditionedQuery
1047         * @brief Create Conditioned Query using conditions
1048         *
1049         * @param [in] IContextModel::ActivationType activationType - ActivationType for ContextModel's working strategy
1050         * @param [in] QueryCondition *pQueryCondition - Conditions for data retrieving
1051         * @param [in] IConditionedQueryEvent *pEvent - Event interface for Conditioned Result listening
1052         * @param [out] IConditionedQuery **ppConditionedQuery - Interface for retrieving Conditioned Query
1053         *
1054         * @return SSMRESULT
1055         * @warning
1056         * @exception
1057         * @see
1058         */
1059         virtual SSMRESULT createConditionedQuery(IN IContextModel::ActivationType activationType,
1060                 IN QueryCondition *pQueryCondition,
1061                 IN IConditionedQueryEvent *pEvent, OUT IConditionedQuery **ppConditionedQuery) = 0;
1062 };
1063
1064 static const OID OID_IQueryEngineInternal = { 0x6eabf1a9, 0xe884, 0x4562, { 0x8b, 0x90, 0x1e, 0xe8, 0xba, 0xbf, 0xbe, 0x1a } };
1065 /**
1066 * @class    IQueryEngineInternal
1067 * @brief    IQueryEngineInternal Interface
1068 *           This class manages ContextQuery at backend side.
1069 *
1070 * @see
1071 *           CObject<CQueryEngine>   *pQueryEngine;
1072 *           CreateInstance(OID_IQueryEngineInternal, (IBase**)&pQueryEngine);
1073 *           pQeuryEngine->ExecuteContextQuery(contextquery,cqid);
1074 */
1075 class IQueryEngineInternal : public IBase
1076     , public IQueryEngine
1077 {
1078 };
1079
1080 static const OID OID_IContextExecutor = { 0x92dcc900, 0xdc8a, 0x474b, { 0x87, 0x45, 0x4d, 0x0, 0xe4, 0xd1, 0x52, 0x2b } };
1081 /**
1082  * @class    IContextExecutor
1083  * @brief    Interface for execute context model.
1084  *           Delegate requested context to lower layer.
1085  *           Execute context model.
1086  *
1087  * @see
1088  */
1089 class IContextExecutor : public IBase
1090     , public IEvent
1091     , public ICtxDelegate
1092 {
1093     public:
1094         /**
1095         * @fn     registerContext
1096         * @brief  Register Context for receiving values
1097         *
1098         * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
1099         * @param [in] ISSMResource *pSSMResouce - Requested Context model
1100         * @param [in] IEvent *pEvent - Event interface for receiving data
1101         *
1102         * @return SSMRESULT
1103         * @warning
1104         * @exception
1105         * @see
1106         */
1107         virtual void registerContext(TypeofEvent callType, ISSMResource *pSSMResouce, IEvent *pEvent) = 0;
1108
1109         /**
1110         * @fn     unregisterContext
1111         * @brief  Unregister Context for receiving values
1112         *
1113         * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
1114         * @param [in] ISSMResource *pSSMResouce - Requested Context model
1115         * @param [in] IEvent *pEvent - Event interface for receiving data
1116         *
1117         * @return SSMRESULT
1118         * @warning
1119         * @exception
1120         * @see
1121         */
1122         virtual void unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource,
1123                                        IEvent *pEvent) = 0;
1124 };
1125
1126 static const OID OID_ISensingEngine = { 0x3140a3dc, 0xf912, 0x4d88, { 0x97, 0x3c, 0x86, 0xe8, 0x35, 0x69, 0xa7, 0xf8 } };
1127 /**
1128  * @class    ISensingEngine
1129  * @brief    Class for implementing main abstration of SensorProcessor
1130  *
1131  *
1132  * @see
1133  */
1134 class ISensingEngine : public IBase
1135     , public IEvent
1136 {
1137     public:
1138         /**
1139         * @fn     registerContext
1140         * @brief  Register Context for receiving values
1141         *
1142         * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
1143         * @param [in] ISSMResource *pSSMResouce - Requested Context model
1144         * @param [in] IEvent *pEvent - Event interface for receiving data
1145         *
1146         * @return SSMRESULT
1147         * @warning
1148         * @exception
1149         * @see
1150         */
1151         virtual SSMRESULT registerContext(TypeofEvent callType, ISSMResource *pSSMResouce,
1152                                           IEvent *pEvent) = 0;
1153
1154         /**
1155         * @fn     unregisterContext
1156         * @brief  Unregister Context for receiving values
1157         *
1158         * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
1159         * @param [in] ISSMResource *pSSMResouce - Requested Context model
1160         * @param [in] IEvent *pEvent - Event interface for receiving data
1161         *
1162         * @return SSMRESULT
1163         * @warning
1164         * @exception
1165         * @see
1166         */
1167         virtual SSMRESULT unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource,
1168                                             IEvent *pEvent) = 0;
1169
1170         /**
1171         * @fn    getList
1172         * @brief Get all available context models
1173         *
1174         * @param [out] std::vector<ISSMResource*> *pList - List of available context model
1175         *
1176         * @return NONE
1177         * @warning
1178         * @exception
1179         * @see
1180         */
1181         virtual SSMRESULT getList(std::vector<ISSMResource *> *pList) = 0;
1182 };
1183
1184 class IResourceFinderEvent
1185 {
1186     public:
1187         virtual SSMRESULT onResourceFound(IN ISSMResource *pSensor) = 0;
1188         virtual SSMRESULT onResourceLost(IN ISSMResource *pSensor) = 0;
1189         virtual ~IResourceFinderEvent() {}
1190 };
1191
1192 static const OID OID_IResourceFinder = { 0x8f52a31f, 0x51d5, 0x462b, { 0xa9, 0x8d, 0x40, 0x70, 0xa3, 0xf6, 0xb5, 0x6f } };
1193 class IResourceFinder : public IBase
1194 {
1195     public:
1196         virtual SSMRESULT registerResourceFinderEvent(IN IResourceFinderEvent *pEvent) = 0;
1197         virtual SSMRESULT startResourceFinder() = 0;
1198         virtual SSMRESULT startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent) = 0;
1199         virtual SSMRESULT stopObserveResource(IN ISSMResource *pSensor) = 0;
1200 };
1201
1202 /**
1203 * @class    ISoftSensorManager
1204 * @brief    ISoftSensorManager Interface
1205 *            This class represents main interface of SSM.
1206 *
1207 * @see
1208 *           static ISoftSensorManager       *g_pSoftSensorManager = NULL;
1209 *           CreateInstance(OID_ISoftSensorManager, (IBase**)&g_pSoftSensorManager);
1210 *           g_pSoftSensorManager->TerminateCore();
1211 *           g_pSoftSensorManager->Release();
1212 */
1213 static const OID OID_ISoftSensorManager = { 0x6b9ce4cb, 0x31fe, 0x4b05, { 0xb4, 0xca, 0x10, 0x3d, 0x82, 0x59, 0x4f, 0x4d } };
1214 class ISoftSensorManager : public IBase
1215 {
1216     public:
1217         /**
1218         * @fn initializeCore
1219         * @brief Initialize core using given configuration information.
1220         *           <SSMCore>
1221         *               <Device>
1222         *                   <UDN>windows7-31f8-11b4-a222-08002b34c003</UDN>
1223         *                   <Name>MyPC</Name>
1224         *                   <Type>PC</Type>
1225         *               </Device>
1226         *           </SSMCore>
1227         *
1228         * @param [in] std::string xmlDescription - specification described in XML
1229         * @param [out] IBase** ppvObject - reference pointer to get instance pointer
1230         * @return SSMRESULT
1231         * @warning
1232         * @exception
1233         * @see
1234         */
1235         virtual SSMRESULT initializeCore(IN std::string xmlDescription) = 0;
1236
1237         /**
1238         * @fn startCore
1239         * @brief Start Core.
1240         *         This enables network capability that can discover and discovered.
1241         *
1242         * @param None
1243         * @return SSMRESULT
1244         * @warning
1245         * @exception
1246         * @see
1247         */
1248         virtual SSMRESULT startCore() = 0;
1249
1250         /**
1251         * @fn stopCore
1252         * @brief Stop Core.
1253         *         This disables network capability that can discover and discovered.
1254         *
1255         * @param None
1256         * @return SSMRESULT
1257         * @warning
1258         * @exception
1259         * @see
1260         */
1261         virtual SSMRESULT stopCore() = 0;
1262
1263         /**
1264         * @fn terminateCore
1265         * @brief Terminates Core.
1266         *         Free all allocated resources
1267         *
1268         * @param None
1269         * @return SSMRESULT
1270         * @warning
1271         * @exception
1272         * @see
1273         */
1274         virtual SSMRESULT terminateCore(IN bool factoryResetFlag) = 0;
1275
1276         /**
1277         * @fn createQueryEngine
1278         * @brief Create new Query Engine instance.
1279         *         Each engine instance has it's own event thread
1280         *         we recommend each application should creates only one instance.
1281         *
1282         * @param [out] IQueryEngine **ppQueryEngine - instance pointer of new Query Engine
1283         * @return SSMRESULT
1284         * @warning
1285         * @exception
1286         * @see
1287         */
1288         virtual SSMRESULT createQueryEngine(OUT IQueryEngine **ppQueryEngine) = 0;
1289
1290         /**
1291         * @fn releaseQueryEngine
1292         * @brief Release exists Query Engine instance.
1293         *
1294         * @param [in] IQueryEngine *pQueryEngine - instance pointer of exists Query Engine
1295         * @return SSMRESULT
1296         * @warning
1297         * @exception
1298         * @see
1299         */
1300         virtual unsigned long releaseQueryEngine(IN IQueryEngine *pQueryEngine) = 0;
1301
1302         /**
1303         * @fn getInstalledModelList
1304         * @brief Gets all installed models from local and remote
1305         *
1306         * @param [out] std::vector<ISSMResource*> *pList - List of installed context model
1307         *
1308         * @return SSMRESULT
1309         * @warning
1310         * @exception
1311         * @see
1312         */
1313         virtual SSMRESULT getInstalledModelList(OUT std::vector<ISSMResource *> *pList) = 0;
1314 };
1315 #endif