Using the Qt DBus library, I'm having a hard time registering an object implementing multiple interfaces.
<node>
<interface name="x.I1"> <method name="foo"/> </interface>
<interface name="x.I2"> <method name="bar"/> </interface>
</node>
I have an implementation of both interfaces using C++ multiple inheritance.
class Impl : public x.I1, public x.I2 {
public:
void foo(){}
void bar(){}
};
The qdbusxml2cpp
tool generates me a DBusAdaptor
for each of the interfaces, but the QDBusConnection
doesn't have a method to add an interface implementor to that object.
And I want to publish this object on a DBus service.
QDBusConnection conn=QDBusConnection::sessionBus();
conn.registerObject("/obj",new DBusAdaptor????(&myObject) );
Do I have to implement my own adaptor to achieve this?
You can't inherit from 2 QDBusAbstractAdaptor classes, because they themselves inherit from QObject
which doesn't support multiple inheritance, and from QtDBus Adaptor documentation:
The class must also contain one Q_CLASSINFO entry with the "D-Bus Interface" name, declaring which interface it is exporting. Only one entry per class is supported.
So you can't implement yourself an adaptor that would support multiple interfaces.