blob: 855a749ad8a88b42e03a055e35df331cb6b4fc8c [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;
17using 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 */
30inline 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 */
44inline 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 */
59inline 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