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: I9cedddf4dc9b224ecbc2f68e6b00c0ab1885a826
diff --git a/bmc_epoch.cpp b/bmc_epoch.cpp
index 92f31d8..7135768 100644
--- a/bmc_epoch.cpp
+++ b/bmc_epoch.cpp
@@ -26,7 +26,7 @@
namespace server = sdbusplus::xyz::openbmc_project::Time::server;
using namespace phosphor::logging;
-BmcEpoch::BmcEpoch(sdbusplus::bus::bus& bus, const char* objPath) :
+BmcEpoch::BmcEpoch(sdbusplus::bus_t& bus, const char* objPath) :
EpochBase(bus, objPath)
{
initialize();
diff --git a/bmc_epoch.hpp b/bmc_epoch.hpp
index b47a39b..d8abe2f 100644
--- a/bmc_epoch.hpp
+++ b/bmc_epoch.hpp
@@ -20,7 +20,7 @@
{
public:
friend class TestBmcEpoch;
- BmcEpoch(sdbusplus::bus::bus& bus, const char* objPath);
+ BmcEpoch(sdbusplus::bus_t& bus, const char* objPath);
~BmcEpoch();
/**
diff --git a/epoch_base.cpp b/epoch_base.cpp
index a336573..17be2c6 100644
--- a/epoch_base.cpp
+++ b/epoch_base.cpp
@@ -24,8 +24,8 @@
using namespace phosphor::logging;
using FailedError = sdbusplus::xyz::openbmc_project::Time::Error::Failed;
-EpochBase::EpochBase(sdbusplus::bus::bus& bus, const char* objPath) :
- sdbusplus::server::object::object<EpochTime>(bus, objPath), bus(bus)
+EpochBase::EpochBase(sdbusplus::bus_t& bus, const char* objPath) :
+ sdbusplus::server::object_t<EpochTime>(bus, objPath), bus(bus)
{}
void EpochBase::onModeChanged(Mode mode)
@@ -46,7 +46,7 @@
{
bus.call_noreply(method);
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
lg2::error("Error in setting system time: {ERROR}", "ERROR", ex);
using namespace xyz::openbmc_project::Time;
diff --git a/epoch_base.hpp b/epoch_base.hpp
index 89a7b85..ed761f8 100644
--- a/epoch_base.hpp
+++ b/epoch_base.hpp
@@ -20,21 +20,21 @@
* DBus API for epoch time.
*/
class EpochBase :
- public sdbusplus::server::object::object<
+ public sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Time::server::EpochTime>,
public PropertyChangeListner
{
public:
friend class TestEpochBase;
- EpochBase(sdbusplus::bus::bus& bus, const char* objPath);
+ EpochBase(sdbusplus::bus_t& bus, const char* objPath);
/** @brief Notified on time mode changed */
void onModeChanged(Mode mode) override;
protected:
/** @brief Persistent sdbusplus DBus connection */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief The current time mode */
Mode timeMode = DEFAULT_TIME_MODE;
diff --git a/main.cpp b/main.cpp
index 1927f4e..b2d1d8a 100644
--- a/main.cpp
+++ b/main.cpp
@@ -22,7 +22,7 @@
bus.attach_event(sdEvent.get(), SD_EVENT_PRIORITY_NORMAL);
// Add sdbusplus ObjectManager
- sdbusplus::server::manager::manager bmcEpochObjManager(bus, OBJPATH_BMC);
+ sdbusplus::server::manager_t bmcEpochObjManager(bus, OBJPATH_BMC);
phosphor::time::BmcEpoch bmc(bus, OBJPATH_BMC);
phosphor::time::Manager manager(bus);
diff --git a/manager.cpp b/manager.cpp
index ceaed7e..660102f 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -27,7 +27,7 @@
using namespace phosphor::logging;
-Manager::Manager(sdbusplus::bus::bus& bus) : bus(bus), settings(bus)
+Manager::Manager(sdbusplus::bus_t& bus) : bus(bus), settings(bus)
{
using namespace sdbusplus::bus::match::rules;
settingsMatches.emplace_back(
@@ -52,7 +52,7 @@
onTimeModeChanged(value);
}
-int Manager::onSettingsChanged(sdbusplus::message::message& msg)
+int Manager::onSettingsChanged(sdbusplus::message_t& msg)
{
using Interface = std::string;
using Property = std::string;
@@ -86,7 +86,7 @@
bus.call_noreply(method);
lg2::info("Updated NTP setting: {ENABLED}", "ENABLED", isNtp);
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
lg2::error("Failed to update NTP setting: {ERROR}", "ERROR", ex);
}
diff --git a/manager.hpp b/manager.hpp
index 8ccea4a..03229fb 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -27,7 +27,7 @@
public:
friend class TestManager;
- explicit Manager(sdbusplus::bus::bus& bus);
+ explicit Manager(sdbusplus::bus_t& bus);
Manager(const Manager&) = delete;
Manager& operator=(const Manager&) = delete;
Manager(Manager&&) = delete;
@@ -36,10 +36,10 @@
private:
/** @brief Persistent sdbusplus DBus connection */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief The match of settings property change */
- std::vector<sdbusplus::bus::match::match> settingsMatches;
+ std::vector<sdbusplus::bus::match_t> settingsMatches;
/** @brief Settings objects of intereset */
settings::Objects settings;
@@ -81,7 +81,7 @@
*
* @return 0 on success, < 0 on failure.
*/
- int onSettingsChanged(sdbusplus::message::message& msg);
+ int onSettingsChanged(sdbusplus::message_t& msg);
/** @brief Notified on settings property changed
*
diff --git a/settings.cpp b/settings.cpp
index 1ac0d9e..b8b3a0d 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -15,7 +15,7 @@
constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
-Objects::Objects(sdbusplus::bus::bus& bus) : bus(bus)
+Objects::Objects(sdbusplus::bus_t& bus) : bus(bus)
{
std::vector<std::string> settingsIntfs = {timeSyncIntf};
auto depth = 0;
@@ -36,7 +36,7 @@
auto response = bus.call(mapperCall);
response.read(result);
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
lg2::error("Failed to invoke GetSubTree method: {ERROR}", "ERROR", ex);
}
@@ -77,7 +77,7 @@
auto response = bus.call(mapperCall);
response.read(result);
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
lg2::error("Error in mapper GetObject: {ERROR}", "ERROR", ex);
}
diff --git a/settings.hpp b/settings.hpp
index 61eba03..5042c9e 100644
--- a/settings.hpp
+++ b/settings.hpp
@@ -25,7 +25,7 @@
* @param[in] bus - The D-bus bus object
*/
Objects() = delete;
- explicit Objects(sdbusplus::bus::bus&);
+ explicit Objects(sdbusplus::bus_t&);
Objects(const Objects&) = delete;
Objects& operator=(const Objects&) = delete;
Objects(Objects&&) = default;
@@ -47,7 +47,7 @@
Path timeSyncMethod;
private:
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
};
} // namespace settings
diff --git a/test/TestBmcEpoch.cpp b/test/TestBmcEpoch.cpp
index 651e019..a5fdb33 100644
--- a/test/TestBmcEpoch.cpp
+++ b/test/TestBmcEpoch.cpp
@@ -19,7 +19,7 @@
class TestBmcEpoch : public testing::Test
{
public:
- sdbusplus::bus::bus bus;
+ sdbusplus::bus_t bus;
sd_event* event;
std::unique_ptr<BmcEpoch> bmcEpoch;
diff --git a/test/TestManager.cpp b/test/TestManager.cpp
index db36b42..b879d3a 100644
--- a/test/TestManager.cpp
+++ b/test/TestManager.cpp
@@ -16,7 +16,7 @@
class TestManager : public testing::Test
{
public:
- sdbusplus::bus::bus bus;
+ sdbusplus::bus_t bus;
Manager manager;
TestManager() : bus(sdbusplus::bus::new_default()), manager(bus)
diff --git a/utils.cpp b/utils.cpp
index 95edd99..9bf83cb 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -15,7 +15,7 @@
namespace utils
{
-std::string getService(sdbusplus::bus::bus& bus, const char* path,
+std::string getService(sdbusplus::bus_t& bus, const char* path,
const char* interface)
{
auto mapper = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
@@ -37,7 +37,7 @@
return mapperResponse[0].first;
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
lg2::error(
"Mapper call failed: path:{PATH}, interface:{INTF}, error:{ERROR}",
diff --git a/utils.hpp b/utils.hpp
index 9639cbf..6f2fc62 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -23,7 +23,7 @@
* @return The value of the property
*/
template <typename T>
-T getProperty(sdbusplus::bus::bus& bus, const char* service, const char* path,
+T getProperty(sdbusplus::bus_t& bus, const char* service, const char* path,
const char* interface, const char* propertyName)
{
auto method = bus.new_method_call(service, path,
@@ -36,7 +36,7 @@
reply.read(value);
return std::get<T>(value);
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
lg2::error("GetProperty call failed, path:{PATH}, interface:{INTF}, "
"propertyName:{NAME}, error:{ERROR}",
@@ -54,7 +54,7 @@
*
* @return The name of the service
*/
-std::string getService(sdbusplus::bus::bus& bus, const char* path,
+std::string getService(sdbusplus::bus_t& bus, const char* path,
const char* interface);
/** @brief Convert a string to enum Mode