diff options
| author | Patrick Williams <patrick@stwcx.xyz> | 2016-10-18 22:14:12 -0500 |
|---|---|---|
| committer | Patrick Williams <patrick@stwcx.xyz> | 2016-10-20 16:40:33 -0500 |
| commit | ebd6b9c02cf1f1831b629b976a07e8f53f4c1235 (patch) | |
| tree | f3c9992ccb56583913fd5180c3a2d1a1355e0d09 | |
| parent | a475c03042bfcd1a1dd27eb1f8e837fc76c8a25f (diff) | |
| download | sdbusplus-ebd6b9c02cf1f1831b629b976a07e8f53f4c1235.tar.gz sdbusplus-ebd6b9c02cf1f1831b629b976a07e8f53f4c1235.zip | |
match: add signal callback registerer
Change-Id: I833e32360391cef8acbb8268e239fbc047173835
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
| -rw-r--r-- | sdbusplus/bus.hpp | 2 | ||||
| -rw-r--r-- | sdbusplus/server.hpp | 1 | ||||
| -rw-r--r-- | sdbusplus/server/match.hpp | 56 |
3 files changed, 59 insertions, 0 deletions
diff --git a/sdbusplus/bus.hpp b/sdbusplus/bus.hpp index 84f45ce..b814380 100644 --- a/sdbusplus/bus.hpp +++ b/sdbusplus/bus.hpp @@ -12,6 +12,7 @@ namespace sdbusplus namespace server { namespace interface { struct interface; } } namespace server { namespace manager { struct manager; } } namespace server { namespace object { template<class...> struct object; } } +namespace server { namespace match { struct match; } } namespace bus { @@ -169,6 +170,7 @@ struct bus friend struct server::interface::interface; friend struct server::manager::manager; template<class... Args> friend struct server::object::object; + friend struct server::match::match; private: busp_t get() { return _bus.get(); } diff --git a/sdbusplus/server.hpp b/sdbusplus/server.hpp index 6ec9757..bbea03b 100644 --- a/sdbusplus/server.hpp +++ b/sdbusplus/server.hpp @@ -6,3 +6,4 @@ #include <sdbusplus/server/interface.hpp> #include <sdbusplus/server/manager.hpp> #include <sdbusplus/server/object.hpp> +#include <sdbusplus/server/match.hpp> diff --git a/sdbusplus/server/match.hpp b/sdbusplus/server/match.hpp new file mode 100644 index 0000000..e7902f6 --- /dev/null +++ b/sdbusplus/server/match.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include <sdbusplus/slot.hpp> +#include <sdbusplus/bus.hpp> + +namespace sdbusplus +{ + +namespace server +{ + +namespace match +{ + +struct match +{ + /* Define all of the basic class operations: + * Not allowed: + * - Default constructor to avoid nullptrs. + * - Copy operations due to internal unique_ptr. + * Allowed: + * - Move operations. + * - Destructor. + */ + match() = delete; + match(const match&) = delete; + match& operator=(const match&) = delete; + match(match&&) = default; + match& operator=(match&&) = default; + ~match() = default; + + /** @brief Register a signal match. + * + * @param[in] bus - The bus to register on. + * @param[in] match - The match to register. + * @param[in] handler - The callback for matches. + */ + match(sdbusplus::bus::bus& bus, const char* match, + sd_bus_message_handler_t handler) : _slot(nullptr) + { + sd_bus_slot* slot = nullptr; + sd_bus_add_match(bus.get(), &slot, match, handler, nullptr); + + _slot = decltype(_slot){slot}; + } + + private: + slot::slot _slot; +}; + +} // namespace match + +using match_t = match::match; + +} // namespace server +} // namespace sdbusplus |

