1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 __PRIMITIVERESOURCE_H
22 #define __PRIMITIVERESOURCE_H
28 #include <OCResource.h>
29 #include <ResponseStatement.h>
36 using HeaderOption = OC::HeaderOption::OCHeaderOption;
37 using HeaderOptions = std::vector<HeaderOption>;
39 class ResourceAttributes;
40 class ResponseStatement;
42 class PrimitiveResource
45 using Ptr = std::shared_ptr<PrimitiveResource>;
47 using GetCallback = std::function<
48 void(const HeaderOptions&, const ResponseStatement&, int)>;
50 using SetCallback = std::function<
51 void(const HeaderOptions&, const ResponseStatement&, int)>;
53 using ObserveCallback = std::function<
54 void(const HeaderOptions&, const ResponseStatement&, int, int)>;
57 static PrimitiveResource::Ptr create(const std::shared_ptr<OC::OCResource>&);
59 virtual ~PrimitiveResource() = default;
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;
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;
72 virtual bool isObservable() const = 0;
75 PrimitiveResource() = default;
77 PrimitiveResource(const PrimitiveResource&) = delete;
78 PrimitiveResource(PrimitiveResource&&) = delete;
80 PrimitiveResource& operator=(const PrimitiveResource&) = delete;
81 PrimitiveResource& operator=(PrimitiveResource&&) = delete;
84 using DiscoverCallback = std::function<void(std::shared_ptr<PrimitiveResource>)>;
86 void discoverResource(const std::string& host, const std::string& resourceURI,
87 OCConnectivityType, DiscoverCallback);
92 #endif // __PRIMITIVERESOURCE_H