1 //******************************************************************
3 // Copyright 2014 Intel Corporation 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 /// @file OCResource.h
23 /// @brief This file contains the declaration of classes and its members related to
26 #ifndef __OCRESOURCE_H
27 #define __OCRESOURCE_H
32 #include <boost/property_tree/ptree.hpp>
33 #include <boost/property_tree/json_parser.hpp>
36 #include <ResourceInitException.h>
41 * @brief OCResource represents an OC resource. A resource could be a light controller,
42 * temperature sensor, smoke detector, etc. A resource comes with a well-defined
43 * contract or interface onto which you can perform different operations, such as
44 * turning on the light, getting the current temperature or subscribing for event
45 * notifications from the smoke detector. A resource can be composed of one or
51 typedef std::shared_ptr<OCResource> Ptr;
53 OCResource(std::string host, boost::property_tree::ptree& resourceNode);
54 virtual ~OCResource(void);
56 // Gets the device host URI
57 std::string host() const {return m_host;}
58 // Gets the device-relative URI for this resource
59 std::string uri() const {return m_uri;}
60 // bool whether it is possible to attach an observer to this resource
61 bool isObservable() const {return m_isObservable;}
62 // bool whether this is a collection type, and will have children that can be queried
63 bool isCollection() const {return m_isCollection;}
64 // a collection of the resource-type names
65 const std::vector<std::string> resourceTypes() const {return m_resourceTypes;}
66 // a collection of the interfaces supported by this resource
67 const std::vector<std::string> interfaces() const { return m_interfaces;}
68 // a collection of property objects that allow calling of properties on this Resource
69 const std::vector<std::string> properties() const { return m_properties;}
70 // a collection of the names of the children of this resource, assuming it supports a collection interface
71 const std::vector<std::string> children() const {return m_children;}
74 // a method which allows
80 std::vector<std::string> m_resourceTypes;
81 std::vector<std::string> m_interfaces;
82 std::vector<std::string> m_properties; // TODO: give a better type once we have the ability to call one!
83 std::vector<std::string> m_children;
88 #endif //__OCRESOURCE_H