Add sid getter to PrimitiveResource
[platform/upstream/iotivity.git] / service / resource-manipulation / modules / common / primitiveResource / include / PrimitiveResource.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 __PRIMITIVERESOURCE_H
22 #define __PRIMITIVERESOURCE_H
23
24 #include <functional>
25 #include <string>
26 #include <vector>
27
28 #include <OCResource.h>
29 #include <ResponseStatement.h>
30
31 namespace OIC
32 {
33     namespace Service
34     {
35
36         using HeaderOption = OC::HeaderOption::OCHeaderOption;
37         using HeaderOptions = std::vector<HeaderOption>;
38
39         class ResourceAttributes;
40         class ResponseStatement;
41
42         class PrimitiveResource
43         {
44         public:
45             using Ptr = std::shared_ptr<PrimitiveResource>;
46
47             using GetCallback = std::function<
48                     void(const HeaderOptions&, const ResponseStatement&, int)>;
49
50             using SetCallback = std::function<
51                     void(const HeaderOptions&, const ResponseStatement&, int)>;
52
53             using ObserveCallback = std::function<
54                     void(const HeaderOptions&, const ResponseStatement&, int, int)>;
55
56         public:
57             static PrimitiveResource::Ptr create(const std::shared_ptr<OC::OCResource>&);
58
59             virtual ~PrimitiveResource() = default;
60
61             virtual void requestGet(GetCallback) = 0;
62             virtual void requestSet(const ResourceAttributes&, SetCallback) = 0;
63             virtual void requestObserve(ObserveCallback) = 0;
64             virtual void cancelObserve() = 0;
65
66             virtual std::string getSid() const = 0;
67             virtual std::string getUri() const = 0;
68             virtual std::string getHost() const = 0;
69             virtual std::vector< std::string > getTypes() const = 0;
70             virtual std::vector< std::string > getInterfaces() const = 0;
71
72             virtual bool isObservable() const = 0;
73
74         protected:
75             PrimitiveResource() = default;
76
77             PrimitiveResource(const PrimitiveResource&) = delete;
78             PrimitiveResource(PrimitiveResource&&) = delete;
79
80             PrimitiveResource& operator=(const PrimitiveResource&) = delete;
81             PrimitiveResource& operator=(PrimitiveResource&&) = delete;
82         };
83
84         using DiscoverCallback = std::function<void(std::shared_ptr<PrimitiveResource>)>;
85
86         void discoverResource(const std::string& host, const std::string& resourceURI,
87                 OCConnectivityType, DiscoverCallback);
88
89     }
90 }
91
92 #endif // __PRIMITIVERESOURCE_H