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 18 /** 19 * @brief A match function that constructs a PropertiesChanged match string 20 * @details Constructs a PropertiesChanged match string with a given object 21 * path and interface 22 * 23 * @param[in] obj - Object's path name 24 * @param[in] iface - Interface name 25 * 26 * @return - A PropertiesChanged match string 27 */ 28 inline auto propertiesChanged(const std::string& obj, const std::string& iface) 29 { 30 return rules::propertiesChanged(obj, iface); 31 } 32 33 /** 34 * @brief A match function that constructs an InterfacesAdded match string 35 * @details Constructs an InterfacesAdded match string with a given object 36 * path 37 * 38 * @param[in] obj - Object's path name 39 * 40 * @return - An InterfacesAdded match string 41 */ 42 inline auto interfacesAdded(const std::string& obj) 43 { 44 return rules::interfacesAdded(obj); 45 } 46 47 /** 48 * @brief A match function that constructs an InterfacesRemoved match string 49 * @details Constructs an InterfacesRemoved match string with a given object 50 * path 51 * 52 * @param[in] obj - Object's path name 53 * 54 * @return - An InterfacesRemoved match string 55 */ 56 inline auto interfacesRemoved(const std::string& obj) 57 { 58 return rules::interfacesRemoved(obj); 59 } 60 61 /** 62 * @brief A match function that constructs a NameOwnerChanged match string 63 * @details Constructs a NameOwnerChanged match string with a given object 64 * path and interface 65 * 66 * @param[in] obj - Object's path name 67 * @param[in] iface - Interface name 68 * 69 * @return - A NameOwnerChanged match string 70 */ 71 inline auto nameOwnerChanged(const std::string& obj, const std::string& iface) 72 { 73 std::string noc; 74 try 75 { 76 noc = rules::nameOwnerChanged(util::SDBusPlus::getService(obj, iface)); 77 } 78 catch (const util::DBusError& e) 79 { 80 // Unable to construct NameOwnerChanged match string 81 } 82 return noc; 83 } 84 85 } // namespace match 86 } // namespace control 87 } // namespace fan 88 } // namespace phosphor 89