You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
}
Thanks in advance,
Aleksandar
The text was updated successfully, but these errors were encountered:
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::vectorServiceRef::Ptr _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
The text was updated successfully, but these errors were encountered: