|
From: Andreas V. <li...@br...> - 2008-09-01 22:25:22
|
Am Sun, 31 Aug 2008 18:16:13 +0200 schrieb P. Durante: Hello Paolo, currently I work on a example implementation that explains all my ideas. I hope tomorrow it's finished and ready to show. Then we talk again about it. regards Andreas > Hi, > > On Sat, Aug 30, 2008 at 12:24 AM, Andreas Volz <li...@br...> > wrote: > > Hello, > > > > while writing a DBUS interface for my application I found a way to > > give objects direct "through" DBUS. In reality the objects aren't > > give through DBUS. Only the copyable contents are given though DBUS. > > > > So how does it work? > > > > See the example communication framework here. It's only a prototype > > and still has some problems. > > > > http://tux-style.de/tmp/oicf-0.1.tar.gz > > > > Look at OICFControlListener.cpp: (below as reference. Use the > > source for more overview) > > > > class OICFControlListener : > > public org::oicf::ControlListener, > > public DBus::IntrospectableProxy, > > public DBus::ObjectProxy > > { > > public: > > OICFControlListener ( DBus::Connection& connection, const char* > > path, const char* name ) : DBus::ObjectProxy (connection, path, > > name) {} > > > > virtual void onAxisListener (const KeyEvent &event) = 0; > > virtual void onButtonListener (const KeyEvent &event) = 0; > > > > private: > > void onAxisListener(const KeyEvent_Dbus_t &eventAxis) > > { > > KeyEvent event; > > event << eventAxis; > > > > onAxisListener (event); > > } > > > > void onButtonListener(const KeyEvent_Dbus_t &eventButton) > > { > > KeyEvent event; > > event << eventButton; > > > > onButtonListener (event); > > } > > > > }; > > > > As you see the private onAxisListener() from dbus-c++ is > > overwritten and creates the object KeyEvent, fills it with the '<<' > > operator and calls the new public callback function. > > > > Look into KeyEvent.h: > > I've perused the archive but can't find this file > > > > > typedef ::DBus::Struct <int32_t, int16_t, uint8_t, bool> > > KeyEvent_Dbus_t; > > > > class KeyEvent > > { > > public: > > ... > > > > public: > > int32_t time; > > int16_t value; > > int8_t number; > > > > public: > > void operator << (const KeyEvent_Dbus_t& event) > > { > > time = event._1; > > value = event._2; > > number = event._3; > > } > > }; > > > > from what I've read you basically want to automate marshaling and > unmarshaling of DBus structured types, is that correct? > if this where to be done in the code generator, where would the field > names (in this case, "time", "value", "number") be stored? in the xml? > > > This works as long as '<<' and '>>' operator is implemented correct > > in the class you like to give "through" dbus-c++. (See > > CoordWGS84.h) for another example. > > > > this file can't be found either :-\ > > > For sure objects are not given through DBUS, but it looks and > > behaves for the user in that way. > > > > Look at the introspection XML: > > > > <?xml version="1.0" ?> > > <node name="/org/oicf/ControlListener"> > > <interface name="org.oicf.ControlListener"> > > > > <signal name="onAxisListener"> > > <arg type="(inyb)" name="eventAxis" direction="out"/> > > </signal> > > > > <signal name="onButtonListener"> > > <arg type="(inyb)" name="eventButton" direction="out"/> > > </signal> > > > > </interface> > > > > </node> > > > > You see that it has a struct that exactly fits the KeyEvent.h data. > > > > This works so far, but it's much way to write all that wrapper > > functions on my own. This is exact the work a code generator is > > done for. I would propose to change the XML format in that way: > > > > <?xml version="1.0" ?> > > <node name="/org/oicf/ControlListener"> > > <interface name="org.oicf.ControlListener"> > > > > <signal name="onAxisListener"> > > <arg type="(inyb)" name="eventAxis" direction="out" > > object="KeyEvent"/> </signal> > > > > <signal name="onButtonListener"> > > <arg type="(inyb)" name="eventButton" direction="out" > > object="KeyEvent"/> </signal> > > > > </interface> > > > > </node> > > > > > > So the code generator know that he should add some code to give > > "class KeyEvent" in a "KeyEvent.h" in dbus-c++ as shown above. The > > only thing that has to be hand written is the KeyEvent.h and the > > '<<' and '>>' operator. > > > > This proposal is backwards compatible as other DBUS implementations > > simply ignore the "object" tag and give access to the data with the > > normal DBUS mechanisms. > > > > XML interfaces are supposed to be distributed to allow interoperation > with other applications and/or languages, since this addition would be > very specific to this particular implementation it could be > implemented using a dedicated annotation, other languages and bindings > (Glib and Qt come to mind) already do it, see > > http://dbus.freedesktop.org/doc/dbus-specification.html > > and look for "annotations" > > > What do you think about this idea? > > > > from what I understand you basically want to implement CORBA > ValueTypes in DBus :-) > > > regards > > Andreas > > > > regards, > Paolo > |