blob: b4cbd6567ec016fe48acf4533064e1ce3343abf6 [file] [log] [blame]
Matthew Barth336f18a2017-09-26 09:15:56 -05001#pragma once
2
Matthew Barth336f18a2017-09-26 09:15:56 -05003#include "sdbusplus.hpp"
4
Matthew Barth3e1bb272020-05-26 11:09:21 -05005#include <sdbusplus/bus.hpp>
6
Matthew Barth336f18a2017-09-26 09:15:56 -05007namespace phosphor
8{
9namespace fan
10{
11namespace control
12{
13namespace match
14{
15
16using namespace phosphor::fan;
17using namespace sdbusplus::bus::match;
Matthew Barth336f18a2017-09-26 09:15:56 -050018
19/**
20 * @brief A match function that constructs a PropertiesChanged match string
21 * @details Constructs a PropertiesChanged match string with a given object
22 * path and interface
23 *
24 * @param[in] obj - Object's path name
25 * @param[in] iface - Interface name
26 *
27 * @return - A PropertiesChanged match string
28 */
29inline auto propertiesChanged(const std::string& obj, const std::string& iface)
30{
31 return rules::propertiesChanged(obj, iface);
32}
33
34/**
35 * @brief A match function that constructs an InterfacesAdded match string
36 * @details Constructs an InterfacesAdded match string with a given object
37 * path
38 *
39 * @param[in] obj - Object's path name
40 *
41 * @return - An InterfacesAdded match string
42 */
43inline auto interfacesAdded(const std::string& obj)
44{
45 return rules::interfacesAdded(obj);
46}
47
48/**
Matthew Barth1499a5c2018-03-20 15:52:33 -050049 * @brief A match function that constructs an InterfacesRemoved match string
50 * @details Constructs an InterfacesRemoved match string with a given object
51 * path
52 *
53 * @param[in] obj - Object's path name
54 *
55 * @return - An InterfacesRemoved match string
56 */
57inline auto interfacesRemoved(const std::string& obj)
58{
59 return rules::interfacesRemoved(obj);
60}
61
62/**
Matthew Barth336f18a2017-09-26 09:15:56 -050063 * @brief A match function that constructs a NameOwnerChanged match string
64 * @details Constructs a NameOwnerChanged match string with a given object
65 * path and interface
66 *
67 * @param[in] obj - Object's path name
68 * @param[in] iface - Interface name
69 *
70 * @return - A NameOwnerChanged match string
71 */
72inline auto nameOwnerChanged(const std::string& obj, const std::string& iface)
73{
74 std::string noc;
75 try
76 {
77 noc = rules::nameOwnerChanged(util::SDBusPlus::getService(obj, iface));
78 }
Matt Spinlerba7b5fe2018-04-25 15:26:10 -050079 catch (const util::DBusError& e)
Matthew Barth336f18a2017-09-26 09:15:56 -050080 {
81 // Unable to construct NameOwnerChanged match string
82 }
83 return noc;
84}
85
86} // namespace match
87} // namespace control
88} // namespace fan
89} // namespace phosphor