1 //******************************************************************
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 /// @brief This file contains the declaration of classes and its members related to
11 #ifndef __OCRESOURCE_H
12 #define __OCRESOURCE_H
17 #include <boost/property_tree/ptree.hpp>
18 #include <boost/property_tree/json_parser.hpp>
21 #include <ResourceInitException.h>
26 * @brief OCResource represents an OC resource. A resource could be a light controller,
27 * temperature sensor, smoke detector, etc. A resource comes with a well-defined
28 * contract or interface onto which you can perform different operations, such as
29 * turning on the light, getting the current temperature or subscribing for event
30 * notifications from the smoke detector. A resource can be composed of one or
36 typedef std::shared_ptr<OCResource> Ptr;
38 OCResource(std::string host, boost::property_tree::ptree& resourceNode);
39 virtual ~OCResource(void);
41 // Gets the device host URI
42 std::string host() const {return m_host;}
43 // Gets the device-relative URI for this resource
44 std::string uri() const {return m_uri;}
45 // bool whether it is possible to attach an observer to this resource
46 bool isObservable() const {return m_isObservable;}
47 // bool whether this is a collection type, and will have children that can be queried
48 bool isCollection() const {return m_isCollection;}
49 // a collection of the resource-type names
50 const std::vector<std::string> resourceTypes() const {return m_resourceTypes;}
51 // a collection of the interfaces supported by this resource
52 const std::vector<std::string> interfaces() const { return m_interfaces;}
53 // a collection of property objects that allow calling of properties on this Resource
54 const std::vector<std::string> properties() const { return m_properties;}
55 // a collection of the names of the children of this resource, assuming it supports a collection interface
56 const std::vector<std::string> children() const {return m_children;}
59 // a method which allows
65 std::vector<std::string> m_resourceTypes;
66 std::vector<std::string> m_interfaces;
67 std::vector<std::string> m_properties; // TODO: give a better type once we have the ability to call one!
68 std::vector<std::string> m_children;
73 #endif //__OCRESOURCE_H