Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame^] | 1 | #include <algorithm> |
| 2 | #include <sdbusplus/server.hpp> |
| 3 | #include <sdbusplus/exception.hpp> |
| 4 | #include "xyz/openbmc_project/Led/Group/server.hpp" |
| 5 | |
| 6 | namespace sdbusplus |
| 7 | { |
| 8 | namespace xyz |
| 9 | { |
| 10 | namespace openbmc_project |
| 11 | { |
| 12 | namespace Led |
| 13 | { |
| 14 | namespace server |
| 15 | { |
| 16 | |
| 17 | Group::Group(bus::bus& bus, const char* path) |
| 18 | : _xyz_openbmc_project_Led_Group_interface( |
| 19 | bus, path, _interface, _vtable, this) |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | |
| 24 | |
| 25 | auto Group::asserted() const -> |
| 26 | bool |
| 27 | { |
| 28 | return _asserted; |
| 29 | } |
| 30 | |
| 31 | int Group::_callback_get_Asserted( |
| 32 | sd_bus* bus, const char* path, const char* interface, |
| 33 | const char* property, sd_bus_message* reply, void* context, |
| 34 | sd_bus_error* error) |
| 35 | { |
| 36 | using sdbusplus::server::binding::details::convertForMessage; |
| 37 | |
| 38 | try |
| 39 | { |
| 40 | auto m = message::message(sd_bus_message_ref(reply)); |
| 41 | |
| 42 | auto o = static_cast<Group*>(context); |
| 43 | m.append(convertForMessage(o->asserted())); |
| 44 | } |
| 45 | catch(sdbusplus::internal_exception_t& e) |
| 46 | { |
| 47 | sd_bus_error_set_const(error, e.name(), e.description()); |
| 48 | return -EINVAL; |
| 49 | } |
| 50 | |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | auto Group::asserted(bool value) -> |
| 55 | bool |
| 56 | { |
| 57 | if (_asserted != value) |
| 58 | { |
| 59 | _asserted = value; |
| 60 | _xyz_openbmc_project_Led_Group_interface.property_changed("Asserted"); |
| 61 | } |
| 62 | |
| 63 | return _asserted; |
| 64 | } |
| 65 | |
| 66 | int Group::_callback_set_Asserted( |
| 67 | sd_bus* bus, const char* path, const char* interface, |
| 68 | const char* property, sd_bus_message* value, void* context, |
| 69 | sd_bus_error* error) |
| 70 | { |
| 71 | try |
| 72 | { |
| 73 | auto m = message::message(sd_bus_message_ref(value)); |
| 74 | |
| 75 | auto o = static_cast<Group*>(context); |
| 76 | |
| 77 | bool v{}; |
| 78 | m.read(v); |
| 79 | o->asserted(v); |
| 80 | } |
| 81 | catch(sdbusplus::internal_exception_t& e) |
| 82 | { |
| 83 | sd_bus_error_set_const(error, e.name(), e.description()); |
| 84 | return -EINVAL; |
| 85 | } |
| 86 | |
| 87 | return true; |
| 88 | } |
| 89 | |
| 90 | namespace details |
| 91 | { |
| 92 | namespace Group |
| 93 | { |
| 94 | static const auto _property_Asserted = |
| 95 | utility::tuple_to_array(message::types::type_id< |
| 96 | bool>()); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | |
| 101 | const vtable::vtable_t Group::_vtable[] = { |
| 102 | vtable::start(), |
| 103 | vtable::property("Asserted", |
| 104 | details::Group::_property_Asserted |
| 105 | .data(), |
| 106 | _callback_get_Asserted, |
| 107 | _callback_set_Asserted, |
| 108 | vtable::property_::emits_change), |
| 109 | vtable::end() |
| 110 | }; |
| 111 | |
| 112 | } // namespace server |
| 113 | } // namespace Led |
| 114 | } // namespace openbmc_project |
| 115 | } // namespace xyz |
| 116 | } // namespace sdbusplus |
| 117 | |