c670db380441feac8f71f10edeaf9da0e5f21913
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SSMCore / src / SSMInterface / SSMModelDefinition.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 _SSMModelDefinition_H_
21 #define _SSMModelDefinition_H_
22 #include <map>
23 #include <string>
24 #include <vector>
25
26 #define SSM_MODEL_RETRY 3
27 typedef enum {SSM_ONCE, SSM_REPEAT} TypeofEvent;
28 typedef enum {SSM_EVENT_NORMAL, SSM_EVENT_ADDED, SSM_REMOVED, SSM_UPDATED} RESOURCE_EVENT_TYPE;
29 typedef enum {SENSOR_LOCATION_REMOTE, SENSOR_LOCATION_LOCAL} SENSOR_LOCATION;
30 class ISSMResource
31 {
32     public:
33         ISSMResource()
34         {
35             location = SENSOR_LOCATION_LOCAL;
36         }
37         ISSMResource(const std::string &n, const std::string &t) :
38             name(n), type(t)
39         {
40         }
41         SENSOR_LOCATION location;
42         std::string name;
43         std::string type;
44         std::string friendlyName;
45         std::string ip;
46         std::vector<std::string> inputList;
47         std::vector<std::map<std::string, std::string> > outputProperty;
48 };
49
50 class ContextData
51 {
52     public:
53         std::string rootName;
54         int outputPropertyCount;
55         std::vector< std::map<std::string, std::string> > outputProperty;
56 };
57
58 struct ResourceResult
59 {
60     std::string deviceID;
61     TypeofEvent callType;
62     ContextData ctxData;
63 };
64
65 enum CTX_EVENT_TYPE {SPF_START, SPF_UPDATE, SPF_END};
66
67 class ICtxEvent
68 {
69     public:
70         virtual void onCtxEvent(enum CTX_EVENT_TYPE, std::vector<ContextData>) = 0 ;
71         virtual ~ICtxEvent() {};
72 };
73
74 class IEvent
75 {
76     public:
77         virtual int onEvent(std::string deviceID, TypeofEvent callType,
78                             std::vector<ContextData> ctxData) = 0;
79         std::string appId;
80         virtual ~IEvent() {};
81 };
82
83 class IResourceEvent
84 {
85     public:
86         virtual int onResourceEvent(RESOURCE_EVENT_TYPE eventType, ISSMResource *pSSMResource,
87                                     std::string info) = 0;
88         virtual ~IResourceEvent() {};
89 };
90
91 class ICtxDelegate
92 {
93     public:
94         virtual void registerCallback(ICtxEvent *pEvent) = 0;
95         virtual void addOutput(std::vector<ContextData>) = 0;
96         virtual void getDataFromDatabase(std::string modelName, int startIndex, int count,
97                                          std::vector<ContextData> *data, int *pLastIndex) = 0;
98         virtual ~ICtxDelegate() {};
99 };
100
101 #endif