const std::string RESOURCETYPESKEY= "rt";
const std::string INTERFACESKEY = "if";
const std::string PROPERTYKEY = "prop";
+ const std::string REPKEY = "rep";
std::shared_ptr<OCResource> InProcClientWrapper::parseOCResource(IClientWrapper::Ptr clientWrapper, const std::string& host, const boost::property_tree::ptree resourceNode)
{
struct GetSetContext
{
- std::function<void(const AttributeMap&, const int&)> callback;
+ std::function<void(const OCRepresentation&, const int&)> callback;
};
-
- AttributeMap parseGetSetCallback(OCClientResponse* clientResponse)
+
+
+ OCRepresentation parseGetSetCallback(OCClientResponse* clientResponse)
{
std::stringstream requestStream;
requestStream<<clientResponse->resJSONPayload;
if(strlen((char*)clientResponse->resJSONPayload) == 0)
{
- return AttributeMap();
+ return OCRepresentation();
}
boost::property_tree::ptree root;
boost::property_tree::read_json(requestStream, root);
- boost::property_tree::ptree payload = root.get_child("oc.payload", boost::property_tree::ptree());
-
- AttributeMap attrs;
- for(auto& item : payload)
- {
- if(item.first.data() == URIKEY)
+ boost::property_tree::ptree payload = root.get_child("oc", boost::property_tree::ptree());
+ OCRepresentation root_resource;
+ std::vector<OCRepresentation> children;
+ bool isRoot = true;
+ for ( auto payloadItr : payload)
+ {
+ OCRepresentation child;
+ try
{
- continue;
+ auto resourceNode = payloadItr.second;
+ std::string uri = resourceNode.get<std::string>(URIKEY, "");
+
+ if (isRoot)
+ {
+ root_resource.setUri(uri);
+ }
+ else
+ {
+ child.setUri(uri);
+ }
+
+ if( resourceNode.count(PROPERTYKEY) != 0 )
+ {
+ std::vector<std::string> rTs;
+ std::vector<std::string> ifaces;
+ boost::property_tree::ptree properties = resourceNode.get_child(PROPERTYKEY, boost::property_tree::ptree());
+
+ boost::property_tree::ptree rT = properties.get_child(RESOURCETYPESKEY, boost::property_tree::ptree());
+ for(auto itr : rT)
+ {
+ rTs.push_back(itr.second.data());
+ }
+
+ boost::property_tree::ptree iF = properties.get_child(INTERFACESKEY, boost::property_tree::ptree());
+ for(auto itr : iF)
+ {
+ ifaces.push_back(itr.second.data());
+ }
+ if (isRoot)
+ {
+ root_resource.setResourceInterfaces(ifaces);
+ root_resource.setResourceTypes(rTs);
+ }
+ else
+ {
+ child.setResourceInterfaces(ifaces);
+ child.setResourceTypes(rTs);
+ }
+ }
+
+ if( resourceNode.count(REPKEY) != 0 )
+ {
+ boost::property_tree::ptree rep = resourceNode.get_child(REPKEY, boost::property_tree::ptree());
+ AttributeMap attrs;
+ for( auto item : rep)
+ {
+ std::string name = item.first.data();
+ std::string value = item.second.data();
+ AttributeValues values;
+ values.push_back(value);
+ attrs[name] = values;
+ }
+ if (isRoot)
+ {
+ root_resource.setAttributeMap(attrs);
+ }
+ else
+ {
+ child.setAttributeMap(attrs);
+ }
+ }
+
+ if (!isRoot)
+ children.push_back(child);
+ }
+ catch (...)
+ {
+ // TODO
}
- std::string name = item.first.data();
- std::string value = item.second.data();
- AttributeValues values;
- values.push_back(value);
- attrs[name] = values;
- }
- return attrs;
+ isRoot = false;
+ }
+
+ root_resource.setChildren(children);
+
+ return root_resource;
}
+
OCStackApplicationResult getResourceCallback(void* ctx, OCDoHandle handle, OCClientResponse* clientResponse)
{
GetSetContext* context = static_cast<GetSetContext*>(ctx);
std::cout << "GET JSON: " << (char*) clientResponse->resJSONPayload << endl;
- AttributeMap attrs;
+ OCRepresentation rep;
if(clientResponse->result == OC_STACK_OK)
{
- attrs = parseGetSetCallback(clientResponse);
+ rep = parseGetSetCallback(clientResponse);
}
- std::thread exec(context->callback, attrs, clientResponse->result);
+ std::thread exec(context->callback, rep, clientResponse->result);
exec.detach();
return OC_STACK_DELETE_TRANSACTION;
}
OCStackResult InProcClientWrapper::GetResourceAttributes(const std::string& host, const std::string& uri,
- const QueryParamsMap& queryParams, std::function<void(const AttributeMap, const int)>& callback)
+ const QueryParamsMap& queryParams, std::function<void(const OCRepresentation, const int)>& callback)
{
OCStackResult result;
OCCallbackData* cbdata = new OCCallbackData();
OCStackApplicationResult setResourceCallback(void* ctx, OCDoHandle handle, OCClientResponse* clientResponse)
{
GetSetContext* context = static_cast<GetSetContext*>(ctx);
- AttributeMap attrs;
+ OCRepresentation attrs;
if(clientResponse->result == OC_STACK_OK)
{
return ret;
}
- std::string InProcClientWrapper::assembleSetResourcePayload(const AttributeMap& attributes)
+ std::string InProcClientWrapper::assembleSetResourcePayload(const OCRepresentation& rep)
{
+ AttributeMap attributes = rep.getAttributeMap();
+
ostringstream payload;
// TODO need to change the format to "{"oc":[]}"
payload << "{\"oc\":{";
return payload.str();
}
- OCStackResult InProcClientWrapper::SetResourceAttributes(const std::string& host, const std::string& uri, const AttributeMap& attributes, const QueryParamsMap& queryParams, std::function<void(const AttributeMap,const int)>& callback)
+ OCStackResult InProcClientWrapper::SetResourceAttributes(const std::string& host, const std::string& uri, const OCRepresentation& attributes, const QueryParamsMap& queryParams, std::function<void(const OCRepresentation,const int)>& callback)
{
OCStackResult result;
OCCallbackData* cbdata = new OCCallbackData();
struct ObserveContext
{
- std::function<void(const AttributeMap&, const int&, const int&)> callback;
+ std::function<void(const OCRepresentation&, const int&, const int&)> callback;
};
OCStackApplicationResult observeResourceCallback(void* ctx, OCDoHandle handle, OCClientResponse* clientResponse)
{
ObserveContext* context = static_cast<ObserveContext*>(ctx);
- AttributeMap attrs;
+ OCRepresentation attrs;
uint32_t sequenceNumber = clientResponse->sequenceNumber;
if(clientResponse->result == OC_STACK_OK)
{
}
OCStackResult InProcClientWrapper::ObserveResource(ObserveType observeType, OCDoHandle* handle, const std::string& host,
- const std::string& uri, const QueryParamsMap& queryParams, std::function<void(const AttributeMap&, const int&, const int&)>& callback)
+ const std::string& uri, const QueryParamsMap& queryParams, std::function<void(const OCRepresentation&, const int&, const int&)>& callback)
{
OCStackResult result;
OCCallbackData* cbdata = new OCCallbackData();
exec.detach();
return OC_STACK_DELETE_TRANSACTION;
}
+
OCStackResult InProcClientWrapper::CancelObserveResource(OCDoHandle handle, const std::string& host, const std::string& uri)
{
OCStackResult result;
{
}
- OCStackResult OCResource::get(const QueryParamsMap& queryParametersMap, std::function<void(const AttributeMap, const int)> attributeHandler)
+ OCStackResult OCResource::get(const QueryParamsMap& queryParametersMap, std::function<void(const OCRepresentation, const int)> attributeHandler)
{
auto cw = m_clientWrapper.lock();
}
}
- OCStackResult OCResource::put(const AttributeMap& attributeMap, const QueryParamsMap& queryParametersMap,
- std::function<void(const AttributeMap, const int)> attributeHandler)
+ OCStackResult OCResource::put(const OCRepresentation& rep, const QueryParamsMap& queryParametersMap,
+ std::function<void(const OCRepresentation, const int)> attributeHandler)
{
auto cw = m_clientWrapper.lock();
if(cw)
{
- return cw->SetResourceAttributes(m_host, m_uri, attributeMap, queryParametersMap, attributeHandler);
+ return cw->SetResourceAttributes(m_host, m_uri, rep, queryParametersMap, attributeHandler);
}
else
{
}
OCStackResult OCResource::observe(ObserveType observeType, const QueryParamsMap& queryParametersMap,
- std::function<void(const AttributeMap&, const int&, const int&)> observeHandler)
+ std::function<void(const OCRepresentation&, const int&, const int&)> observeHandler)
{
if(m_observeHandle != nullptr)
{
return ++oc;
}
-void onObserve(const AttributeMap& attributeMap, const int& eCode, const int& sequenceNumber)
-{
- if(eCode == SUCCESS_RESPONSE)
- {
- std::cout << "OBSERVE RESULT:"<<std::endl;
- std::cout << "\tSequenceNumber: "<< sequenceNumber << endl;
- for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
- {
- std::cout << "\tAttribute name: "<< it->first << " value: ";
- for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)
- {
- std::cout <<"\t"<< *valueItr << " ";
- }
-
- std::cout << std::endl;
- }
-
- if(observe_count() > 30)
- {
- std::cout<<"Cancelling Observe..."<<std::endl;
- OCStackResult result = curResource->cancelObserve();
+// Forward declaration
+void putRoomRepresentation(std::shared_ptr<OCResource> resource);
+void onPut(const OCRepresentation& rep, const int eCode);
- std::cout << "Cancel result: "<< result <<std::endl;
- sleep(10);
- std::cout << "DONE"<<std::endl;
- std::exit(0);
- }
- }
- else
- {
- std::cout << "onObserve Response error: " << eCode << std::endl;
- std::exit(-1);
- }
-}
-// callback handler on PUT request
-void onGetRep(OCRepresentation& rep, const int eCode)
+// callback handler on GET request
+void onGet(const OCRepresentation& rep, const int eCode)
{
if(eCode == SUCCESS_RESPONSE)
{
std::cout << "GET request was successful" << std::endl;
AttributeMap attributeMap = rep.getAttributeMap();
+
+ std::cout << "Resource URI: " << rep.getUri() << std::endl;
for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
{
for(auto oit = children.begin(); oit != children.end(); ++oit)
{
- attributeMap = oit->getAttributeMap();
+ std::cout << "Child Resource URI: " << oit->getUri() << std::endl;
- for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
- {
- std::cout << "\tAttribute name: "<< it->first << " value: ";
- for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)
- {
- std::cout <<"\t"<< *valueItr << " ";
- }
-
- std::cout << std::endl;
- }
- }
-
- }
- else
- {
- std::cout << "onGET Response error: " << eCode << std::endl;
- std::exit(-1);
- }
-}
-
-// callback handler on PUT request
-void onPutRep(OCRepresentation& rep, const int eCode)
-{
- if(eCode == SUCCESS_RESPONSE)
- {
- std::cout << "PUT request was successful" << std::endl;
-
- AttributeMap attributeMap = rep.getAttributeMap();
-
- for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
- {
- std::cout << "\tAttribute name: "<< it->first << " value: ";
- for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)
- {
- std::cout <<"\t"<< *valueItr << " ";
- }
-
- std::cout << std::endl;
- }
-
- std::vector<OCRepresentation> children = rep.getChildren();
-
- for(auto oit = children.begin(); oit != children.end(); ++oit)
- {
attributeMap = oit->getAttributeMap();
for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
}
}
+ putRoomRepresentation(curResource);
}
else
{
- std::cout << "onPut Response error: " << eCode << std::endl;
- std::exit(-1);
- }
-}
-
-// callback handler on PUT request
-void onPut(const AttributeMap attributeMap, const int eCode)
-{
- if(eCode == SUCCESS_RESPONSE)
- {
- std::cout << "PUT request was successful" << std::endl;
-
- for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
- {
- std::cout << "\tAttribute name: "<< it->first << " value: ";
- for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)
- {
- std::cout <<"\t"<< *valueItr << " ";
- }
-
- std::cout << std::endl;
- }
- }
- else
- {
- std::cout << "onPut Response error: " << eCode << std::endl;
+ std::cout << "onGET Response error: " << eCode << std::endl;
std::exit(-1);
}
}
{
if(resource)
{
+ OCRepresentation rep;
std::cout << "Putting room representation..."<<std::endl;
// Create AttributeMap
AttributeMap attributeMap;
QueryParamsMap qp;
qp["if"] = BATCH_INTERFACE;
+ rep.setAttributeMap(attributeMap);
+
// Invoke resource's pit API with attribute map, query map and the callback parameter
- resource->put(attributeMap, qp, &onPut);
+ resource->put(rep, qp, &onPut);
}
}
-// callback handler on GET request
-void onGet(const AttributeMap attributeMap, const int eCode)
+// callback handler on PUT request
+void onPut(const OCRepresentation& rep, const int eCode)
{
if(eCode == SUCCESS_RESPONSE)
{
- std::cout << "GET Succeeded:"<<std::endl;
+ std::cout << "PUT request was successful" << std::endl;
+
+ AttributeMap attributeMap = rep.getAttributeMap();
+
for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
{
std::cout << "\tAttribute name: "<< it->first << " value: ";
std::cout << std::endl;
}
- putRoomRepresentation(curResource);
+ std::vector<OCRepresentation> children = rep.getChildren();
+
+ for(auto oit = children.begin(); oit != children.end(); ++oit)
+ {
+ attributeMap = oit->getAttributeMap();
+
+ for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
+ {
+ std::cout << "\tAttribute name: "<< it->first << " value: ";
+ for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)
+ {
+ std::cout <<"\t"<< *valueItr << " ";
+ }
+
+ std::cout << std::endl;
+ }
+ }
+
}
else
{
- std::cout << "onGet Response error: " << eCode << std::endl;
+ std::cout << "onPut Response error: " << eCode << std::endl;
std::exit(-1);
}
}
+
+
// Local function to get representation of light resource
void getRoomRepresentation(std::shared_ptr<OCResource> resource)
{
{
curResource = resource;
// Call a local function which will internally invoke get API on the resource pointer
- // TODO change this back when getRoomRepresentation works
getRoomRepresentation(resource);
- //putRoomRepresentation(resource);
}
}
else
}
// callback handler on PUT request
-void onPut(const AttributeMap attributeMap, const int eCode)
+void onPut(const OCRepresentation& rep, const int eCode)
{
if(eCode == SUCCESS_RESPONSE)
{
std::cout << "PUT request was successful" << std::endl;
+ AttributeMap attributeMap = rep.getAttributeMap();
+
for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
{
std::cout << "\tAttribute name: "<< it->first << " value: ";
std::cout << std::endl;
}
- if (OBSERVE_TYPE_TO_USE == ObserveType::Observe)
- std::cout << endl << "Observe is used." << endl << endl;
- else if (OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll)
- std::cout << endl << "ObserveAll is used." << endl << endl;
+ std::vector<OCRepresentation> children = rep.getChildren();
- // TODO
- QueryParamsMap test;
+ for(auto oit = children.begin(); oit != children.end(); ++oit)
+ {
+ attributeMap = oit->getAttributeMap();
- curResource->observe(OBSERVE_TYPE_TO_USE, test, &onObserve);
+ for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
+ {
+ std::cout << "\tAttribute name: "<< it->first << " value: ";
+ for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)
+ {
+ std::cout <<"\t"<< *valueItr << " ";
+ }
+
+ std::cout << std::endl;
+ }
+ }
}
else
{
if(resource)
{
+ OCRepresentation rep;
+
std::cout << "Putting light representation..."<<std::endl;
// Create AttributeMap
AttributeMap attributeMap;
// Create QueryParameters Map and add query params (if any)
QueryParamsMap queryParamsMap;
+ rep.setAttributeMap(attributeMap);
+
// Invoke resource's pit API with attribute map, query map and the callback parameter
- resource->put(attributeMap, queryParamsMap, &onPut);
+ resource->put(rep, queryParamsMap, &onPut);
}
}
// callback handler on GET request
-void onGet(const AttributeMap attributeMap, const int eCode)
+void onGet(const OCRepresentation& rep, const int eCode)
{
if(eCode == SUCCESS_RESPONSE)
{
- std::cout << "GET Succeeded:"<<std::endl;
+ std::cout << "GET request was successful" << std::endl;
+
+ AttributeMap attributeMap = rep.getAttributeMap();
+
+ std::cout << "Resource URI: " << rep.getUri() << std::endl;
+
for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
{
std::cout << "\tAttribute name: "<< it->first << " value: ";
std::cout << std::endl;
}
+ std::vector<OCRepresentation> children = rep.getChildren();
+
+ for(auto oit = children.begin(); oit != children.end(); ++oit)
+ {
+ std::cout << "Child Resource URI: " << oit->getUri() << std::endl;
+
+ attributeMap = oit->getAttributeMap();
+
+ for(auto it = attributeMap.begin(); it != attributeMap.end(); ++it)
+ {
+ std::cout << "\tAttribute name: "<< it->first << " value: ";
+ for(auto valueItr = it->second.begin(); valueItr != it->second.end(); ++valueItr)
+ {
+ std::cout <<"\t"<< *valueItr << " ";
+ }
+
+ std::cout << std::endl;
+ }
+ }
+
putLightRepresentation(curResource);
}
else
{
- std::cout << "onGet Response error: " << eCode << std::endl;
+ std::cout << "onGET Response error: " << eCode << std::endl;
std::exit(-1);
}
}
+
// Local function to get representation of light resource
void getLightRepresentation(std::shared_ptr<OCResource> resource)
{
#include <string>
#include <OCApi.h>
+
namespace OC
{
class IClientWrapper : public std::enable_shared_from_this<IClientWrapper>
std::function<void(std::shared_ptr<OCResource>)>& callback) = 0;
virtual OCStackResult GetResourceAttributes(const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
- std::function<void(const AttributeMap, const int)>& callback)=0;
-
- virtual OCStackResult SetResourceAttributes(const std::string& host, const std::string& uri, const AttributeMap& attributes,
- const QueryParamsMap& queryParams, std::function<void(const AttributeMap,const int)>& callback)=0;
+ std::function<void(const OCRepresentation, const int)>& callback)=0;
+
+ virtual OCStackResult SetResourceAttributes(const std::string& host, const std::string& uri, const OCRepresentation& attributes,
+ const QueryParamsMap& queryParams, std::function<void(const OCRepresentation, const int)>& callback) = 0;
virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
- std::function<void(const AttributeMap&, const int&, const int&)>& callback)=0;
+ std::function<void(const OCRepresentation&, const int&, const int&)>& callback)=0;
virtual OCStackResult CancelObserveResource(OCDoHandle handle, const std::string& host, const std::string& uri)=0;
std::function<void(std::shared_ptr<OCResource>)>& callback);
virtual OCStackResult GetResourceAttributes(const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
- std::function<void(const AttributeMap, const int)>& callback);
+ std::function<void(const OCRepresentation, const int)>& callback);
- virtual OCStackResult SetResourceAttributes(const std::string& host, const std::string& uri, const AttributeMap& attributes,
- const QueryParamsMap& queryParams, std::function<void(const AttributeMap,const int)>& callback);
+ virtual OCStackResult SetResourceAttributes(const std::string& host, const std::string& uri, const OCRepresentation& attributes,
+ const QueryParamsMap& queryParams, std::function<void(const OCRepresentation, const int)>& callback);
virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle,
const std::string& host, const std::string& uri, const QueryParamsMap& queryParams,
- std::function<void(const AttributeMap&, const int&, const int&)>& callback);
+ std::function<void(const OCRepresentation&, const int&, const int&)>& callback);
virtual OCStackResult CancelObserveResource(OCDoHandle handle, const std::string& host, const std::string& uri);
private:
void listeningFunc();
std::string assembleSetResourceUri(std::string uri, const QueryParamsMap& queryParams);
- std::string assembleSetResourcePayload(const AttributeMap& attributes);
+ std::string assembleSetResourcePayload(const OCRepresentation& attributes);
std::thread m_listeningThread;
bool m_threadRun;
std::weak_ptr<std::mutex> m_csdkLock;
// Used in GET, PUT, POST, DELETE methods on links to other resources of a collection.
const std::string BATCH_INTERFACE = "oc.mi.b";
+ class OCRepresentation
+ {
+
+ private:
+
+ std::string m_uri;
+ AttributeMap m_attributeMap;
+ std::vector<std::string> m_resourceTypes;
+ std::vector<std::string> m_resourceInterfaces;
+ bool m_observable; // TODO : do we need this here???
+ int errorCode;
+
+ std::vector<OCRepresentation> m_children;
+
+ public:
+
+ OCRepresentation() {}
+
+ std::string getUri(void) const
+ {
+ return m_uri;
+ }
+
+ void setUri(std::string uri)
+ {
+ m_uri = uri;
+ }
+
+ std::vector<OCRepresentation> getChildren(void) const
+ {
+ return m_children;
+ }
+
+ void setChildren(std::vector<OCRepresentation> children)
+ {
+ m_children = children;
+ }
+
+ OCResource* getResource() const
+ {
+ // TODO Needs to be implemented
+ OCResource* res = NULL;
+
+ return res;
+ }
+
+ AttributeMap getAttributeMap() const
+ {
+ return m_attributeMap;
+ }
+
+ void setAttributeMap(AttributeMap map)
+ {
+ m_attributeMap = map;
+ }
+
+ std::vector<std::string> getResourceTypes() const
+ {
+ return m_resourceTypes;
+ }
+
+ void setResourceTypes(std::vector<std::string> resourceTypes)
+ {
+ m_resourceTypes = resourceTypes;
+ }
+
+ std::vector<std::string> getResourceInterfaces(void) const
+ {
+ return m_resourceInterfaces;
+ }
+
+ void setResourceInterfaces(std::vector<std::string> resourceInterfaces)
+ {
+ m_resourceInterfaces = resourceInterfaces;
+ }
+ };
+
} // namespace OC
#endif
namespace OC
{
- class OCRepresentation
- {
-
- private:
-
- std::string m_uri;
- AttributeMap m_attributeMap;
- std::vector<std::string> m_resourceTypes;
- std::vector<std::string> m_resourceInterfaces;
- bool m_observable; // TODO : do we need this here???
- int errorCode;
-
- std::vector<OCRepresentation> m_children;
-
- public:
-
- OCRepresentation() {}
-
- std::string getUri(void) const
- {
- return m_uri;
- }
-
- void setUri(std::string uri)
- {
- m_uri = uri;
- }
-
- std::vector<OCRepresentation> getChildren(void) const
- {
- return m_children;
- }
-
- void setChildren(std::vector<OCRepresentation> children)
- {
- m_children = children;
- }
-
- OCResource* getResource() const
- {
- // TODO Needs to be implemented
- OCResource* res = NULL;
-
- return res;
- }
-
- AttributeMap getAttributeMap() const
- {
- return m_attributeMap;
- }
-
- void setAttributeMap(AttributeMap map)
- {
- m_attributeMap = map;
- }
-
- std::vector<std::string> getResourceTypes() const
- {
- return m_resourceTypes;
- }
-
- void setResourceTypes(std::vector<std::string> resourceTypes)
- {
- m_resourceTypes = resourceTypes;
- }
-
- std::vector<std::string> getResourceInterfaces(void) const
- {
- return m_resourceInterfaces;
- }
-
- void setResourceInterfaces(std::vector<std::string> resourceInterfaces)
- {
- m_resourceInterfaces = resourceInterfaces;
- }
- };
-
+
} // namespace OC
#endif //__OCREPRESENTATION_H
#include <ResourceInitException.h>
#include <IClientWrapper.h>
#include <InProcClientWrapper.h>
+#include <OCRepresentation.h>
namespace OC
{
* @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
* NOTE: OCStackResult is defined in ocstack.h.
*/
- OCStackResult get(const QueryParamsMap& queryParametersMap, std::function<void(const AttributeMap, const int)> attributeHandler);
+ OCStackResult get(const QueryParamsMap& queryParametersMap, std::function<void(const OCRepresentation, const int)> attributeHandler);
/**
* Function to get the attributes of a resource.
* TODO: Implementation
*/
OCStackResult get(const std::string& resourceType, const std::string& resourceInterface, const QueryParamsMap& queryParametersMap,
- std::function<void(const AttributeMap& attributeMap, const std::vector<std::string>& resourceUriList, const int& errorCode)> attributeHandler)
+ std::function<void(const OCRepresentation& rep, const std::vector<std::string>& resourceUriList, const int& errorCode)> attributeHandler)
{ return OC_STACK_OK; }
/**
* @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
* NOTE: OCStackResult is defined in ocstack.h.
*/
- OCStackResult put(const AttributeMap& attributeMap, const QueryParamsMap& queryParametersMap,
- std::function< void(const AttributeMap,const int)> attributeHandler);
+ OCStackResult put(const OCRepresentation& attributeMap, const QueryParamsMap& queryParametersMap,
+ std::function< void(const OCRepresentation,const int)> attributeHandler);
/**
* Function to set the attributes of a resource (via PUT)
* TODO: Implementation
*/
OCStackResult put(const std::string& resourceType, const std::string& resourceInterface,
- const AttributeMap& attributeMap, const QueryParamsMap& queryParametersMap,
- std::function< void(const AttributeMap&,const int&)> attributeHandler) { return OC_STACK_OK; }
+ const OCRepresentation& attributeMap, const QueryParamsMap& queryParametersMap,
+ std::function< void(const OCRepresentation&,const int&)> attributeHandler) { return OC_STACK_OK; }
/**
* Function to set observation on the resource
* NOTE: OCStackResult is defined in ocstack.h.
*/
OCStackResult observe(ObserveType observeType, const QueryParamsMap& queryParametersMap,
- std::function<void(const AttributeMap&, const int&, const int&)> observeHandler);
+ std::function<void(const OCRepresentation&, const int&, const int&)> observeHandler);
/**
* Function to cancel the observation on the resource
std::vector<std::string> m_resourceTypes;
std::vector<std::string> m_interfaces;
std::vector<std::string> m_children;
- AttributeMap m_attributeMap;
OCDoHandle m_observeHandle;
private:
std::function<void(std::shared_ptr<OCResource>)>& callback) {return OC_STACK_NOTIMPL;}
virtual OCStackResult GetResourceAttributes(const std::string& host, const std::string& uri,
- const QueryParamsMap& queryParams, std::function<void(const AttributeMap, const int)>& callback){return OC_STACK_NOTIMPL;}
-
+ const QueryParamsMap& queryParams, std::function<void(const OCRepresentation, const int)>& callback){return OC_STACK_NOTIMPL;}
+/*
virtual OCStackResult SetResourceAttributes(const std::string& host, const std::string& uri,
const AttributeMap& attributes, const QueryParamsMap& queryParams, std::function<void(const AttributeMap,const int)>& callback){return OC_STACK_NOTIMPL;}
-
+ */
+ virtual OCStackResult SetResourceAttributes(const std::string& host, const std::string& uri,
+ const OCRepresentation& attributes, const QueryParamsMap& queryParams, std::function<void(const OCRepresentation,const int)>& callback){return OC_STACK_NOTIMPL;}
+
virtual OCStackResult ObserveResource(ObserveType observeType, OCDoHandle* handle, const std::string& host,
const std::string& uri, const QueryParamsMap& queryParams,
- std::function<void(const AttributeMap&, const int&, const int&)>& callback){return OC_STACK_NOTIMPL;}
+ std::function<void(const OCRepresentation&, const int&, const int&)>& callback){return OC_STACK_NOTIMPL;}
virtual OCStackResult CancelObserveResource(OCDoHandle handle, const std::string& host, const std::string& uri){return OC_STACK_NOTIMPL;}
CXX_INC += -I./csdk/libcoap
# Force metatargets to build:
-.PHONY: prep_dirs c_sdk simpleserver simpleclient simpleclientserver roomserver roomclient
+.PHONY: prep_dirs c_sdk simpleserver simpleclient roomserver roomclient
all: .PHONY