-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow arbitrary structs in an sdbus interface #420
Comments
Hi Marcel, thanks for the detailed description and the proposal, and yes, this interesting and useful topic is in my backlog and there already was an issue/suggestion raised in this respect before. I started prototyping a non-intrusive user struct description solution but then got interrupted. I wanted to release v2 first, but there were still ideas coming to implement given this breaking-change major release opportunity, and limited time. I hope this is coming to its finish line. I'll let you know once I get back to this topic and you and I can share own solutions and discuss. From quickly reading over your list of disadvantages, boost::mpl dependency is something which we most likely won't be able to accept... Let's see then. |
@hellow554 I got to back to this now. While reflecting on the problem and the potential solution, I realized we already have a very solid foundation for extending support for user-defined structs, as a part of generic solution for teaching sdbus-c++ about user-defined types that I introduced in August last year. See the sdbus-c++ cookbook, section Extending sdbus-c++ type system with an example of Clients need to simply define the This will enable them to pass these structs directly to sdbus-c++ API on both server and client side, as if they were What do you think? This would mean we don't need any extra code for conversions between structs etc. Have you tried that approach? If higher convenience is needed, we could potentially provide one macro for structs that would define the above-mentioned needed overloads/specializations. Something like |
A very nice bonus is that we automatically get support for nested structs. Struct members can have types that are other user-defined structs, or user-defined containers (like Also, we could extend the XML syntax for the xml-to-cpp codegen. An attribute or a sub-element could be added under a |
That section looks different than the last time I looked at it, seems to be a long time ago 🙈 TBH: I never used the xml-to-cpp so far, maybe it's time to take a look into it. Thanks for your long and good explanation of your point of view. |
Hey @hellow554, FYI, I introduced the Today I also opened a merge request which adds more functionality to the Just in case it could interest you, or help improve your code. You can also share your feedback in case something more could be added or improved :o) |
Is your feature request related to a problem? Please describe.
In our product we have a large amount of structs going back and forth between multiple programs.
For this to work, we have a common file between all projects that contains something like this:
This is of course not a great interface, because even I can't tell what these members do.
So, I tried to come up with a lot of template magic code and tried to convert a regular struct/class to a
sdbus::Struct
and it worked.The question is now, are you interested in allowing such thing.
Describe the solution you'd like
I have a solution ready that currently allows to write
to_sdbus_struct(system_status_1)
which converts astruct SystemStatus1 { ... }
tosdbus::Struct<...>
andto_cpp_struct
wich converts it the other way around.We could integrate this directly into sdbus-c++ and make automatic conversion from and to sdbus types possible
This would allow us and other people to use structs as interface description instead of the
using
I wrote above.There are a few downsides:
float
s aren't allowed in the struct, because it's not part of the dbus interface specificationPlease tell me what you think.
I can provide some code examples and you tell me how you like it or not.
The text was updated successfully, but these errors were encountered: