本文整理汇总了C++中OCRepresentation::getAttributeMap方法的典型用法代码示例。如果您正苦于以下问题:C++ OCRepresentation::getAttributeMap方法的具体用法?C++ OCRepresentation::getAttributeMap怎么用?C++ OCRepresentation::getAttributeMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCRepresentation
的用法示例。
在下文中一共展示了OCRepresentation::getAttributeMap方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onPut
// callback handler on PUT request
void onPut(const OCRepresentation& rep , const int eCode)
{
AttributeMap attributeMap = rep.getAttributeMap();
if(eCode == SUCCESS_RESPONSE)
{
DBG("PUT request was successful");
printAttributeMap(attributeMap);
if(OBSERVE_TYPE_TO_USE == ObserveType::Observe)
INFO("Observe is used.");
else if(OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll)
INFO("ObserveAll is used.");
if(g_curResource != nullptr)
{
DBG("Observe Start");
QueryParamsMap test;
g_curResource->observe(ObserveType::Observe , test , &onObserve);
}
}
else
{
ERR("onPut Response error: %d" , eCode);
//std::exit(-1);
}
}
示例2: onObserve
void onObserve(const HeaderOptions &headerOption , const OCRepresentation& rep , const int& eCode, const int& sequenceNumber)
{
std::cout << "onObserve" << std::endl;
// if(eCode == SUCCESS_RESPONSE)
if(eCode <= OC_STACK_RESOURCE_DELETED)
{
AttributeMap attributeMap = rep.getAttributeMap();
for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
{
if(attributeMap.find(it->first) == attributeMap.end())
{
return;
}
}
if(rep.getUri().empty())
{
cout << "uri is null\n";
return;
}
std::cout << std::endl;
std::cout << "========================================================" << std::endl;
std::cout << "Receive OBSERVE RESULT:" << std::endl;
std::cout << "\tSequenceNumber: " << sequenceNumber << 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;
}
if(observe_count() > 30)
{
std::cout << "Cancelling Observe..." << std::endl;
OCStackResult result = g_curResource->cancelObserve();
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);
}
}
示例3: onPut
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: ";
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)
{
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_TYPE_TO_USE == ObserveType::Observe)
std::cout << std::endl << "Observe is used." << std::endl << std::endl;
else if(OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll)
std::cout << std::endl << "ObserveAll is used." << std::endl << std::endl;
QueryParamsMap test;
g_curResource->observe(ObserveType::Observe , test , &onObserve);
}
else
{
std::cout << "onPut Response error: " << eCode << std::endl;
std::exit(-1);
}
}
示例4: onGet
// callback handler on GET request
void onGet(const HeaderOptions &headerOption , 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)
{
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)
{
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;
}
}
}
else
{
std::cout << "onGET Response error: " << eCode << std::endl;
std::exit(-1);
}
}
示例5: onGet
// callback handler on GET request
void onGet(const OCRepresentation& rep , const int eCode)
{
AttributeMap attributeMap = rep.getAttributeMap();
if(eCode == SUCCESS_RESPONSE)
{
DBG("GET Succeeded:");
printAttributeMap(attributeMap);
updateAttribute(attributeMap);
}
else
{
ERR("onGet Response error: %d" , eCode);
//std::exit(-1);
}
}
示例6: onObserve
void onObserve(const OCRepresentation& rep , const int& eCode , const int& sequenceNumber)
{
AttributeMap attributeMap = rep.getAttributeMap();
if(eCode == SUCCESS_RESPONSE)
{
DBG("OBSERVE RESULT:");
DBG("\tSequenceNumber: %d" , sequenceNumber);
printAttributeMap(attributeMap);
// updateAttribute(attributeMap);
g_curAttributeMap = attributeMap;
onobserve();
}
else
{
ERR("onObserve Response error: %d" , eCode);
//std::exit(-1);
}
}