sdbusplus: use shorter type aliases
The sdbusplus headers provide shortened aliases for many types.
Switch to using them to provide better code clarity and shorter
lines. Possible replacements are for:
* bus_t
* exception_t
* manager_t
* match_t
* message_t
* object_t
* slot_t
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I91502c85799b7d3be22b7d05659ff26bea08c32b
diff --git a/inc/button_factory.hpp b/inc/button_factory.hpp
index fc75f4f..69e05a9 100644
--- a/inc/button_factory.hpp
+++ b/inc/button_factory.hpp
@@ -8,7 +8,7 @@
#include <unordered_map>
using buttonIfCreatorMethod = std::function<std::unique_ptr<ButtonIface>(
- sdbusplus::bus::bus& bus, EventPtr& event, buttonConfig& buttonCfg)>;
+ sdbusplus::bus_t& bus, EventPtr& event, buttonConfig& buttonCfg)>;
/**
* @brief This is abstract factory for the creating phosphor buttons objects
@@ -36,7 +36,7 @@
void addToRegistry()
{
buttonIfaceRegistry[std::string(T::getFormFactorName())] =
- [](sdbusplus::bus::bus& bus, EventPtr& event,
+ [](sdbusplus::bus_t& bus, EventPtr& event,
buttonConfig& buttonCfg) {
return std::make_unique<T>(bus, T::getDbusObjectPath(), event,
buttonCfg);
@@ -47,7 +47,7 @@
* corresponding to the button formfactor name provided
*/
std::unique_ptr<ButtonIface> createInstance(const std::string& name,
- sdbusplus::bus::bus& bus,
+ sdbusplus::bus_t& bus,
EventPtr& event,
buttonConfig& buttonCfg)
{
diff --git a/inc/button_handler.hpp b/inc/button_handler.hpp
index 8d1b319..5723cf7 100644
--- a/inc/button_handler.hpp
+++ b/inc/button_handler.hpp
@@ -41,7 +41,7 @@
*
* @param[in] bus - sdbusplus connection object
*/
- explicit Handler(sdbusplus::bus::bus& bus);
+ explicit Handler(sdbusplus::bus_t& bus);
private:
/**
@@ -52,7 +52,7 @@
*
* @param[in] msg - sdbusplus message from signal
*/
- void powerReleased(sdbusplus::message::message& msg);
+ void powerReleased(sdbusplus::message_t& msg);
/**
* @brief The handler for a long power button press
@@ -62,7 +62,7 @@
*
* @param[in] msg - sdbusplus message from signal
*/
- void longPowerPressed(sdbusplus::message::message& msg);
+ void longPowerPressed(sdbusplus::message_t& msg);
/**
* @brief The handler for an ID button press
@@ -71,7 +71,7 @@
*
* @param[in] msg - sdbusplus message from signal
*/
- void idReleased(sdbusplus::message::message& msg);
+ void idReleased(sdbusplus::message_t& msg);
/**
* @brief The handler for a reset button press
@@ -80,7 +80,7 @@
*
* @param[in] msg - sdbusplus message from signal
*/
- void resetReleased(sdbusplus::message::message& msg);
+ void resetReleased(sdbusplus::message_t& msg);
/**
* @brief Checks if system is powered on
@@ -125,7 +125,7 @@
/**
* @brief sdbusplus connection object
*/
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/**
* @brief Matches on the power button released signal
diff --git a/inc/button_interface.hpp b/inc/button_interface.hpp
index 9d85e8e..f05beb9 100644
--- a/inc/button_interface.hpp
+++ b/inc/button_interface.hpp
@@ -10,8 +10,7 @@
class ButtonIface
{
public:
- ButtonIface(sdbusplus::bus::bus& bus, EventPtr& event,
- buttonConfig& buttonCfg,
+ ButtonIface(sdbusplus::bus_t& bus, EventPtr& event, buttonConfig& buttonCfg,
sd_event_io_handler_t handler = ButtonIface::EventHandler) :
bus(bus),
event(event), config(buttonCfg), callbackHandler(handler)
@@ -108,7 +107,7 @@
}
}
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
EventPtr& event;
buttonConfig config;
sd_event_io_handler_t callbackHandler;
diff --git a/inc/hostSelector_switch.hpp b/inc/hostSelector_switch.hpp
index cb9eab7..dc98739 100644
--- a/inc/hostSelector_switch.hpp
+++ b/inc/hostSelector_switch.hpp
@@ -33,7 +33,7 @@
public ButtonIface
{
public:
- HostSelector(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
+ HostSelector(sdbusplus::bus_t& bus, const char* path, EventPtr& event,
buttonConfig& buttonCfg) :
sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Chassis::
Buttons::server::HostSelector>(
diff --git a/inc/id_button.hpp b/inc/id_button.hpp
index 41a2059..e48843b 100644
--- a/inc/id_button.hpp
+++ b/inc/id_button.hpp
@@ -31,14 +31,14 @@
static constexpr std::string_view ID_BUTTON = "ID_BTN";
class IDButton :
- public sdbusplus::server::object::object<
+ public sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>,
public ButtonIface
{
public:
- IDButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
+ IDButton(sdbusplus::bus_t& bus, const char* path, EventPtr& event,
buttonConfig& buttonCfg) :
- sdbusplus::server::object::object<
+ sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>(
bus, path),
ButtonIface(bus, event, buttonCfg)
diff --git a/inc/power_button.hpp b/inc/power_button.hpp
index 73336ac..90076f3 100644
--- a/inc/power_button.hpp
+++ b/inc/power_button.hpp
@@ -33,14 +33,14 @@
static constexpr std::string_view POWER_BUTTON = "POWER_BUTTON";
class PowerButton :
- public sdbusplus::server::object::object<
+ public sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Power>,
public ButtonIface
{
public:
- PowerButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
+ PowerButton(sdbusplus::bus_t& bus, const char* path, EventPtr& event,
buttonConfig& buttonCfg) :
- sdbusplus::server::object::object<
+ sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Power>(
bus, path),
ButtonIface(bus, event, buttonCfg)
diff --git a/inc/reset_button.hpp b/inc/reset_button.hpp
index fea82b6..925bed1 100644
--- a/inc/reset_button.hpp
+++ b/inc/reset_button.hpp
@@ -31,14 +31,14 @@
static constexpr std::string_view RESET_BUTTON = "RESET_BUTTON";
class ResetButton :
- public sdbusplus::server::object::object<
+ public sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>,
public ButtonIface
{
public:
- ResetButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
+ ResetButton(sdbusplus::bus_t& bus, const char* path, EventPtr& event,
buttonConfig& buttonCfg) :
- sdbusplus::server::object::object<
+ sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>(
bus, path),
ButtonIface(bus, event, buttonCfg)
diff --git a/src/button_handler.cpp b/src/button_handler.cpp
index 3751df5..72d2f65 100644
--- a/src/button_handler.cpp
+++ b/src/button_handler.cpp
@@ -32,7 +32,7 @@
constexpr auto mapperService = "xyz.openbmc_project.ObjectMapper";
constexpr auto BMC_POSITION = 0;
-Handler::Handler(sdbusplus::bus::bus& bus) : bus(bus)
+Handler::Handler(sdbusplus::bus_t& bus) : bus(bus)
{
try
{
@@ -56,7 +56,7 @@
std::placeholders::_1));
}
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
// The button wasn't implemented
}
@@ -75,7 +75,7 @@
std::placeholders::_1));
}
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
// The button wasn't implemented
}
@@ -94,7 +94,7 @@
std::placeholders::_1));
}
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
// The button wasn't implemented
}
@@ -140,7 +140,7 @@
auto position = std::get<size_t>(HSPositionVariant);
return position;
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error("Error reading Host selector Position: {ERROR}", "ERROR", e);
throw;
@@ -271,45 +271,45 @@
method.append(dbusIfaceName, transitionName, transition);
bus.call(method);
}
-void Handler::powerReleased(sdbusplus::message::message& /* msg */)
+void Handler::powerReleased(sdbusplus::message_t& /* msg */)
{
try
{
handlePowerEvent(PowerEvent::powerReleased);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error("Failed power state change on a power button press: {ERROR}",
"ERROR", e);
}
}
-void Handler::longPowerPressed(sdbusplus::message::message& /* msg */)
+void Handler::longPowerPressed(sdbusplus::message_t& /* msg */)
{
try
{
handlePowerEvent(PowerEvent::longPowerPressed);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error("Failed powering off on long power button press: {ERROR}",
"ERROR", e);
}
}
-void Handler::resetReleased(sdbusplus::message::message& /* msg */)
+void Handler::resetReleased(sdbusplus::message_t& /* msg */)
{
try
{
handlePowerEvent(PowerEvent::resetReleased);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error("Failed power state change on a reset button press: {ERROR}",
"ERROR", e);
}
}
-void Handler::idReleased(sdbusplus::message::message& /* msg */)
+void Handler::idReleased(sdbusplus::message_t& /* msg */)
{
std::string groupPath{ledGroupBasePath};
groupPath += ID_LED_GROUP;
@@ -345,7 +345,7 @@
method.append(ledGroupIface, "Asserted", state);
result = bus.call(method);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
lg2::error("Error toggling ID LED group on ID button press: {ERROR}",
"ERROR", e);
diff --git a/src/main.cpp b/src/main.cpp
index 5b5341d..90c189d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -43,8 +43,8 @@
EventPtr eventP{event};
event = nullptr;
- sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
- sdbusplus::server::manager::manager objManager{
+ sdbusplus::bus_t bus = sdbusplus::bus::new_default();
+ sdbusplus::server::manager_t objManager{
bus, "/xyz/openbmc_project/Chassis/Buttons"};
bus.request_name("xyz.openbmc_project.Chassis.Buttons");