sdbusplus match interface changes
Patrick Williams
patrick at stwcx.xyz
Sat May 6 07:09:39 AEST 2017
There are three changes that I made recently to the sdbusplus match APIs
that I'd like new code to start using. I'm going through the existing
openbmc repositories and making the changes to existing code.
1. Namespace move.
The sdbusplus::server::match namespace is now sdbusplus::bus::match,
but there is a temporary alias for the old namespace still in place.
Once I get all changes merged in the user repositories, I'll remove
the alias.
This change was proposed by someone outside OpenBMC that was using
the library. I agreed that the 'match' utilities should not be in
server because they are just as likely to be used by a dbus-client.
2. Addition of match rule utilities.
I added a number of utilities in the sdbus::bus::match::rules
namespace that can be used to create signal match rules instead of
hand-written C-strings.
Old example:
"type='signal',member='JobRemoved',path='/org/freedesktop/systemd1',"
"interface='org.freedesktop.systemd1.Manager'"
New example:
type::signal() + member("JobRemoved") +
path("/org/freedesktop/systemd1) +
interface("org.freedesktop.systemd1.Manager)
3. Support for std::function-type callbacks.
Previously, when you had a class member function you wanted to have as
the callback for a dbus signal, you needed to make a static member
trampoline like:
static int callback(msg, void* context)
{
return static_cast<MyClass>(context)->realCallback(msg);
}
match m = match(..., &MyClass::callback, this);
You can now avoid writing the trampoline function by using
std::mem_fn:
match m = match(..., std::bind(std::mem_fn(&MyClass::callback),
this, _1));
The first repository I modified to take advantage of these three changes
is phosphor-state-manager. You can find that review here as an example:
https://gerrit.openbmc-project.xyz/#/c/4092
--
Patrick Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20170505/7e7378fa/attachment-0001.sig>
More information about the openbmc
mailing list