1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
21 #ifndef SIMULATOR_COLLECTION_RESOURCE_IMPL_H_
22 #define SIMULATOR_COLLECTION_RESOURCE_IMPL_H_
24 #include "simulator_collection_resource.h"
26 class SimulatorResourceFactory;
27 class SimulatorCollectionResourceImpl : public SimulatorCollectionResource
30 friend class SimulatorResourceFactory;
32 std::string getName() const;
33 SimulatorResource::Type getType() const;
34 std::string getURI() const;
35 std::string getResourceType() const;
36 std::vector<std::string> getInterface() const;
39 SimulatorResourceModel getResourceModel();
40 void setInterface(const std::vector<std::string> &interfaces);
41 void setName(const std::string &name);
42 void setURI(const std::string &uri);
43 void setResourceType(const std::string &resourceType);
44 void addInterface(std::string interfaceType);
45 void setObservable(bool state);
46 void setObserverCallback(ObserverCallback callback);
47 void setModelChangeCallback(ResourceModelChangedCallback callback);
50 std::vector<ObserverInfo> getObserversList();
54 std::vector<std::string> getSupportedResources();
55 void addChildResource(SimulatorResourceSP &resource);
56 void removeChildResource(SimulatorResourceSP &resource);
57 void removeChildResource(const std::string &uri);
58 std::vector<SimulatorResourceSP> getChildResources();
60 void setResourceModel(const SimulatorResourceModel &resModel);
63 SimulatorCollectionResourceImpl();
65 OCEntityHandlerResult handleRequests(std::shared_ptr<OC::OCResourceRequest> request);
66 std::shared_ptr<OC::OCResourceResponse> requestOnBaseLineInterface(
67 std::shared_ptr<OC::OCResourceRequest> request);
68 std::shared_ptr<OC::OCResourceResponse> requestOnLinkListInterface(
69 std::shared_ptr<OC::OCResourceRequest> request);
70 std::shared_ptr<OC::OCResourceResponse> requestOnBatchInterface(
71 std::shared_ptr<OC::OCResourceRequest> request);
72 void sendNotification(OC::ObservationIds &observers);
73 void addLink(SimulatorResourceSP &resource);
74 void removeLink(std::string uri);
76 SimulatorResource::Type m_type;
79 std::string m_resourceType;
80 std::vector<std::string> m_interfaces;
82 std::mutex m_modelLock;
83 SimulatorResourceModel m_resModel;
84 std::recursive_mutex m_objectLock;
85 std::mutex m_childResourcesLock;
86 std::map<std::string, SimulatorResourceSP> m_childResources;
87 std::vector<std::string> m_supportedTypes;
88 std::vector<ObserverInfo> m_observersList;
89 ObserverCallback m_observeCallback;
90 ResourceModelChangedCallback m_modelCallback;
92 OCResourceProperty m_property;
93 OCResourceHandle m_resourceHandle;