9f615103f0f31783a391c0a3b1df8076d2e4231c
[platform/upstream/iotivity.git] / service / resource-hosting / src / RequestObject.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 RH_REQUESTOBJECT_H_
22 #define RH_REQUESTOBJECT_H_
23
24 #include "RCSRemoteResourceObject.h"
25 #include "RCSResourceObject.h"
26
27 namespace OIC
28 {
29 namespace Service
30 {
31
32 class RequestObject
33 {
34 public:
35     typedef std::shared_ptr<RequestObject> Ptr;
36     typedef std::function<
37             void(const RCSResourceAttributes &, const RCSResourceAttributes &)> SetRequestCallback;
38
39     enum class RequestMethod
40     {
41         Get = 0,
42         Set,
43         Post,
44         Delete
45     };
46
47 private:
48     typedef RCSRemoteResourceObject::Ptr RemoteObjectPtr;
49
50     SetRequestCallback pSetRequestCB;
51
52 public:
53     RequestObject();
54     RequestObject(SetRequestCallback cb);
55     ~RequestObject();
56
57     void invokeRequest(RemoteObjectPtr remoteObject, RequestMethod method,
58             const RCSResourceAttributes & resourceAttibutes);
59
60 private:
61     void setRequestCB(const RCSResourceAttributes & returnedAttributes,
62             const RCSResourceAttributes & putAttibutes);
63 };
64
65 } /* namespace Service */
66 } /* namespace OIC */
67
68 #endif /* RH_REQUESTOBJECT_H_ */