|
From: Andreas V. <li...@br...> - 2008-08-29 22:25:29
|
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: 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; } }; 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. 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. What do you think about this idea? regards Andreas |
|
From: P. D. <sh...@gm...> - 2008-08-31 16:16:17
|
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 |
|
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 > |
|
From: Andreas V. <li...@br...> - 2008-09-02 22:50:14
|
Am Tue, 2 Sep 2008 00:20:15 +0200 schrieb Andreas Volz: > 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. Here is the result of my proposal. I modified the dbusxx-xml2cpp tool to generate the object binding. See here: http://gitorious.org/projects/dbus-cplusplus/repos/mainline/blobs/master/tools%2Fxml2cpp.cpp As result it parses the object="MyObject" code in the XML and generates code based on it. See here a prototype of my communication library: http://www.tux-style.de/tmp/dbus-cplusplus/oicf-0.1.tar.gz and here the dbus-c++ code generated with it: http://www.tux-style.de/tmp/dbus-cplusplus/oicf-0.1_bin.tar.gz It seems to work for signals and methods, but it's not extreme tested for in and out values. I need to write more tests for it. It works well and is 100% compatible to other dbus bindings. You even don't need to do it in dbus-c++ if you fear of more object creations while communications. Simply don't use the "object" tag. What do you think? I would like to see it integrated into the official repo. BTW: As I noticed the tabs aren't perfect. In both source code and generated code. But I think that's a minor problem. BTW2: Maybe you noticed that I added some more comments for dbusxx-xml2cpp while understanding it. So the next new person will faster understand it. regards Andreas |
|
From: Andreas V. <li...@br...> - 2008-09-08 20:55:23
|
Am Wed, 3 Sep 2008 00:45:17 +0200 schrieb Andreas Volz: > Am Tue, 2 Sep 2008 00:20:15 +0200 schrieb Andreas Volz: > > > 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. > > Here is the result of my proposal. I modified the dbusxx-xml2cpp tool > to generate the object binding. See here: > > http://gitorious.org/projects/dbus-cplusplus/repos/mainline/blobs/master/tools%2Fxml2cpp.cpp > > As result it parses the object="MyObject" code in the XML and > generates code based on it. See here a prototype of my communication > library: > > http://www.tux-style.de/tmp/dbus-cplusplus/oicf-0.1.tar.gz > > and here the dbus-c++ code generated with it: > > http://www.tux-style.de/tmp/dbus-cplusplus/oicf-0.1_bin.tar.gz > > It seems to work for signals and methods, but it's not extreme tested > for in and out values. I need to write more tests for it. > > It works well and is 100% compatible to other dbus bindings. You even > don't need to do it in dbus-c++ if you fear of more object creations > while communications. Simply don't use the "object" tag. > > What do you think? > > I would like to see it integrated into the official repo. > > BTW: As I noticed the tabs aren't perfect. In both source code and > generated code. But I think that's a minor problem. > > BTW2: Maybe you noticed that I added some more comments for > dbusxx-xml2cpp while understanding it. So the next new person will > faster understand it. Did you've some time to look into my proposal? regards Andreas |