Repo Merge: Moving resource API down a directory
[platform/upstream/iotivity.git] / resource / include / IClientWrapper.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH 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 _I_CLIENT_WRAPPER_H_
22 #define _I_CLIENT_WRAPPER_H_
23
24 #include <memory>
25 #include <string>
26
27 #include <OCApi.h>
28
29 namespace OC
30 {
31     class OCPlatform_impl;
32
33     class IClientWrapper : public std::enable_shared_from_this<IClientWrapper>
34     {
35     protected:
36         OCPlatform_impl& m_owner;
37
38     public:
39         typedef std::shared_ptr<IClientWrapper> Ptr;
40
41         IClientWrapper(OCPlatform_impl& owner)
42          : m_owner(owner)
43         {}
44
45         virtual OCStackResult ListenForResource(const std::string& serviceUrl,
46                         const std::string& resourceType, FindCallback& callback,
47                         QualityOfService QoS) = 0;
48
49         virtual OCStackResult GetResourceRepresentation(const std::string& host,
50                         const std::string& uri, const QueryParamsMap& queryParams,
51                         const HeaderOptions& headerOptions,
52                         GetCallback& callback, QualityOfService QoS)=0;
53
54         virtual OCStackResult PutResourceRepresentation(const std::string& host,
55                         const std::string& uri, const OCRepresentation& rep,
56                         const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
57                         PutCallback& callback, QualityOfService QoS) = 0;
58
59         virtual OCStackResult PostResourceRepresentation(const std::string& host,
60                         const std::string& uri, const OCRepresentation& rep,
61                         const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
62                         PostCallback& callback, QualityOfService QoS) = 0;
63
64         virtual OCStackResult DeleteResource(const std::string& host, const std::string& uri,
65                         const HeaderOptions& headerOptions, DeleteCallback& callback,
66                         QualityOfService QoS) = 0;
67
68         virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
69                         const std::string& host, const std::string& uri,
70                         const QueryParamsMap& queryParams, const HeaderOptions& headerOptions,
71                         ObserveCallback& callback, QualityOfService QoS)=0;
72
73         virtual OCStackResult CancelObserveResource(OCDoHandle handle, const std::string& host,
74             const std::string& uri, const HeaderOptions& headerOptions, QualityOfService QoS)=0;
75
76         virtual OCStackResult SubscribePresence(OCDoHandle* handle, const std::string& host,
77                         SubscribeCallback& presenceHandler)=0;
78
79         virtual OCStackResult UnsubscribePresence(OCDoHandle handle) =0;
80
81         virtual OCStackResult GetDefaultQos(QualityOfService& qos) = 0;
82
83         virtual ~IClientWrapper(){}
84
85
86         // Note: this should never be called by anyone but the handler for the listen command.
87         // It is public becuase that needs to be a non-instance callback
88         virtual std::shared_ptr<OCResource> parseOCResource(IClientWrapper::Ptr clientWrapper,
89                         const std::string& host, const boost::property_tree::ptree resourceNode)=0;
90     private:
91     };
92 }
93
94 #endif