diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-09-26 09:15:56 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-11-17 15:43:28 +0000 |
commit | 336f18a541e93e2cc1719180df73ef8b357c962f (patch) | |
tree | e0edf72beb42a9c7a7a6ce9e46b768d1b7fcfffd /control/matches.hpp | |
parent | 6088558429fbe5f723783b4220b6ac1c9096cde9 (diff) | |
download | phosphor-fan-presence-336f18a541e93e2cc1719180df73ef8b357c962f.tar.gz phosphor-fan-presence-336f18a541e93e2cc1719180df73ef8b357c962f.zip |
Update event initialization
Using a null dbus message to the event signal will perform the necessary
steps to initialize the event parameters using the given signal
handler's function directly.
i.e.) In the case for subscribing to PropertiesChanged signals,
initially the given property must be read. When the PropertiesChanged
signal struct is given a null message, it finds the property, reads the
value, and then can perform the given signal handler function directly.
This produces the same functional path as receiving a PropertiesChanged
signal containing the property value within the message.
Change-Id: I35575cfff66eb0305156be786cb1f5536d42bb1c
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control/matches.hpp')
-rw-r--r-- | control/matches.hpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/control/matches.hpp b/control/matches.hpp new file mode 100644 index 0000000..855a749 --- /dev/null +++ b/control/matches.hpp @@ -0,0 +1,76 @@ +#pragma once + +#include <sdbusplus/bus.hpp> +#include "sdbusplus.hpp" + +namespace phosphor +{ +namespace fan +{ +namespace control +{ +namespace match +{ + +using namespace phosphor::fan; +using namespace sdbusplus::bus::match; +using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: + Error::InternalFailure; + +/** + * @brief A match function that constructs a PropertiesChanged match string + * @details Constructs a PropertiesChanged match string with a given object + * path and interface + * + * @param[in] obj - Object's path name + * @param[in] iface - Interface name + * + * @return - A PropertiesChanged match string + */ +inline auto propertiesChanged(const std::string& obj, const std::string& iface) +{ + return rules::propertiesChanged(obj, iface); +} + +/** + * @brief A match function that constructs an InterfacesAdded match string + * @details Constructs an InterfacesAdded match string with a given object + * path + * + * @param[in] obj - Object's path name + * + * @return - An InterfacesAdded match string + */ +inline auto interfacesAdded(const std::string& obj) +{ + return rules::interfacesAdded(obj); +} + +/** + * @brief A match function that constructs a NameOwnerChanged match string + * @details Constructs a NameOwnerChanged match string with a given object + * path and interface + * + * @param[in] obj - Object's path name + * @param[in] iface - Interface name + * + * @return - A NameOwnerChanged match string + */ +inline auto nameOwnerChanged(const std::string& obj, const std::string& iface) +{ + std::string noc; + try + { + noc = rules::nameOwnerChanged(util::SDBusPlus::getService(obj, iface)); + } + catch (const InternalFailure& ife) + { + // Unable to construct NameOwnerChanged match string + } + return noc; +} + +} // namespace match +} // namespace control +} // namespace fan +} // namespace phosphor |