Imported Upstream version 0.9.2
[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 #if defined(WIN32)
27
28 #if defined(SSMSENSOR_WINDOWS_EXPORTS)
29 #define INTERFACE_DECLSPEC    __declspec(dllexport)
30 #elif defined(WIN32)
31 #define INTERFACE_DECLSPEC    __declspec(dllimport)
32 #endif
33
34 #elif defined(TIZEN)
35
36 #include <tizen.h>
37
38 #define INTERFACE_DECLSPEC EXPORT_API
39
40 #else
41
42 #define INTERFACE_DECLSPEC
43
44 #endif
45
46 #define SSM_MODEL_RETRY 3
47 typedef enum {SSM_ONCE, SSM_REPEAT} TypeofEvent;
48 typedef enum {SSM_EVENT_NORMAL, SSM_EVENT_ADDED, SSM_REMOVED, SSM_UPDATED} RESOURCE_EVENT_TYPE;
49 typedef enum {SENSOR_LOCATION_REMOTE, SENSOR_LOCATION_LOCAL} SENSOR_LOCATION;
50 class ISSMResource
51 {
52     public:
53         ISSMResource()
54         {
55             location = SENSOR_LOCATION_LOCAL;
56             connectivityType = 0;
57         }
58         ISSMResource(const std::string &n, const std::string &t) :
59             name(n), type(t)
60         {
61             location = SENSOR_LOCATION_LOCAL;
62             connectivityType = 0;
63         }
64         SENSOR_LOCATION location;
65         std::string name;
66         std::string type;
67         std::string friendlyName;
68         std::string ip;
69         int connectivityType;
70         std::vector<std::string> inputList;
71         std::vector<std::map<std::string, std::string> > outputProperty;
72 };
73
74 class ContextData
75 {
76     public:
77         std::string rootName;
78         int outputPropertyCount;
79         std::vector< std::map<std::string, std::string> > outputProperty;
80 };
81
82 struct ResourceResult
83 {
84     std::string deviceID;
85     TypeofEvent callType;
86     ContextData ctxData;
87 };
88
89 enum CTX_EVENT_TYPE {SPF_START, SPF_UPDATE, SPF_END};
90
91 class ICtxEvent
92 {
93     public:
94         virtual void onCtxEvent(enum CTX_EVENT_TYPE, std::vector<ContextData>) = 0 ;
95         virtual ~ICtxEvent() {};
96 };
97
98 class IEvent
99 {
100     public:
101         virtual int onEvent(std::string deviceID, TypeofEvent callType,
102                             std::vector<ContextData> ctxData) = 0;
103         std::string appId;
104         virtual ~IEvent() {};
105 };
106
107 class IResourceEvent
108 {
109     public:
110         virtual int onResourceEvent(RESOURCE_EVENT_TYPE eventType, ISSMResource *pSSMResource,
111                                     std::string info) = 0;
112         virtual ~IResourceEvent() {};
113 };
114
115 class ICtxDelegate
116 {
117     public:
118         virtual void registerCallback(ICtxEvent *pEvent) = 0;
119         virtual void addOutput(std::vector<ContextData>) = 0;
120         virtual void getDataFromDatabase(std::string modelName, int startIndex, int count,
121                                          std::vector<ContextData> *data, int *pLastIndex) = 0;
122         virtual ~ICtxDelegate() {};
123 };
124
125 #endif