blob: c3b40060a3687f1a73d7216b941098eee3e312f5 [file] [log] [blame]
Matthew Barth336f18a2017-09-26 09:15:56 -05001#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include "sdbusplus.hpp"
5
6namespace phosphor
7{
8namespace fan
9{
10namespace control
11{
12namespace match
13{
14
15using namespace phosphor::fan;
16using namespace sdbusplus::bus::match;
Matthew Barth336f18a2017-09-26 09:15:56 -050017
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 */
28inline 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 */
42inline auto interfacesAdded(const std::string& obj)
43{
44 return rules::interfacesAdded(obj);
45}
46
47/**
Matthew Barth1499a5c2018-03-20 15:52:33 -050048 * @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 */
56inline auto interfacesRemoved(const std::string& obj)
57{
58 return rules::interfacesRemoved(obj);
59}
60
61/**
Matthew Barth336f18a2017-09-26 09:15:56 -050062 * @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 */
71inline 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 }
Matt Spinlerba7b5fe2018-04-25 15:26:10 -050078 catch (const util::DBusError& e)
Matthew Barth336f18a2017-09-26 09:15:56 -050079 {
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