1 //******************************************************************
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 #include "OCResource.h"
10 OCResource::OCResource(std::string host, boost::property_tree::ptree& resourceNode) : m_isCollection(false)
13 m_uri = resourceNode.get<std::string>("href","");
14 m_isObservable = resourceNode.get<int>("obs",0)==1;
16 boost::property_tree::ptree resourceTypes = resourceNode.get_child("rt", boost::property_tree::ptree());
17 for(auto itr : resourceTypes)
19 m_resourceTypes.push_back(itr.second.data());
22 boost::property_tree::ptree interfaces = resourceNode.get_child("if", boost::property_tree::ptree());
23 for(auto itr : interfaces)
25 if(itr.second.data() == "oc.mi.ll")
27 m_isCollection = true;
30 m_interfaces.push_back(itr.second.data());
33 // TODO: If collection, load children, assuming this becomes a thing
35 // TODO: Load attributes, assuming this becomes a 'thing'
37 if (m_uri.empty() || resourceTypes.empty() || interfaces.empty())
39 throw ResourceInitException(m_uri.empty(), resourceTypes.empty(), interfaces.empty());
43 OCResource::~OCResource()