summaryrefslogtreecommitdiffstats
path: root/control/matches.hpp
blob: 855a749ad8a88b42e03a055e35df331cb6b4fc8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once

#include <sdbusplus/bus.hpp>
#include "sdbusplus.hpp"

namespace phosphor
{
namespace fan
{
namespace control
{
namespace match
{

using namespace phosphor::fan;
using namespace sdbusplus::bus::match;
using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
                             Error::InternalFailure;

/**
 * @brief A match function that constructs a PropertiesChanged match string
 * @details Constructs a PropertiesChanged match string with a given object
 * path and interface
 *
 * @param[in] obj - Object's path name
 * @param[in] iface - Interface name
 *
 * @return - A PropertiesChanged match string
 */
inline auto propertiesChanged(const std::string& obj, const std::string& iface)
{
    return rules::propertiesChanged(obj, iface);
}

/**
 * @brief A match function that constructs an InterfacesAdded match string
 * @details Constructs an InterfacesAdded match string with a given object
 * path
 *
 * @param[in] obj - Object's path name
 *
 * @return - An InterfacesAdded match string
 */
inline auto interfacesAdded(const std::string& obj)
{
    return rules::interfacesAdded(obj);
}

/**
 * @brief A match function that constructs a NameOwnerChanged match string
 * @details Constructs a NameOwnerChanged match string with a given object
 * path and interface
 *
 * @param[in] obj - Object's path name
 * @param[in] iface - Interface name
 *
 * @return - A NameOwnerChanged match string
 */
inline auto nameOwnerChanged(const std::string& obj, const std::string& iface)
{
    std::string noc;
    try
    {
        noc = rules::nameOwnerChanged(util::SDBusPlus::getService(obj, iface));
    }
    catch (const InternalFailure& ife)
    {
        // Unable to construct NameOwnerChanged match string
    }
    return noc;
}

} // namespace match
} // namespace control
} // namespace fan
} // namespace phosphor
OpenPOWER on IntegriCloud