If there is few references in Service Registry pointed to the same object but with different names, how can I differentiate them in call of some property method in pointed object?
Poco::Any MyObject::getDisplayValue(const std::string&) const
{
if(calling_reference == oid_1) // how to get calling_reference?
{
return value_1;
}
else if(calling_reference == oid_2) // how to get calling_reference?
{
return value_2;
}
else if(calling_reference == oid_3) // how to get calling_reference?
{
return value_3;
}
}
Hi,
I need advice on following example:
If there is few references in Service Registry pointed to the same object but with different names, how can I differentiate them in call of some property method in pointed object?
Example:
BundleActivator:
BundleContext::Ptr _pContext; std::vector _serviceRefs;
Properties props; props.set("io.macchina.device", MyObject::SYMBOLIC_NAME); props.set("io.macchina.deviceType", MyObject::TYPE);
std::string oid_1; std::string oid_2; std::string oid_3;
_serviceRefs.push_back(_pContext->registry().registerService(oid_1, pMyObject, props)); _serviceRefs.push_back(_pContext->registry().registerService(oid_2, pMyObject, props)); _serviceRefs.push_back(_pContext->registry().registerService(oid_3, pMyObject, props));
class MyObject: public IoT::Devices::DeviceImpl<IoT::Devices::MyDevice, MyObject> { protected: Poco::Any getDisplayValue(const std::string&) const; }
MyObject() ( addProperty("displayValue", &MyObject::getDisplayValue); ... )
Poco::Any MyObject::getDisplayValue(const std::string&) const { if(calling_reference == oid_1) // how to get calling_reference? { return value_1; } else if(calling_reference == oid_2) // how to get calling_reference? { return value_2; } else if(calling_reference == oid_3) // how to get calling_reference? { return value_3; } }
Thanks in advance,
Aleksandar