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 ******************************************************************/
22 * @file simulator_remote_resource_impl.h
24 * @brief This file provides internal implementation of simulator remote resource functionalities.
28 #ifndef SIMULATOR_REMOTE_RESOURCE_IMPL_H_
29 #define SIMULATOR_REMOTE_RESOURCE_IMPL_H_
31 #include "simulator_remote_resource.h"
32 #include "request_automation_manager.h"
33 #include "RamlParser.h"
34 #include "request_model.h"
35 #include "request_sender.h"
39 class SimulatorRemoteResourceImpl : public SimulatorRemoteResource
42 SimulatorRemoteResourceImpl(const std::shared_ptr<OC::OCResource> &ocResource);
43 std::string getURI() const;
44 std::string getHost() const;
45 std::string getID() const;
46 SimulatorConnectivityType getConnectivityType() const;
47 std::vector < std::string > getResourceTypes() const;
48 std::vector < std::string > getInterface() const;
49 bool isObservable() const;
51 void observe(ObserveType type, ObserveNotificationCallback callback);
54 void get(const GetResponseCallback &callback);
55 void get(const std::map<std::string, std::string> &queryParams,
56 const GetResponseCallback &callback);
57 void get(const std::string &interfaceType,
58 const std::map<std::string, std::string> &queryParams,
59 const GetResponseCallback &callback);
61 void put(const SimulatorResourceModel &representation,
62 const PutResponseCallback &callback);
63 void put(const std::map<std::string, std::string> &queryParams,
64 const SimulatorResourceModel &representation,
65 const PutResponseCallback &callback);
66 void put(const std::string &interfaceType,
67 const std::map<std::string, std::string> &queryParams,
68 const SimulatorResourceModel &representation,
69 const PutResponseCallback &callback);
71 void post(const SimulatorResourceModel &resourceModel,
72 const PostResponseCallback &callback);
73 void post(const std::map<std::string, std::string> &queryParams,
74 const SimulatorResourceModel &representation,
75 const PostResponseCallback &callback);
76 void post(const std::string &interfaceType,
77 const std::map<std::string, std::string> &queryParams,
78 const SimulatorResourceModel &representation,
79 const PostResponseCallback &callback);
81 std::map<RequestType, SimulatorRequestModel> configure(
82 const std::string &path);
83 int startAutoRequesting(RequestType type, AutoRequestGenerationCallback callback);
84 void stopAutoRequesting(int id);
87 void configure(const std::shared_ptr<RAML::Raml> &raml);
88 void onResponseReceived(SimulatorResult result, const SimulatorResourceModel &resourceModel,
89 const RequestInfo &reqInfo, ResponseCallback callback);
90 void onAutoRequestingState(int sessionId, OperationState state,
91 AutoRequestGenerationCallback callback);
92 SimulatorConnectivityType convertConnectivityType(OCConnectivityType type) const;
95 std::mutex m_observeLock;
97 GETRequestSender m_getRequestSender;
98 PUTRequestSender m_putRequestSender;
99 POSTRequestSender m_postRequestSender;
101 RequestAutomationMngr m_requestAutomationMngr;
102 std::unordered_map<std::string, std::shared_ptr<RequestModel>> m_requestModels;
103 std::shared_ptr<OC::OCResource> m_ocResource;