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"
25 #include "RamlParser.h"
27 class SimulatorResourceFactory;
28 class SimulatorCollectionResourceImpl : public SimulatorCollectionResource
31 friend class SimulatorResourceFactory;
33 std::string getName() const;
34 SimulatorResource::Type getType() const;
35 std::string getURI() const;
36 std::string getResourceType() const;
37 std::vector<std::string> getInterface() const;
40 SimulatorResourceModel getResourceModel();
41 void setInterface(const std::vector<std::string> &interfaces);
42 void setName(const std::string &name);
43 void setURI(const std::string &uri);
44 void setResourceType(const std::string &resourceType);
45 void addInterface(std::string interfaceType);
46 void setObservable(bool state);
47 void setObserverCallback(ObserverCallback callback);
48 void setModelChangeCallback(ResourceModelChangedCallback callback);
51 std::vector<ObserverInfo> getObserversList();
55 std::vector<std::string> getSupportedResources();
56 void addChildResource(SimulatorResourceSP &resource);
57 void removeChildResource(SimulatorResourceSP &resource);
58 void removeChildResource(const std::string &uri);
59 std::vector<SimulatorResourceSP> getChildResources();
61 void setResourceModel(const SimulatorResourceModel &resModel);
63 void setActionType(std::map<RAML::ActionType, RAML::ActionPtr> &actionType);
65 RAML::ActionType getActionType(std::string requestType);
68 SimulatorCollectionResourceImpl();
70 OCEntityHandlerResult handleRequests(std::shared_ptr<OC::OCResourceRequest> request);
71 std::shared_ptr<OC::OCResourceResponse> requestOnBaseLineInterface(
72 std::shared_ptr<OC::OCResourceRequest> request);
73 std::shared_ptr<OC::OCResourceResponse> requestOnLinkListInterface(
74 std::shared_ptr<OC::OCResourceRequest> request);
75 std::shared_ptr<OC::OCResourceResponse> requestOnBatchInterface(
76 std::shared_ptr<OC::OCResourceRequest> request);
77 void sendNotification(OC::ObservationIds &observers);
78 void addLink(SimulatorResourceSP &resource);
79 void removeLink(std::string uri);
81 SimulatorResource::Type m_type;
84 std::string m_resourceType;
85 std::vector<std::string> m_interfaces;
87 std::mutex m_modelLock;
88 SimulatorResourceModel m_resModel;
89 std::recursive_mutex m_objectLock;
90 std::mutex m_childResourcesLock;
91 std::map<std::string, SimulatorResourceSP> m_childResources;
92 std::vector<std::string> m_supportedTypes;
93 std::vector<ObserverInfo> m_observersList;
94 ObserverCallback m_observeCallback;
95 ResourceModelChangedCallback m_modelCallback;
96 std::map<RAML::ActionType , RAML::ActionPtr> m_actionTypes;
98 OCResourceProperty m_property;
99 OCResourceHandle m_resourceHandle;