From 55ef5b04c9f35174b2c398793438af49b832f4e5 Mon Sep 17 00:00:00 2001 From: Vishwanatha Subbanna Date: Fri, 10 Mar 2017 13:32:08 +0530 Subject: Link to dbus interfaces library for using generated code Change-Id: I7db65c8bea0bc111e9b0810ffdc33a8ffc924f5e Signed-off-by: Vishwanatha Subbanna --- Makefile.am | 11 +-- configure.ac | 1 + group.hpp | 2 +- xyz.openbmc_project.Led.Group.cpp | 117 ------------------------------- xyz/openbmc_project/Led/Group/server.hpp | 77 -------------------- 5 files changed, 9 insertions(+), 199 deletions(-) delete mode 100644 xyz.openbmc_project.Led.Group.cpp delete mode 100644 xyz/openbmc_project/Led/Group/server.hpp diff --git a/Makefile.am b/Makefile.am index 337cad3..75888f6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,8 +4,7 @@ sbin_PROGRAMS = phosphor-ledmanager phosphor_ledmanager_SOURCES = \ led-main.cpp \ manager.cpp \ - group.cpp \ - xyz.openbmc_project.Led.Group.cpp + group.cpp BUILT_SOURCES = led-gen.hpp CLEANFILES = led-gen.hpp @@ -13,7 +12,11 @@ CLEANFILES = led-gen.hpp led-gen.hpp: ${srcdir}/parse_led.py $(AM_V)@LEDGEN@ > $@ -phosphor_ledmanager_LDFLAGS = $(SDBUSPLUS_LIBS) $(PHOSPHOR_LOGGING_LIBS) -phosphor_ledmanager_CFLAGS = $(SDBUSPLUS_CFLAGS) $(PHOSPHOR_LOGGING_CFLAGS) +phosphor_ledmanager_LDFLAGS = $(SDBUSPLUS_LIBS) \ + $(PHOSPHOR_LOGGING_LIBS) \ + $(PHOSPHOR_DBUS_INTERFACES_LIBS) +phosphor_ledmanager_CFLAGS = $(SDBUSPLUS_CFLAGS) \ + $(PHOSPHOR_LOGGING_CFLAGS) \ + $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) SUBDIRS = test diff --git a/configure.ac b/configure.ac index 51f6ad9..8cac302 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,7 @@ AS_IF([test "x$enable_oe_sdk" == "xyes"], # Checks for modules PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],, [AC_MSG_ERROR([Could not find sdbusplus...openbmc/sdbusplus package required])]) PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging],, [AC_MSG_ERROR([Could not find phosphor-logging...openbmc/phosphor-logging package required])]) +PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],, [AC_MSG_ERROR([Could not find phosphor-dbus-interfaces...openbmc/phosphor-dbus-interfaces package required])]) # Dbus service name AC_ARG_VAR(BUSNAME, [The Dbus busname to own]) diff --git a/group.hpp b/group.hpp index 3a14dc1..34f7afd 100644 --- a/group.hpp +++ b/group.hpp @@ -2,7 +2,7 @@ #include #include -#include "xyz/openbmc_project/Led/Group/server.hpp" +#include #include "manager.hpp" namespace phosphor { diff --git a/xyz.openbmc_project.Led.Group.cpp b/xyz.openbmc_project.Led.Group.cpp deleted file mode 100644 index cd32b4b..0000000 --- a/xyz.openbmc_project.Led.Group.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include -#include -#include -#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(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(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 - diff --git a/xyz/openbmc_project/Led/Group/server.hpp b/xyz/openbmc_project/Led/Group/server.hpp deleted file mode 100644 index 9f5a796..0000000 --- a/xyz/openbmc_project/Led/Group/server.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#pragma once -#include -#include -#include - -namespace sdbusplus -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Led -{ -namespace server -{ - -class Group -{ - public: - /* Define all of the basic class operations: - * Not allowed: - * - Default constructor to avoid nullptrs. - * - Copy operations due to internal unique_ptr. - * Allowed: - * - Move operations. - * - Destructor. - */ - Group() = delete; - Group(const Group&) = delete; - Group& operator=(const Group&) = delete; - Group(Group&&) = default; - Group& operator=(Group&&) = default; - virtual ~Group() = default; - - /** @brief Constructor to put object onto bus at a dbus path. - * @param[in] bus - Bus to attach to. - * @param[in] path - Path to attach at. - */ - Group(bus::bus& bus, const char* path); - - - - - /** Get value of Asserted */ - virtual bool asserted() const; - /** Set value of Asserted */ - virtual bool asserted(bool value); - - - private: - - /** @brief sd-bus callback for get-property 'Asserted' */ - static int _callback_get_Asserted( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'Asserted' */ - static int _callback_set_Asserted( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - - static constexpr auto _interface = "xyz.openbmc_project.Led.Group"; - static const vtable::vtable_t _vtable[]; - sdbusplus::server::interface::interface - _xyz_openbmc_project_Led_Group_interface; - - bool _asserted{}; - -}; - - -} // namespace server -} // namespace Led -} // namespace openbmc_project -} // namespace xyz -} // namespace sdbusplus - -- cgit v1.2.1