diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-02-16 11:10:40 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-02-16 11:10:40 -0500 |
commit | bf86e72ebc4b33264ac0d8d6c8f0383f76b44e0f (patch) | |
tree | a7ad5353f14d42382bb728e07fecaa6e6d8d5057 | |
parent | 30dbceec70d96487016b129334ba539b9e161c08 (diff) | |
download | phosphor-hwmon-bf86e72ebc4b33264ac0d8d6c8f0383f76b44e0f.tar.gz phosphor-hwmon-bf86e72ebc4b33264ac0d8d6c8f0383f76b44e0f.zip |
Link to libphosphor_dbus
Remove manually generated server bindings.
Change-Id: I77ccda7f669d58f55e86ee5887dbbb380c673390
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rw-r--r-- | Makefile.am | 12 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | test/Makefile.am | 4 | ||||
-rw-r--r-- | xyz.openbmc_project.Sensor.Threshold.Critical.cpp | 360 | ||||
-rw-r--r-- | xyz.openbmc_project.Sensor.Threshold.Warning.cpp | 360 | ||||
-rw-r--r-- | xyz.openbmc_project.Sensor.Value.cpp | 319 | ||||
-rw-r--r-- | xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp | 122 | ||||
-rw-r--r-- | xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp | 122 | ||||
-rw-r--r-- | xyz/openbmc_project/Sensor/Value/server.hpp | 130 |
9 files changed, 10 insertions, 1422 deletions
diff --git a/Makefile.am b/Makefile.am index 8340c05..5ce260f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,19 +2,19 @@ sbin_PROGRAMS = phosphor-hwmon-readd phosphor_hwmon_readd_SOURCES = readd.cpp phosphor_hwmon_readd_LDADD = libhwmon.la -phosphor_hwmon_readd_LDFLAGS = $(SYSTEMD_LIBS) -phosphor_hwmon_readd_CFLAGS = $(SYSTEMD_CFLAGS) +phosphor_hwmon_readd_LDFLAGS = $(SDBUSPLUS_LIBS) +phosphor_hwmon_readd_CFLAGS = $(SDBUSPLUS_CFLAGS) noinst_LTLIBRARIES = libhwmon.la +libhwmon_la_LDFLAGS = $(SDBUSPLUS_LIBS) $(PHOSPHOR_DBUS_INTERFACES_LIBS) +libhwmon_la_CFLAGS = $(SDBUSPLUS_CFLAGS) $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) + libhwmon_la_SOURCES = \ argument.cpp \ directory.cpp \ sensorset.cpp \ mainloop.cpp \ sysfs.cpp \ - env.cpp \ - xyz.openbmc_project.Sensor.Value.cpp \ - xyz.openbmc_project.Sensor.Threshold.Warning.cpp \ - xyz.openbmc_project.Sensor.Threshold.Critical.cpp + env.cpp SUBDIRS = . test diff --git a/configure.ac b/configure.ac index 845b186..8fd31ac 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,8 @@ AC_PROG_INSTALL AC_PROG_MAKE_SET # Checks for libraries. -PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221]) +PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus], [], [AC_MSG_ERROR(["sdbusplus required and not found."])]) +PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces], [], [AC_MSG_ERROR(["phosphor-dbus-interfaces required and not found."])]) # Checks for typedefs, structures, and compiler characteristics. AX_CXX_COMPILE_STDCXX_14([noext]) diff --git a/test/Makefile.am b/test/Makefile.am index efdc8c7..0d7d7a0 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -3,6 +3,6 @@ noinst_PROGRAMS = phosphor-hwmon-test phosphor_hwmon_test_SOURCES = \ test.cpp -phosphor_hwmon_test_LDFLAGS = $(SYSTEMD_LIBS) $(PTHREAD_CFLAGS) -phosphor_hwmon_test_CFLAGS = $(SYSTEMD_CFLAGS) +phosphor_hwmon_test_LDFLAGS = $(SDBUSPLUS_LIBS) $(PTHREAD_CFLAGS) +phosphor_hwmon_test_CFLAGS = $(SDBUSPLUS_CFLAGS) phosphor_hwmon_test_LDADD = ${top_builddir}/libhwmon.la diff --git a/xyz.openbmc_project.Sensor.Threshold.Critical.cpp b/xyz.openbmc_project.Sensor.Threshold.Critical.cpp deleted file mode 100644 index 755174d..0000000 --- a/xyz.openbmc_project.Sensor.Threshold.Critical.cpp +++ /dev/null @@ -1,360 +0,0 @@ -#include <algorithm> -#include <sdbusplus/server.hpp> -#include <sdbusplus/exception.hpp> -#include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp> - -namespace sdbusplus -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Sensor -{ -namespace Threshold -{ -namespace server -{ - -Critical::Critical(bus::bus& bus, const char* path) - : _xyz_openbmc_project_Sensor_Threshold_Critical_interface( - bus, path, _interface, _vtable, this) -{ -} - - - -auto Critical::criticalHigh() const -> - int64_t -{ - return _criticalHigh; -} - -int Critical::_callback_get_CriticalHigh( - 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<Critical*>(context); - m.append(convertForMessage(o->criticalHigh())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Critical::criticalHigh(int64_t value) -> - int64_t -{ - if (_criticalHigh != value) - { - _criticalHigh = value; - _xyz_openbmc_project_Sensor_Threshold_Critical_interface.property_changed("CriticalHigh"); - } - - return _criticalHigh; -} - -int Critical::_callback_set_CriticalHigh( - 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<Critical*>(context); - - int64_t v{}; - m.read(v); - o->criticalHigh(v); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Critical -{ -static const auto _property_CriticalHigh = - utility::tuple_to_array(message::types::type_id< - int64_t>()); -} -} -auto Critical::criticalLow() const -> - int64_t -{ - return _criticalLow; -} - -int Critical::_callback_get_CriticalLow( - 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<Critical*>(context); - m.append(convertForMessage(o->criticalLow())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Critical::criticalLow(int64_t value) -> - int64_t -{ - if (_criticalLow != value) - { - _criticalLow = value; - _xyz_openbmc_project_Sensor_Threshold_Critical_interface.property_changed("CriticalLow"); - } - - return _criticalLow; -} - -int Critical::_callback_set_CriticalLow( - 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<Critical*>(context); - - int64_t v{}; - m.read(v); - o->criticalLow(v); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Critical -{ -static const auto _property_CriticalLow = - utility::tuple_to_array(message::types::type_id< - int64_t>()); -} -} -auto Critical::criticalAlarmHigh() const -> - bool -{ - return _criticalAlarmHigh; -} - -int Critical::_callback_get_CriticalAlarmHigh( - 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<Critical*>(context); - m.append(convertForMessage(o->criticalAlarmHigh())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Critical::criticalAlarmHigh(bool value) -> - bool -{ - if (_criticalAlarmHigh != value) - { - _criticalAlarmHigh = value; - _xyz_openbmc_project_Sensor_Threshold_Critical_interface.property_changed("CriticalAlarmHigh"); - } - - return _criticalAlarmHigh; -} - -int Critical::_callback_set_CriticalAlarmHigh( - 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<Critical*>(context); - - bool v{}; - m.read(v); - o->criticalAlarmHigh(v); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Critical -{ -static const auto _property_CriticalAlarmHigh = - utility::tuple_to_array(message::types::type_id< - bool>()); -} -} -auto Critical::criticalAlarmLow() const -> - bool -{ - return _criticalAlarmLow; -} - -int Critical::_callback_get_CriticalAlarmLow( - 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<Critical*>(context); - m.append(convertForMessage(o->criticalAlarmLow())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Critical::criticalAlarmLow(bool value) -> - bool -{ - if (_criticalAlarmLow != value) - { - _criticalAlarmLow = value; - _xyz_openbmc_project_Sensor_Threshold_Critical_interface.property_changed("CriticalAlarmLow"); - } - - return _criticalAlarmLow; -} - -int Critical::_callback_set_CriticalAlarmLow( - 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<Critical*>(context); - - bool v{}; - m.read(v); - o->criticalAlarmLow(v); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Critical -{ -static const auto _property_CriticalAlarmLow = - utility::tuple_to_array(message::types::type_id< - bool>()); -} -} - - -const vtable::vtable_t Critical::_vtable[] = { - vtable::start(), - vtable::property("CriticalHigh", - details::Critical::_property_CriticalHigh - .data(), - _callback_get_CriticalHigh, - _callback_set_CriticalHigh, - vtable::property_::emits_change), - vtable::property("CriticalLow", - details::Critical::_property_CriticalLow - .data(), - _callback_get_CriticalLow, - _callback_set_CriticalLow, - vtable::property_::emits_change), - vtable::property("CriticalAlarmHigh", - details::Critical::_property_CriticalAlarmHigh - .data(), - _callback_get_CriticalAlarmHigh, - _callback_set_CriticalAlarmHigh, - vtable::property_::emits_change), - vtable::property("CriticalAlarmLow", - details::Critical::_property_CriticalAlarmLow - .data(), - _callback_get_CriticalAlarmLow, - _callback_set_CriticalAlarmLow, - vtable::property_::emits_change), - vtable::end() -}; - -} // namespace server -} // namespace Threshold -} // namespace Sensor -} // namespace openbmc_project -} // namespace xyz -} // namespace sdbusplus - diff --git a/xyz.openbmc_project.Sensor.Threshold.Warning.cpp b/xyz.openbmc_project.Sensor.Threshold.Warning.cpp deleted file mode 100644 index 4e06927..0000000 --- a/xyz.openbmc_project.Sensor.Threshold.Warning.cpp +++ /dev/null @@ -1,360 +0,0 @@ -#include <algorithm> -#include <sdbusplus/server.hpp> -#include <sdbusplus/exception.hpp> -#include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp> - -namespace sdbusplus -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Sensor -{ -namespace Threshold -{ -namespace server -{ - -Warning::Warning(bus::bus& bus, const char* path) - : _xyz_openbmc_project_Sensor_Threshold_Warning_interface( - bus, path, _interface, _vtable, this) -{ -} - - - -auto Warning::warningHigh() const -> - int64_t -{ - return _warningHigh; -} - -int Warning::_callback_get_WarningHigh( - 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<Warning*>(context); - m.append(convertForMessage(o->warningHigh())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Warning::warningHigh(int64_t value) -> - int64_t -{ - if (_warningHigh != value) - { - _warningHigh = value; - _xyz_openbmc_project_Sensor_Threshold_Warning_interface.property_changed("WarningHigh"); - } - - return _warningHigh; -} - -int Warning::_callback_set_WarningHigh( - 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<Warning*>(context); - - int64_t v{}; - m.read(v); - o->warningHigh(v); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Warning -{ -static const auto _property_WarningHigh = - utility::tuple_to_array(message::types::type_id< - int64_t>()); -} -} -auto Warning::warningLow() const -> - int64_t -{ - return _warningLow; -} - -int Warning::_callback_get_WarningLow( - 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<Warning*>(context); - m.append(convertForMessage(o->warningLow())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Warning::warningLow(int64_t value) -> - int64_t -{ - if (_warningLow != value) - { - _warningLow = value; - _xyz_openbmc_project_Sensor_Threshold_Warning_interface.property_changed("WarningLow"); - } - - return _warningLow; -} - -int Warning::_callback_set_WarningLow( - 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<Warning*>(context); - - int64_t v{}; - m.read(v); - o->warningLow(v); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Warning -{ -static const auto _property_WarningLow = - utility::tuple_to_array(message::types::type_id< - int64_t>()); -} -} -auto Warning::warningAlarmHigh() const -> - bool -{ - return _warningAlarmHigh; -} - -int Warning::_callback_get_WarningAlarmHigh( - 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<Warning*>(context); - m.append(convertForMessage(o->warningAlarmHigh())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Warning::warningAlarmHigh(bool value) -> - bool -{ - if (_warningAlarmHigh != value) - { - _warningAlarmHigh = value; - _xyz_openbmc_project_Sensor_Threshold_Warning_interface.property_changed("WarningAlarmHigh"); - } - - return _warningAlarmHigh; -} - -int Warning::_callback_set_WarningAlarmHigh( - 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<Warning*>(context); - - bool v{}; - m.read(v); - o->warningAlarmHigh(v); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Warning -{ -static const auto _property_WarningAlarmHigh = - utility::tuple_to_array(message::types::type_id< - bool>()); -} -} -auto Warning::warningAlarmLow() const -> - bool -{ - return _warningAlarmLow; -} - -int Warning::_callback_get_WarningAlarmLow( - 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<Warning*>(context); - m.append(convertForMessage(o->warningAlarmLow())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Warning::warningAlarmLow(bool value) -> - bool -{ - if (_warningAlarmLow != value) - { - _warningAlarmLow = value; - _xyz_openbmc_project_Sensor_Threshold_Warning_interface.property_changed("WarningAlarmLow"); - } - - return _warningAlarmLow; -} - -int Warning::_callback_set_WarningAlarmLow( - 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<Warning*>(context); - - bool v{}; - m.read(v); - o->warningAlarmLow(v); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Warning -{ -static const auto _property_WarningAlarmLow = - utility::tuple_to_array(message::types::type_id< - bool>()); -} -} - - -const vtable::vtable_t Warning::_vtable[] = { - vtable::start(), - vtable::property("WarningHigh", - details::Warning::_property_WarningHigh - .data(), - _callback_get_WarningHigh, - _callback_set_WarningHigh, - vtable::property_::emits_change), - vtable::property("WarningLow", - details::Warning::_property_WarningLow - .data(), - _callback_get_WarningLow, - _callback_set_WarningLow, - vtable::property_::emits_change), - vtable::property("WarningAlarmHigh", - details::Warning::_property_WarningAlarmHigh - .data(), - _callback_get_WarningAlarmHigh, - _callback_set_WarningAlarmHigh, - vtable::property_::emits_change), - vtable::property("WarningAlarmLow", - details::Warning::_property_WarningAlarmLow - .data(), - _callback_get_WarningAlarmLow, - _callback_set_WarningAlarmLow, - vtable::property_::emits_change), - vtable::end() -}; - -} // namespace server -} // namespace Threshold -} // namespace Sensor -} // namespace openbmc_project -} // namespace xyz -} // namespace sdbusplus - diff --git a/xyz.openbmc_project.Sensor.Value.cpp b/xyz.openbmc_project.Sensor.Value.cpp deleted file mode 100644 index bb3ef58..0000000 --- a/xyz.openbmc_project.Sensor.Value.cpp +++ /dev/null @@ -1,319 +0,0 @@ -#include <algorithm> -#include <sdbusplus/server.hpp> -#include <sdbusplus/exception.hpp> -#include <xyz/openbmc_project/Sensor/Value/server.hpp> - -namespace sdbusplus -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Sensor -{ -namespace server -{ - -Value::Value(bus::bus& bus, const char* path) - : _xyz_openbmc_project_Sensor_Value_interface( - bus, path, _interface, _vtable, this) -{ -} - - - -auto Value::value() const -> - int64_t -{ - return _value; -} - -int Value::_callback_get_Value( - 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<Value*>(context); - m.append(convertForMessage(o->value())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Value::value(int64_t value) -> - int64_t -{ - if (_value != value) - { - _value = value; - _xyz_openbmc_project_Sensor_Value_interface.property_changed("Value"); - } - - return _value; -} - -int Value::_callback_set_Value( - 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<Value*>(context); - - int64_t v{}; - m.read(v); - o->value(v); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Value -{ -static const auto _property_Value = - utility::tuple_to_array(message::types::type_id< - int64_t>()); -} -} -auto Value::unit() const -> - Unit -{ - return _unit; -} - -int Value::_callback_get_Unit( - 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<Value*>(context); - m.append(convertForMessage(o->unit())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Value::unit(Unit value) -> - Unit -{ - if (_unit != value) - { - _unit = value; - _xyz_openbmc_project_Sensor_Value_interface.property_changed("Unit"); - } - - return _unit; -} - -int Value::_callback_set_Unit( - 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<Value*>(context); - - std::string v{}; - m.read(v); - o->unit(convertUnitFromString(v)); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Value -{ -static const auto _property_Unit = - utility::tuple_to_array(message::types::type_id< - std::string>()); -} -} -auto Value::scale() const -> - int64_t -{ - return _scale; -} - -int Value::_callback_get_Scale( - 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<Value*>(context); - m.append(convertForMessage(o->scale())); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -auto Value::scale(int64_t value) -> - int64_t -{ - if (_scale != value) - { - _scale = value; - _xyz_openbmc_project_Sensor_Value_interface.property_changed("Scale"); - } - - return _scale; -} - -int Value::_callback_set_Scale( - 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<Value*>(context); - - int64_t v{}; - m.read(v); - o->scale(v); - } - catch(sdbusplus::internal_exception_t& e) - { - sd_bus_error_set_const(error, e.name(), e.description()); - return -EINVAL; - } - - return true; -} - -namespace details -{ -namespace Value -{ -static const auto _property_Scale = - utility::tuple_to_array(message::types::type_id< - int64_t>()); -} -} - - -namespace -{ -/** String to enum mapping for Value::Unit */ -static const std::tuple<const char*, Value::Unit> mappingValueUnit[] = - { - std::make_tuple( "xyz.openbmc_project.Sensor.Value.Unit.DegreesC", Value::Unit::DegreesC ), - std::make_tuple( "xyz.openbmc_project.Sensor.Value.Unit.RPMS", Value::Unit::RPMS ), - std::make_tuple( "xyz.openbmc_project.Sensor.Value.Unit.Volts", Value::Unit::Volts ), - std::make_tuple( "xyz.openbmc_project.Sensor.Value.Unit.Meters", Value::Unit::Meters ), - std::make_tuple( "xyz.openbmc_project.Sensor.Value.Unit.Amperes", Value::Unit::Amperes ), - std::make_tuple( "xyz.openbmc_project.Sensor.Value.Unit.Watts", Value::Unit::Watts ), - std::make_tuple( "xyz.openbmc_project.Sensor.Value.Unit.Joules", Value::Unit::Joules ), - }; - -} // anonymous namespace - -auto Value::convertUnitFromString(std::string& s) -> - Unit -{ - auto i = std::find_if( - std::begin(mappingValueUnit), - std::end(mappingValueUnit), - [&s](auto& e){ return 0 == strcmp(s.c_str(), std::get<0>(e)); } ); - if (std::end(mappingValueUnit) == i) - { - throw sdbusplus::exception::InvalidEnumString(); - } - else - { - return std::get<1>(*i); - } -} - -std::string convertForMessage(Value::Unit v) -{ - auto i = std::find_if( - std::begin(mappingValueUnit), - std::end(mappingValueUnit), - [v](auto& e){ return v == std::get<1>(e); }); - return std::get<0>(*i); -} - -const vtable::vtable_t Value::_vtable[] = { - vtable::start(), - vtable::property("Value", - details::Value::_property_Value - .data(), - _callback_get_Value, - _callback_set_Value, - vtable::property_::emits_change), - vtable::property("Unit", - details::Value::_property_Unit - .data(), - _callback_get_Unit, - _callback_set_Unit, - vtable::property_::emits_change), - vtable::property("Scale", - details::Value::_property_Scale - .data(), - _callback_get_Scale, - _callback_set_Scale, - vtable::property_::emits_change), - vtable::end() -}; - -} // namespace server -} // namespace Sensor -} // namespace openbmc_project -} // namespace xyz -} // namespace sdbusplus - diff --git a/xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp b/xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp deleted file mode 100644 index 5135121..0000000 --- a/xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp +++ /dev/null @@ -1,122 +0,0 @@ -#pragma once -#include <tuple> -#include <systemd/sd-bus.h> -#include <sdbusplus/server.hpp> - -namespace sdbusplus -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Sensor -{ -namespace Threshold -{ -namespace server -{ - -class Critical -{ - 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. - */ - Critical() = delete; - Critical(const Critical&) = delete; - Critical& operator=(const Critical&) = delete; - Critical(Critical&&) = default; - Critical& operator=(Critical&&) = default; - virtual ~Critical() = 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. - */ - Critical(bus::bus& bus, const char* path); - - - - - /** Get value of CriticalHigh */ - virtual int64_t criticalHigh() const; - /** Set value of CriticalHigh */ - virtual int64_t criticalHigh(int64_t value); - /** Get value of CriticalLow */ - virtual int64_t criticalLow() const; - /** Set value of CriticalLow */ - virtual int64_t criticalLow(int64_t value); - /** Get value of CriticalAlarmHigh */ - virtual bool criticalAlarmHigh() const; - /** Set value of CriticalAlarmHigh */ - virtual bool criticalAlarmHigh(bool value); - /** Get value of CriticalAlarmLow */ - virtual bool criticalAlarmLow() const; - /** Set value of CriticalAlarmLow */ - virtual bool criticalAlarmLow(bool value); - - - private: - - /** @brief sd-bus callback for get-property 'CriticalHigh' */ - static int _callback_get_CriticalHigh( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'CriticalHigh' */ - static int _callback_set_CriticalHigh( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - /** @brief sd-bus callback for get-property 'CriticalLow' */ - static int _callback_get_CriticalLow( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'CriticalLow' */ - static int _callback_set_CriticalLow( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - /** @brief sd-bus callback for get-property 'CriticalAlarmHigh' */ - static int _callback_get_CriticalAlarmHigh( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'CriticalAlarmHigh' */ - static int _callback_set_CriticalAlarmHigh( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - /** @brief sd-bus callback for get-property 'CriticalAlarmLow' */ - static int _callback_get_CriticalAlarmLow( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'CriticalAlarmLow' */ - static int _callback_set_CriticalAlarmLow( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - - static constexpr auto _interface = "xyz.openbmc_project.Sensor.Threshold.Critical"; - static const vtable::vtable_t _vtable[]; - sdbusplus::server::interface::interface - _xyz_openbmc_project_Sensor_Threshold_Critical_interface; - - int64_t _criticalHigh{}; - int64_t _criticalLow{}; - bool _criticalAlarmHigh{}; - bool _criticalAlarmLow{}; - -}; - - -} // namespace server -} // namespace Threshold -} // namespace Sensor -} // namespace openbmc_project -} // namespace xyz -} // namespace sdbusplus - diff --git a/xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp b/xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp deleted file mode 100644 index e560223..0000000 --- a/xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp +++ /dev/null @@ -1,122 +0,0 @@ -#pragma once -#include <tuple> -#include <systemd/sd-bus.h> -#include <sdbusplus/server.hpp> - -namespace sdbusplus -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Sensor -{ -namespace Threshold -{ -namespace server -{ - -class Warning -{ - 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. - */ - Warning() = delete; - Warning(const Warning&) = delete; - Warning& operator=(const Warning&) = delete; - Warning(Warning&&) = default; - Warning& operator=(Warning&&) = default; - virtual ~Warning() = 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. - */ - Warning(bus::bus& bus, const char* path); - - - - - /** Get value of WarningHigh */ - virtual int64_t warningHigh() const; - /** Set value of WarningHigh */ - virtual int64_t warningHigh(int64_t value); - /** Get value of WarningLow */ - virtual int64_t warningLow() const; - /** Set value of WarningLow */ - virtual int64_t warningLow(int64_t value); - /** Get value of WarningAlarmHigh */ - virtual bool warningAlarmHigh() const; - /** Set value of WarningAlarmHigh */ - virtual bool warningAlarmHigh(bool value); - /** Get value of WarningAlarmLow */ - virtual bool warningAlarmLow() const; - /** Set value of WarningAlarmLow */ - virtual bool warningAlarmLow(bool value); - - - private: - - /** @brief sd-bus callback for get-property 'WarningHigh' */ - static int _callback_get_WarningHigh( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'WarningHigh' */ - static int _callback_set_WarningHigh( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - /** @brief sd-bus callback for get-property 'WarningLow' */ - static int _callback_get_WarningLow( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'WarningLow' */ - static int _callback_set_WarningLow( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - /** @brief sd-bus callback for get-property 'WarningAlarmHigh' */ - static int _callback_get_WarningAlarmHigh( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'WarningAlarmHigh' */ - static int _callback_set_WarningAlarmHigh( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - /** @brief sd-bus callback for get-property 'WarningAlarmLow' */ - static int _callback_get_WarningAlarmLow( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'WarningAlarmLow' */ - static int _callback_set_WarningAlarmLow( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - - static constexpr auto _interface = "xyz.openbmc_project.Sensor.Threshold.Warning"; - static const vtable::vtable_t _vtable[]; - sdbusplus::server::interface::interface - _xyz_openbmc_project_Sensor_Threshold_Warning_interface; - - int64_t _warningHigh{}; - int64_t _warningLow{}; - bool _warningAlarmHigh{}; - bool _warningAlarmLow{}; - -}; - - -} // namespace server -} // namespace Threshold -} // namespace Sensor -} // namespace openbmc_project -} // namespace xyz -} // namespace sdbusplus - diff --git a/xyz/openbmc_project/Sensor/Value/server.hpp b/xyz/openbmc_project/Sensor/Value/server.hpp deleted file mode 100644 index 732ba8d..0000000 --- a/xyz/openbmc_project/Sensor/Value/server.hpp +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include <tuple> -#include <systemd/sd-bus.h> -#include <sdbusplus/server.hpp> - -namespace sdbusplus -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Sensor -{ -namespace server -{ - -class Value -{ - 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. - */ - Value() = delete; - Value(const Value&) = delete; - Value& operator=(const Value&) = delete; - Value(Value&&) = default; - Value& operator=(Value&&) = default; - virtual ~Value() = 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. - */ - Value(bus::bus& bus, const char* path); - - enum class Unit - { - DegreesC, - RPMS, - Volts, - Meters, - Amperes, - Watts, - Joules, - }; - - - - /** Get value of Value */ - virtual int64_t value() const; - /** Set value of Value */ - virtual int64_t value(int64_t value); - /** Get value of Unit */ - virtual Unit unit() const; - /** Set value of Unit */ - virtual Unit unit(Unit value); - /** Get value of Scale */ - virtual int64_t scale() const; - /** Set value of Scale */ - virtual int64_t scale(int64_t value); - - /** @brief Convert a string to an appropriate enum value. - * @param[in] s - The string to convert in the form of - * "xyz.openbmc_project.Sensor.Value.<value name>" - * @return - The enum value. - */ - static Unit convertUnitFromString(std::string& s); - - private: - - /** @brief sd-bus callback for get-property 'Value' */ - static int _callback_get_Value( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'Value' */ - static int _callback_set_Value( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - /** @brief sd-bus callback for get-property 'Unit' */ - static int _callback_get_Unit( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'Unit' */ - static int _callback_set_Unit( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - /** @brief sd-bus callback for get-property 'Scale' */ - static int _callback_get_Scale( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - /** @brief sd-bus callback for set-property 'Scale' */ - static int _callback_set_Scale( - sd_bus*, const char*, const char*, const char*, - sd_bus_message*, void*, sd_bus_error*); - - - static constexpr auto _interface = "xyz.openbmc_project.Sensor.Value"; - static const vtable::vtable_t _vtable[]; - sdbusplus::server::interface::interface - _xyz_openbmc_project_Sensor_Value_interface; - - int64_t _value{}; - Unit _unit{}; - int64_t _scale{}; - -}; - -/* Specialization of sdbusplus::server::bindings::details::convertForMessage - * for enum-type Value::Unit. - * - * This converts from the enum to a constant c-string representing the enum. - * - * @param[in] e - Enum value to convert. - * @return C-string representing the name for the enum value. - */ -std::string convertForMessage(Value::Unit e); - -} // namespace server -} // namespace Sensor -} // namespace openbmc_project -} // namespace xyz -} // namespace sdbusplus - |