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: Ie530f2c63000bbfac7c5fbbc74ebe6bc8c07fb1a
diff --git a/src/activation.cpp b/src/activation.cpp
index 8ea4f25..9112c3f 100644
--- a/src/activation.cpp
+++ b/src/activation.cpp
@@ -60,7 +60,7 @@
return SoftwareActivation::requestedActivation(value);
}
-void Activation::unitStateChange(sdbusplus::message::message& msg)
+void Activation::unitStateChange(sdbusplus::message_t& msg)
{
uint32_t newStateID{};
sdbusplus::message::object_path newStateObjPath;
@@ -95,7 +95,7 @@
bus.call_noreply(method);
return true;
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
log<level::ERR>("Error staring service", entry("ERROR=%s", e.what()));
onUpdateFailed();
@@ -264,7 +264,7 @@
{
bus.call(method);
}
- catch (const sdbusplus::exception::exception& e)
+ catch (const sdbusplus::exception_t& e)
{
log<level::ERR>("Error performing call to Delete object path",
entry("ERROR=%s", e.what()),
diff --git a/src/activation.hpp b/src/activation.hpp
index 622474a..6af99cd 100644
--- a/src/activation.hpp
+++ b/src/activation.hpp
@@ -27,9 +27,9 @@
namespace sdbusRule = sdbusplus::bus::match::rules;
-using ActivationBlocksTransitionInherit = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Software::server::
- ActivationBlocksTransition>;
+using ActivationBlocksTransitionInherit =
+ sdbusplus::server::object_t<sdbusplus::xyz::openbmc_project::Software::
+ server::ActivationBlocksTransition>;
/** @class ActivationBlocksTransition
* @brief OpenBMC ActivationBlocksTransition implementation.
@@ -44,8 +44,7 @@
* @param[in] bus - The Dbus bus object
* @param[in] path - The Dbus object path
*/
- ActivationBlocksTransition(sdbusplus::bus::bus& bus,
- const std::string& path) :
+ ActivationBlocksTransition(sdbusplus::bus_t& bus, const std::string& path) :
ActivationBlocksTransitionInherit(bus, path.c_str(),
action::emit_interface_added),
bus(bus)
@@ -59,7 +58,7 @@
}
private:
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief Enables a Guard that blocks any BMC reboot commands */
void enableRebootGuard();
@@ -68,7 +67,7 @@
void disableRebootGuard();
};
-using ActivationProgressInherit = sdbusplus::server::object::object<
+using ActivationProgressInherit = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Software::server::ActivationProgress>;
class ActivationProgress : public ActivationProgressInherit
@@ -79,7 +78,7 @@
* @param[in] bus - The Dbus bus object
* @param[in] path - The Dbus object path
*/
- ActivationProgress(sdbusplus::bus::bus& bus, const std::string& path) :
+ ActivationProgress(sdbusplus::bus_t& bus, const std::string& path) :
ActivationProgressInherit(bus, path.c_str(),
action::emit_interface_added)
{
@@ -87,7 +86,7 @@
}
};
-using ActivationInherit = sdbusplus::server::object::object<
+using ActivationInherit = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Software::server::ExtendedVersion,
sdbusplus::xyz::openbmc_project::Software::server::Activation,
sdbusplus::xyz::openbmc_project::Association::server::Definitions,
@@ -114,7 +113,7 @@
* @param[in] assocs - Association objects
* @param[in] filePath - The image filesystem path
*/
- Activation(sdbusplus::bus::bus& bus, const std::string& objPath,
+ Activation(sdbusplus::bus_t& bus, const std::string& objPath,
const std::string& versionId, const std::string& extVersion,
Status activationStatus, const AssociationList& assocs,
const std::string& filePath,
@@ -188,7 +187,7 @@
* @param[in] msg - Data associated with subscribed signal
*
*/
- void unitStateChange(sdbusplus::message::message& msg);
+ void unitStateChange(sdbusplus::message_t& msg);
/**
* @brief Delete the version from Image Manager and the
@@ -237,7 +236,7 @@
std::string getUpdateService(const std::string& psuInventoryPath);
/** @brief Persistent sdbusplus DBus bus connection */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief Persistent DBus object path */
std::string objPath;
diff --git a/src/item_updater.cpp b/src/item_updater.cpp
index 5481b06..1b38e13 100644
--- a/src/item_updater.cpp
+++ b/src/item_updater.cpp
@@ -29,7 +29,7 @@
using SVersion = server::Version;
using VersionPurpose = SVersion::VersionPurpose;
-void ItemUpdater::createActivation(sdbusplus::message::message& m)
+void ItemUpdater::createActivation(sdbusplus::message_t& m)
{
sdbusplus::message::object_path objPath;
std::map<std::string, std::map<std::string, std::variant<std::string>>>
@@ -306,7 +306,7 @@
return version;
}
-void ItemUpdater::onPsuInventoryChangedMsg(sdbusplus::message::message& msg)
+void ItemUpdater::onPsuInventoryChangedMsg(sdbusplus::message_t& msg)
{
using Interface = std::string;
Interface interface;
diff --git a/src/item_updater.hpp b/src/item_updater.hpp
index 94d97f5..0f998c8 100644
--- a/src/item_updater.hpp
+++ b/src/item_updater.hpp
@@ -25,7 +25,7 @@
class Version;
-using ItemUpdaterInherit = sdbusplus::server::object::object<
+using ItemUpdaterInherit = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Association::server::Definitions>;
namespace MatchRules = sdbusplus::bus::match::rules;
@@ -47,7 +47,7 @@
* @param[in] bus - The D-Bus bus object
* @param[in] path - The D-Bus path
*/
- ItemUpdater(sdbusplus::bus::bus& bus, const std::string& path) :
+ ItemUpdater(sdbusplus::bus_t& bus, const std::string& path) :
ItemUpdaterInherit(bus, path.c_str()), bus(bus),
versionMatch(bus,
MatchRules::interfacesAdded() +
@@ -107,7 +107,7 @@
*
* @param[in] msg - Data associated with subscribed signal
*/
- void createActivation(sdbusplus::message::message& msg);
+ void createActivation(sdbusplus::message_t& msg);
using Properties =
std::map<std::string, utils::UtilsInterface::PropertyType>;
@@ -117,7 +117,7 @@
*
* @param[in] msg - Data associated with subscribed signal
*/
- void onPsuInventoryChangedMsg(sdbusplus::message::message& msg);
+ void onPsuInventoryChangedMsg(sdbusplus::message_t& msg);
/** @brief Callback function for PSU inventory match.
* @details Update an Activation D-Bus object for PSU inventory.
@@ -178,7 +178,7 @@
void invokeActivation(const std::unique_ptr<Activation>& activation);
/** @brief Persistent sdbusplus D-Bus bus connection. */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief Persistent map of Activation D-Bus objects and their
* version id */
diff --git a/src/main.cpp b/src/main.cpp
index fe9062e..b15923a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -12,7 +12,7 @@
auto bus = sdbusplus::bus::new_default();
// Add sdbusplus ObjectManager.
- sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH);
+ sdbusplus::server::manager_t objManager(bus, SOFTWARE_OBJPATH);
phosphor::software::updater::ItemUpdater updater(bus, SOFTWARE_OBJPATH);
diff --git a/src/utils.cpp b/src/utils.cpp
index d4b5291..0626543 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -60,8 +60,7 @@
return utils;
}
-std::vector<std::string>
- Utils::getPSUInventoryPath(sdbusplus::bus::bus& bus) const
+std::vector<std::string> Utils::getPSUInventoryPath(sdbusplus::bus_t& bus) const
{
std::vector<std::string> paths;
auto method = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
@@ -75,7 +74,7 @@
return paths;
}
-std::string Utils::getService(sdbusplus::bus::bus& bus, const char* path,
+std::string Utils::getService(sdbusplus::bus_t& bus, const char* path,
const char* interface) const
{
auto services = getServices(bus, path, interface);
@@ -86,7 +85,7 @@
return services[0];
}
-std::vector<std::string> Utils::getServices(sdbusplus::bus::bus& bus,
+std::vector<std::string> Utils::getServices(sdbusplus::bus_t& bus,
const char* path,
const char* interface) const
{
@@ -113,7 +112,7 @@
}
return ret;
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
log<level::ERR>("GetObject call failed", entry("PATH=%s", path),
entry("INTERFACE=%s", interface));
@@ -181,7 +180,7 @@
}) != assocs.end();
}
-any Utils::getPropertyImpl(sdbusplus::bus::bus& bus, const char* service,
+any Utils::getPropertyImpl(sdbusplus::bus_t& bus, const char* service,
const char* path, const char* interface,
const char* propertyName) const
{
@@ -195,7 +194,7 @@
reply.read(value);
return any(value);
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
log<level::ERR>("GetProperty call failed", entry("PATH=%s", path),
entry("INTERFACE=%s", interface),
diff --git a/src/utils.hpp b/src/utils.hpp
index 5744e4a..13c7b62 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -25,7 +25,7 @@
/**
* @brief Get PSU inventory object path from DBus
*/
-std::vector<std::string> getPSUInventoryPath(sdbusplus::bus::bus& bus);
+std::vector<std::string> getPSUInventoryPath(sdbusplus::bus_t& bus);
/** @brief Get service name from object path and interface
*
@@ -35,7 +35,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 Get all the service names from object path and interface
@@ -46,7 +46,7 @@
*
* @return The name of the services
*/
-std::vector<std::string> getServices(sdbusplus::bus::bus& bus, const char* path,
+std::vector<std::string> getServices(sdbusplus::bus_t& bus, const char* path,
const char* interface);
/** @brief The template function to get property from the requested dbus path
@@ -60,7 +60,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);
/**
@@ -113,13 +113,13 @@
virtual ~UtilsInterface() = default;
virtual std::vector<std::string>
- getPSUInventoryPath(sdbusplus::bus::bus& bus) const = 0;
+ getPSUInventoryPath(sdbusplus::bus_t& bus) const = 0;
- virtual std::string getService(sdbusplus::bus::bus& bus, const char* path,
+ virtual std::string getService(sdbusplus::bus_t& bus, const char* path,
const char* interface) const = 0;
virtual std::vector<std::string>
- getServices(sdbusplus::bus::bus& bus, const char* path,
+ getServices(sdbusplus::bus_t& bus, const char* path,
const char* interface) const = 0;
virtual std::string getVersionId(const std::string& version) const = 0;
@@ -132,14 +132,13 @@
virtual bool isAssociated(const std::string& psuInventoryPath,
const AssociationList& assocs) const = 0;
- virtual any getPropertyImpl(sdbusplus::bus::bus& bus, const char* service,
+ virtual any getPropertyImpl(sdbusplus::bus_t& bus, const char* service,
const char* path, const char* interface,
const char* propertyName) const = 0;
template <typename T>
- T getProperty(sdbusplus::bus::bus& bus, const char* service,
- const char* path, const char* interface,
- const char* propertyName) const
+ T getProperty(sdbusplus::bus_t& bus, const char* service, const char* path,
+ const char* interface, const char* propertyName) const
{
any result =
getPropertyImpl(bus, service, path, interface, propertyName);
@@ -152,12 +151,12 @@
{
public:
std::vector<std::string>
- getPSUInventoryPath(sdbusplus::bus::bus& bus) const override;
+ getPSUInventoryPath(sdbusplus::bus_t& bus) const override;
- std::string getService(sdbusplus::bus::bus& bus, const char* path,
+ std::string getService(sdbusplus::bus_t& bus, const char* path,
const char* interface) const override;
- std::vector<std::string> getServices(sdbusplus::bus::bus& bus,
+ std::vector<std::string> getServices(sdbusplus::bus_t& bus,
const char* path,
const char* interface) const override;
@@ -171,25 +170,24 @@
bool isAssociated(const std::string& psuInventoryPath,
const AssociationList& assocs) const override;
- any getPropertyImpl(sdbusplus::bus::bus& bus, const char* service,
+ any getPropertyImpl(sdbusplus::bus_t& bus, const char* service,
const char* path, const char* interface,
const char* propertyName) const override;
};
-inline std::string getService(sdbusplus::bus::bus& bus, const char* path,
+inline std::string getService(sdbusplus::bus_t& bus, const char* path,
const char* interface)
{
return getUtils().getService(bus, path, interface);
}
-inline std::vector<std::string> getServices(sdbusplus::bus::bus& bus,
- const char* path,
- const char* interface)
+inline std::vector<std::string>
+ getServices(sdbusplus::bus_t& bus, const char* path, const char* interface)
{
return getUtils().getServices(bus, path, interface);
}
-inline std::vector<std::string> getPSUInventoryPath(sdbusplus::bus::bus& bus)
+inline std::vector<std::string> getPSUInventoryPath(sdbusplus::bus_t& bus)
{
return getUtils().getPSUInventoryPath(bus);
}
@@ -216,7 +214,7 @@
}
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)
{
return getUtils().getProperty<T>(bus, service, path, interface,
diff --git a/src/version.hpp b/src/version.hpp
index 4c4dfde..37c7e38 100644
--- a/src/version.hpp
+++ b/src/version.hpp
@@ -15,9 +15,9 @@
using eraseFunc = std::function<void(std::string)>;
-using VersionInherit = sdbusplus::server::object::object<
+using VersionInherit = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Software::server::Version>;
-using DeleteInherit = sdbusplus::server::object::object<
+using DeleteInherit = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Object::server::Delete>;
namespace sdbusRule = sdbusplus::bus::match::rules;
@@ -38,8 +38,7 @@
* @param[in] path - The D-Bus object path
* @param[in] version - The Version object.
*/
- Delete(sdbusplus::bus::bus& bus, const std::string& path,
- Version& version) :
+ Delete(sdbusplus::bus_t& bus, const std::string& path, Version& version) :
DeleteInherit(bus, path.c_str(), action::emit_interface_added),
version(version)
{
@@ -74,7 +73,7 @@
* @param[in] versionPurpose - The version purpose
* @param[in] callback - The eraseFunc callback
*/
- Version(sdbusplus::bus::bus& bus, const std::string& objPath,
+ Version(sdbusplus::bus_t& bus, const std::string& objPath,
const std::string& versionId, const std::string& versionString,
VersionPurpose versionPurpose, eraseFunc callback) :
VersionInherit(bus, (objPath).c_str(),
@@ -146,7 +145,7 @@
private:
/** @brief Persistent sdbusplus DBus bus connection */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief Persistent DBus object path */
std::string objPath;
diff --git a/test/mocked_utils.hpp b/test/mocked_utils.hpp
index 71aac99..71a4f77 100644
--- a/test/mocked_utils.hpp
+++ b/test/mocked_utils.hpp
@@ -11,14 +11,14 @@
virtual ~MockedUtils() = default;
MOCK_CONST_METHOD1(getPSUInventoryPath,
- std::vector<std::string>(sdbusplus::bus::bus& bus));
+ std::vector<std::string>(sdbusplus::bus_t& bus));
MOCK_CONST_METHOD3(getService,
- std::string(sdbusplus::bus::bus& bus, const char* path,
+ std::string(sdbusplus::bus_t& bus, const char* path,
const char* interface));
MOCK_CONST_METHOD3(getServices,
- std::vector<std::string>(sdbusplus::bus::bus& bus,
+ std::vector<std::string>(sdbusplus::bus_t& bus,
const char* path,
const char* interface));
@@ -34,7 +34,7 @@
const AssociationList& assocs));
MOCK_CONST_METHOD5(getPropertyImpl,
- any(sdbusplus::bus::bus& bus, const char* service,
+ any(sdbusplus::bus_t& bus, const char* service,
const char* path, const char* interface,
const char* propertyName));
};
diff --git a/test/test_activation.cpp b/test/test_activation.cpp
index 8da5b2d..2e93672 100644
--- a/test/test_activation.cpp
+++ b/test/test_activation.cpp
@@ -60,7 +60,7 @@
}
sdbusplus::SdBusMock sdbusMock;
- sdbusplus::bus::bus mockedBus = sdbusplus::get_mocked_new(&sdbusMock);
+ sdbusplus::bus_t mockedBus = sdbusplus::get_mocked_new(&sdbusMock);
const utils::MockedUtils& mockedUtils;
MockedAssociationInterface mockedAssociationInterface;
MockedActivationListener mockedActivationListener;
diff --git a/test/test_item_updater.cpp b/test/test_item_updater.cpp
index dab6a57..2fe1c86 100644
--- a/test/test_item_updater.cpp
+++ b/test/test_item_updater.cpp
@@ -59,7 +59,7 @@
static constexpr auto dBusPath = SOFTWARE_OBJPATH;
sdbusplus::SdBusMock sdbusMock;
- sdbusplus::bus::bus mockedBus = sdbusplus::get_mocked_new(&sdbusMock);
+ sdbusplus::bus_t mockedBus = sdbusplus::get_mocked_new(&sdbusMock);
const utils::MockedUtils& mockedUtils;
std::unique_ptr<ItemUpdater> itemUpdater;
Properties propAdded{{PRESENT, PropertyType(true)}};
diff --git a/test/test_utils.cpp b/test/test_utils.cpp
index afcbb47..668803e 100644
--- a/test/test_utils.cpp
+++ b/test/test_utils.cpp
@@ -23,7 +23,7 @@
EXPECT_CALL(sdbusMock, sd_bus_message_ref(IsNull()))
.WillOnce(Return(nullptr));
- sdbusplus::message::message msg(nullptr, &sdbusMock);
+ sdbusplus::message_t msg(nullptr, &sdbusMock);
const char* path0 = "/com/example/chassis/powersupply0";
const char* path1 = "/com/example/chassis/powersupply1";