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 COMMON_PRIMITIVERESOURCE_H
22 #define COMMON_PRIMITIVERESOURCE_H
28 #include <OCResource.h>
30 #include <ResponseStatement.h>
31 #include <RCSAddress.h>
38 typedef OC::HeaderOption::OCHeaderOption HeaderOption;
39 typedef std::vector<HeaderOption> HeaderOptions;
41 class RCSResourceAttributes;
42 class ResponseStatement;
44 class PrimitiveResource: public std::enable_shared_from_this< PrimitiveResource >
47 typedef std::shared_ptr< PrimitiveResource > Ptr;
48 typedef std::shared_ptr< const PrimitiveResource > ConstPtr;
50 typedef std::function<void(const HeaderOptions&, const ResponseStatement&, int)>
53 typedef std::function<void(const HeaderOptions&, const ResponseStatement&, int)>
56 typedef std::function<void(const HeaderOptions&, const ResponseStatement&, int)>
59 typedef std::function<void(const HeaderOptions&, const ResponseStatement&, int, int)>
63 static PrimitiveResource::Ptr create(const std::shared_ptr<OC::OCResource>&);
65 virtual ~PrimitiveResource() { };
67 virtual void requestGet(GetCallback) = 0;
68 virtual void requestSet(const RCSResourceAttributes&, SetCallback) = 0;
69 virtual void requestPut(const RCSResourceAttributes&, PutCallback) = 0;
70 virtual void requestObserve(ObserveCallback) = 0;
71 virtual void cancelObserve() = 0;
73 virtual std::string getSid() const = 0;
74 virtual std::string getUri() const = 0;
75 virtual std::string getHost() const = 0;
76 virtual std::vector< std::string > getTypes() const = 0;
77 virtual std::vector< std::string > getInterfaces() const = 0;
79 virtual bool isObservable() const = 0;
82 PrimitiveResource() = default;
84 PrimitiveResource(const PrimitiveResource&) = delete;
85 PrimitiveResource(PrimitiveResource&&) = delete;
87 PrimitiveResource& operator=(const PrimitiveResource&) = delete;
88 PrimitiveResource& operator=(PrimitiveResource&&) = delete;
91 typedef std::function<void(std::shared_ptr<PrimitiveResource>)> DiscoverCallback;
93 void discoverResource(const std::string& host, const std::string& resourceURI,
94 OCConnectivityType, DiscoverCallback);
96 void discoverResource(const RCSAddress& address, const std::string& resourceURI,
102 #endif // COMMON_PRIMITIVERESOURCE_H