Imported Upstream version 1.0.1
[platform/upstream/iotivity.git] / service / simulator / src / service-provider / simulator_resource_server_impl.h
1 /******************************************************************
2  *
3  * Copyright 2015 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
21 #ifndef SIMULATOR_RESOURCE_SERVER_IMPL_H_
22 #define SIMULATOR_RESOURCE_SERVER_IMPL_H_
23
24 #include "simulator_resource_server.h"
25 #include "resource_update_automation_mngr.h"
26
27 class SimulatorResourceServerImpl : public SimulatorResourceServer
28 {
29     public:
30         SimulatorResourceServerImpl();
31
32         void setURI(const std::string &uri);
33
34         void setResourceType(const std::string &resourceType);
35
36         void setInterfaceType(const std::string &interfaceType);
37
38         void setName(const std::string &name);
39
40         void setObservable(bool state);
41
42         bool isObservable() const;
43
44         int startUpdateAutomation(AutomationType type, int updateInterval,
45                                   updateCompleteCallback callback);
46
47         int startUpdateAutomation(const std::string &attrName, AutomationType type,
48                                   int updateInterval, updateCompleteCallback callback);
49
50         std::vector<int> getResourceAutomationIds();
51
52         std::vector<int> getAttributeAutomationIds();
53
54         void stopUpdateAutomation(const int id);
55
56         void setModelChangeCallback(ResourceModelChangedCB callback);
57
58         void setObserverCallback(ObserverCB callback);
59
60         std::vector<ObserverInfo> getObserversList();
61
62         void notify(uint8_t id);
63
64         void notifyAll();
65
66         void start();
67
68         void stop();
69
70         void notifyApp();
71
72     private:
73         OC::OCRepresentation getOCRepresentation();
74         bool modifyResourceModel(OC::OCRepresentation &ocRep);
75         OCEntityHandlerResult entityHandler(std::shared_ptr<OC::OCResourceRequest> request);
76         void resourceModified();
77
78         ResourceModelChangedCB m_callback;
79         ObserverCB m_observeCallback;
80         UpdateAutomationMngr m_updateAutomationMgr;
81         std::vector<ObserverInfo> m_observersList;
82
83         OCResourceProperty m_property;
84         OCResourceHandle m_resourceHandle;
85 };
86
87 typedef std::shared_ptr<SimulatorResourceServerImpl> SimulatorResourceServerImplSP;
88
89 #endif