iotivity 0.9.0
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SSMCore / src / SensorProcessor / SensingEngine.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 _ResponseReactor_H_
21 #define _ResponseReactor_H_
22
23 #include "SSMInterface/SSMCore.h"
24 #include "Common/PlatformLayer.h"
25 #include "Common/InternalInterface.h"
26
27 /**
28  * @class    CSensingEngine
29  * @brief    Class for implementing main abstration of SensorProcessor
30  *
31  *
32  * @see
33  */
34 class CSensingEngine :
35     public CObjectRoot<CObjectMultiThreadModel>
36     , public ISensingEngine
37 {
38     private:
39         CObjectPtr<IContextRepository>  m_pContextRepository;
40         CObjectPtr<IContextExecutor>    m_pContextExecutor;
41
42         /**
43         * @brief requested high layer's callback data.(IEvent instance, deviceId, call type)
44         */
45         std::map<std::string, CallbackData > m_requestedCallbackData;
46
47         /**
48         * @brief Context model data from lower layer(OnEvent Callback)
49         */
50         std::map<std::string, std::vector<ContextData> > m_storedLowerContextData;
51
52         CSimpleMutex                        m_mtxRequestedContextData;
53         CSimpleMutex                        m_mtxUnregisterContext;
54
55     public:
56         SSMRESULT finalConstruct();
57         void finalRelease();
58
59         SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
60         {
61             if (ppObject == NULL)
62                 return SSM_E_POINTER;
63
64             if (IsEqualOID(objectID, OID_ISensingEngine))
65             {
66                 IBase *pBase = this;
67                 pBase->addRef();
68                 *ppObject = pBase;
69                 return SSM_S_OK;
70             }
71
72             return SSM_E_NOINTERFACE;
73         }
74
75         /**
76         * @fn           registerContext
77         * @brief        Register context model request.
78         *
79         * @param        [in]  TypeofEvent callType -  Type of event. SSM_ONCE or SSM_REPEAT
80         * @param        [in]  ISSMResource *pSSMResource -  Requested context model resource.
81         * @param        [in]  IEvent *pEvent -  IEvent class for callback.
82         *
83         * @return       SSMRESULT
84         *
85         * @warning
86         * @exception
87         * @see
88         */
89         SSMRESULT registerContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource,
90                                   IN IEvent *pEvent);
91
92         /**
93         * @fn           unregisterContext
94         * @brief        Unregister context model request.
95         *
96         * @param        [in]  TypeofEvent callType -  Type of event. SSM_ONCE or SSM_REPEAT
97         * @param        [in]  ISSMResource *pSSMResource -  Requested context model resource.
98         * @param        [in]  IEvent *pEvent -  IEvent class for callback.
99         *
100         * @return       SSMRESULT
101         *
102         * @warning
103         * @exception
104         * @see
105         */
106         SSMRESULT  unregisterContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource,
107                                      IN IEvent *pEvent);
108
109         /**
110         * @fn           getList
111         * @brief        Get context model list
112         *
113         * @param        [out]  std::vector<ISSMResource> *pList - ISSMResource vector of low level context models or high level context models.
114         *
115         * @return       SSMRESULT
116         *
117         * @warning
118         * @exception
119         * @see
120         */
121         SSMRESULT getList(OUT std::vector<ISSMResource *> *pList);
122
123         /**
124         * @fn           onEvent
125         * @brief        IEvent Interface.
126         *               Call from executor when context model data generated.
127         *
128         * @param        [in]  std::string name - caller Resource name.
129         * @param        [in]  TypeofEvent callType -  context event type.
130         * @param        [in]  std::vector<ContextData> ctxData -  context data
131         *
132         * @return       int - function result status
133         *
134         * @warning
135         * @exception
136         * @see
137         */
138         int onEvent(IN std::string name, IN TypeofEvent callType, IN std::vector<ContextData> ctxData);
139 };
140 #endif