1 #pragma once 2 3 #include <sdbusplus/bus.hpp> 4 #include "sdbusplus.hpp" 5 6 namespace phosphor 7 { 8 namespace fan 9 { 10 namespace control 11 { 12 namespace match 13 { 14 15 using namespace phosphor::fan; 16 using namespace sdbusplus::bus::match; 17 using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: 18 Error::InternalFailure; 19 20 /** 21 * @brief A match function that constructs a PropertiesChanged match string 22 * @details Constructs a PropertiesChanged match string with a given object 23 * path and interface 24 * 25 * @param[in] obj - Object's path name 26 * @param[in] iface - Interface name 27 * 28 * @return - A PropertiesChanged match string 29 */ 30 inline auto propertiesChanged(const std::string& obj, const std::string& iface) 31 { 32 return rules::propertiesChanged(obj, iface); 33 } 34 35 /** 36 * @brief A match function that constructs an InterfacesAdded match string 37 * @details Constructs an InterfacesAdded match string with a given object 38 * path 39 * 40 * @param[in] obj - Object's path name 41 * 42 * @return - An InterfacesAdded match string 43 */ 44 inline auto interfacesAdded(const std::string& obj) 45 { 46 return rules::interfacesAdded(obj); 47 } 48 49 /** 50 * @brief A match function that constructs a NameOwnerChanged match string 51 * @details Constructs a NameOwnerChanged match string with a given object 52 * path and interface 53 * 54 * @param[in] obj - Object's path name 55 * @param[in] iface - Interface name 56 * 57 * @return - A NameOwnerChanged match string 58 */ 59 inline auto nameOwnerChanged(const std::string& obj, const std::string& iface) 60 { 61 std::string noc; 62 try 63 { 64 noc = rules::nameOwnerChanged(util::SDBusPlus::getService(obj, iface)); 65 } 66 catch (const InternalFailure& ife) 67 { 68 // Unable to construct NameOwnerChanged match string 69 } 70 return noc; 71 } 72 73 } // namespace match 74 } // namespace control 75 } // namespace fan 76 } // namespace phosphor 77