Initial merge-commit of the OIC code. Should successfully do discovery for single...
[platform/upstream/iotivity.git] / include / OCResource.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
5
6 /// @file OCResource.h 
7
8 /// @brief      This file contains the declaration of classes and its members related to 
9 ///                     Resource.
10
11 #ifndef __OCRESOURCE_H
12 #define __OCRESOURCE_H
13
14 #include <memory>
15 #include <random>
16
17 #include <boost/property_tree/ptree.hpp>
18 #include <boost/property_tree/json_parser.hpp>
19
20 #include <OCApi.h>
21 #include <ResourceInitException.h>
22
23 namespace OC
24 {
25         /**
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
31         *                       more resources. 
32         */
33         class OCResource
34         {
35         public:
36                 typedef std::shared_ptr<OCResource> Ptr;
37                 
38                 OCResource(std::string host, boost::property_tree::ptree& resourceNode);
39                 virtual ~OCResource(void);
40                 
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;}
57                 
58                 
59                 // a method which allows 
60         private:        
61                 std::string m_uri;
62                 std::string m_host;
63                 bool m_isObservable;
64                 bool m_isCollection;
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;
69         };
70
71 } // namespace OC
72
73 #endif //__OCRESOURCE_H