summaryrefslogtreecommitdiffstats
path: root/xyz.openbmc_project.Led.Group.cpp
blob: cd32b4b47af6ac30251476a8c2240a9319a483a9 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <algorithm>
#include <sdbusplus/server.hpp>
#include <sdbusplus/exception.hpp>
#include "xyz/openbmc_project/Led/Group/server.hpp"

namespace sdbusplus
{
namespace xyz
{
namespace openbmc_project
{
namespace Led
{
namespace server
{

Group::Group(bus::bus& bus, const char* path)
        : _xyz_openbmc_project_Led_Group_interface(
                bus, path, _interface, _vtable, this)
{
}



auto Group::asserted() const ->
        bool
{
    return _asserted;
}

int Group::_callback_get_Asserted(
        sd_bus* bus, const char* path, const char* interface,
        const char* property, sd_bus_message* reply, void* context,
        sd_bus_error* error)
{
    using sdbusplus::server::binding::details::convertForMessage;

    try
    {
        auto m = message::message(sd_bus_message_ref(reply));

        auto o = static_cast<Group*>(context);
        m.append(convertForMessage(o->asserted()));
    }
    catch(sdbusplus::internal_exception_t& e)
    {
        sd_bus_error_set_const(error, e.name(), e.description());
        return -EINVAL;
    }

    return true;
}

auto Group::asserted(bool value) ->
        bool
{
    if (_asserted != value)
    {
        _asserted = value;
        _xyz_openbmc_project_Led_Group_interface.property_changed("Asserted");
    }

    return _asserted;
}

int Group::_callback_set_Asserted(
        sd_bus* bus, const char* path, const char* interface,
        const char* property, sd_bus_message* value, void* context,
        sd_bus_error* error)
{
    try
    {
        auto m = message::message(sd_bus_message_ref(value));

        auto o = static_cast<Group*>(context);

        bool v{};
        m.read(v);
        o->asserted(v);
    }
    catch(sdbusplus::internal_exception_t& e)
    {
        sd_bus_error_set_const(error, e.name(), e.description());
        return -EINVAL;
    }

    return true;
}

namespace details
{
namespace Group
{
static const auto _property_Asserted =
    utility::tuple_to_array(message::types::type_id<
            bool>());
}
}


const vtable::vtable_t Group::_vtable[] = {
    vtable::start(),
    vtable::property("Asserted",
                     details::Group::_property_Asserted
                        .data(),
                     _callback_get_Asserted,
                     _callback_set_Asserted,
                     vtable::property_::emits_change),
    vtable::end()
};

} // namespace server
} // namespace Led
} // namespace openbmc_project
} // namespace xyz
} // namespace sdbusplus

OpenPOWER on IntegriCloud