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 an InterfacesRemoved match string 51 * @details Constructs an InterfacesRemoved match string with a given object 52 * path 53 * 54 * @param[in] obj - Object's path name 55 * 56 * @return - An InterfacesRemoved match string 57 */ 58 inline auto interfacesRemoved(const std::string& obj) 59 { 60 return rules::interfacesRemoved(obj); 61 } 62 63 /** 64 * @brief A match function that constructs a NameOwnerChanged match string 65 * @details Constructs a NameOwnerChanged match string with a given object 66 * path and interface 67 * 68 * @param[in] obj - Object's path name 69 * @param[in] iface - Interface name 70 * 71 * @return - A NameOwnerChanged match string 72 */ 73 inline auto nameOwnerChanged(const std::string& obj, const std::string& iface) 74 { 75 std::string noc; 76 try 77 { 78 noc = rules::nameOwnerChanged(util::SDBusPlus::getService(obj, iface)); 79 } 80 catch (const InternalFailure& ife) 81 { 82 // Unable to construct NameOwnerChanged match string 83 } 84 return noc; 85 } 86 87 } // namespace match 88 } // namespace control 89 } // namespace fan 90 } // namespace phosphor 91