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: Ic63a70d32f4683e0bd92b625cc36c836aa8395a8
diff --git a/association_manager.cpp b/association_manager.cpp
index ade689d..1b28ace 100644
--- a/association_manager.cpp
+++ b/association_manager.cpp
@@ -15,7 +15,7 @@
{
namespace fs = std::filesystem;
-Manager::Manager(sdbusplus::bus::bus& bus, const std::string& jsonPath) :
+Manager::Manager(sdbusplus::bus_t& bus, const std::string& jsonPath) :
_bus(bus), _jsonFile(jsonPath)
{
// If there aren't any conditional associations files, look for
diff --git a/association_manager.hpp b/association_manager.hpp
index eda7e05..8756f7e 100644
--- a/association_manager.hpp
+++ b/association_manager.hpp
@@ -30,7 +30,7 @@
using AssociationMap = std::map<std::string, EndpointsEntry>;
-using AssociationObject = sdbusplus::server::object::object<
+using AssociationObject = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Association::server::Definitions>;
using AssociationIfaceMap =
@@ -76,14 +76,14 @@
* @param[in] bus - sdbusplus object
* @param[in] jsonPath - path to the JSON File that contains associations
*/
- Manager(sdbusplus::bus::bus& bus, const std::string& jsonPath);
+ Manager(sdbusplus::bus_t& bus, const std::string& jsonPath);
/**
* @brief Constructor
*
* @param[in] bus - sdbusplus object
*/
- explicit Manager(sdbusplus::bus::bus& bus) :
+ explicit Manager(sdbusplus::bus_t& bus) :
Manager(bus, ASSOCIATIONS_FILE_PATH)
{}
@@ -214,7 +214,7 @@
/**
* @brief The sdbusplus bus object.
*/
- sdbusplus::bus::bus& _bus;
+ sdbusplus::bus_t& _bus;
/**
* @brief The path to the associations JSON File.
diff --git a/functor.cpp b/functor.cpp
index d0dbbcc..272bd14 100644
--- a/functor.cpp
+++ b/functor.cpp
@@ -30,8 +30,8 @@
{
namespace functor
{
-bool PropertyConditionBase::operator()(sdbusplus::bus::bus& bus,
- sdbusplus::message::message&,
+bool PropertyConditionBase::operator()(sdbusplus::bus_t& bus,
+ sdbusplus::message_t&,
Manager& mgr) const
{
std::string path(_path);
@@ -39,7 +39,7 @@
}
bool PropertyConditionBase::operator()(const std::string& path,
- sdbusplus::bus::bus& bus,
+ sdbusplus::bus_t& bus,
Manager& mgr) const
{
std::string host;
diff --git a/functor.hpp b/functor.hpp
index e220550..903cbd0 100644
--- a/functor.hpp
+++ b/functor.hpp
@@ -208,7 +208,7 @@
* Extract the property from the PropertiesChanged
* message and run the condition test.
*/
- bool operator()(sdbusplus::bus::bus&, sdbusplus::message::message& msg,
+ bool operator()(sdbusplus::bus_t&, sdbusplus::message_t& msg,
Manager&) const
{
std::map<std::string, std::variant<T>> properties;
@@ -272,7 +272,7 @@
{}
/** @brief Forward comparison to type specific implementation. */
- virtual bool eval(sdbusplus::message::message&) const = 0;
+ virtual bool eval(sdbusplus::message_t&) const = 0;
/** @brief Forward comparison to type specific implementation. */
virtual bool eval(Manager&) const = 0;
@@ -281,14 +281,13 @@
*
* Make a DBus call and test the value of any property.
*/
- bool operator()(sdbusplus::bus::bus&, sdbusplus::message::message&,
- Manager&) const;
+ bool operator()(sdbusplus::bus_t&, sdbusplus::message_t&, Manager&) const;
/** @brief Test a property value.
*
* Make a DBus call and test the value of any property.
*/
- bool operator()(const std::string&, sdbusplus::bus::bus&, Manager&) const;
+ bool operator()(const std::string&, sdbusplus::bus_t&, Manager&) const;
private:
std::string _path;
@@ -347,7 +346,7 @@
*
* Make a DBus call and test the value of any property.
*/
- bool eval(sdbusplus::message::message& msg) const override
+ bool eval(sdbusplus::message_t& msg) const override
{
std::variant<T> value;
msg.read(value);
diff --git a/interface_ops.hpp b/interface_ops.hpp
index 98b0ffb..8806fdc 100644
--- a/interface_ops.hpp
+++ b/interface_ops.hpp
@@ -47,7 +47,7 @@
template <typename T, typename Enable = void>
struct MakeInterface
{
- static std::any op(sdbusplus::bus::bus& bus, const char* path,
+ static std::any op(sdbusplus::bus_t& bus, const char* path,
const Interface&, bool)
{
return std::any(std::make_shared<T>(bus, path));
@@ -57,7 +57,7 @@
template <typename T>
struct MakeInterface<T, std::enable_if_t<HasProperties<T>::value>>
{
- static std::any op(sdbusplus::bus::bus& bus, const char* path,
+ static std::any op(sdbusplus::bus_t& bus, const char* path,
const Interface& props, bool deferSignal)
{
using InterfaceVariant =
diff --git a/manager.cpp b/manager.cpp
index fad77e6..2c4ee11 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -40,7 +40,7 @@
{
try
{
- auto msg = sdbusplus::message::message(m);
+ auto msg = sdbusplus::message_t(m);
auto& args = *static_cast<Manager::SigArg*>(data);
sd_bus_message_ref(m);
auto& mgr = *std::get<0>(args);
@@ -55,7 +55,7 @@
return 0;
}
-Manager::Manager(sdbusplus::bus::bus&& bus, const char* root) :
+Manager::Manager(sdbusplus::bus_t&& bus, const char* root) :
ServerObject<ManagerIface>(bus, root), _root(root), _bus(std::move(bus)),
_manager(_bus, root),
#ifdef CREATE_ASSOCIATIONS
@@ -100,7 +100,7 @@
void Manager::run(const char* busname)
{
- sdbusplus::message::message unusedMsg{nullptr};
+ sdbusplus::message_t unusedMsg{nullptr};
// Run startup events.
for (auto& group : _events)
@@ -275,7 +275,7 @@
updateObjects(objs);
}
-void Manager::handleEvent(sdbusplus::message::message& msg, const Event& event,
+void Manager::handleEvent(sdbusplus::message_t& msg, const Event& event,
const EventInfo& info)
{
auto& actions = std::get<1>(info);
diff --git a/manager.hpp b/manager.hpp
index 744caa5..e580481 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -60,7 +60,7 @@
* @param[in] root - The DBus path on which to implement
* an inventory manager.
*/
- Manager(sdbusplus::bus::bus&&, const char*);
+ Manager(sdbusplus::bus_t&&, const char*);
using EventInfo =
std::tuple<std::vector<EventBasePtr>, std::vector<Action>>;
@@ -79,7 +79,7 @@
notify(std::map<sdbusplus::message::object_path, Object> objs) override;
/** @brief Event processing entry point. */
- void handleEvent(sdbusplus::message::message&, const Event& event,
+ void handleEvent(sdbusplus::message_t&, const Event& event,
const EventInfo& info);
/** @brief Drop one or more objects from DBus. */
@@ -201,10 +201,10 @@
std::vector<sdbusplus::bus::match_t> _matches;
/** @brief Persistent sdbusplus DBus bus connection. */
- sdbusplus::bus::bus _bus;
+ sdbusplus::bus_t _bus;
/** @brief sdbusplus org.freedesktop.DBus.ObjectManager reference. */
- sdbusplus::server::manager::manager _manager;
+ sdbusplus::server::manager_t _manager;
/** @brief A container of pimgen generated events and responses. */
static const Events _events;
diff --git a/test/associations_test.cpp b/test/associations_test.cpp
index 5fa95c3..6515ee3 100644
--- a/test/associations_test.cpp
+++ b/test/associations_test.cpp
@@ -145,7 +145,7 @@
{}
fs::path jsonDir;
- sdbusplus::bus::bus bus;
+ sdbusplus::bus_t bus;
virtual void SetUp()
{
diff --git a/test/interface_ops_test.cpp b/test/interface_ops_test.cpp
index 3033423..b6d6ac8 100644
--- a/test/interface_ops_test.cpp
+++ b/test/interface_ops_test.cpp
@@ -52,7 +52,7 @@
struct DummyInterfaceWithoutProperties
{
- DummyInterfaceWithoutProperties(sdbusplus::bus::bus&, const char* name)
+ DummyInterfaceWithoutProperties(sdbusplus::bus_t&, const char* name)
{
g_currentMock->constructWithoutProperties(name);
}
@@ -62,7 +62,7 @@
{
using PropertiesVariant = FakeVariantType;
- DummyInterfaceWithProperties(sdbusplus::bus::bus&, const char* name,
+ DummyInterfaceWithProperties(sdbusplus::bus_t&, const char* name,
const InterfaceVariant& i, bool skipSignal)
{
g_currentMock->constructWithProperties(name, i, skipSignal);
diff --git a/types.hpp b/types.hpp
index 1840edf..2b946a0 100644
--- a/types.hpp
+++ b/types.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/message.hpp>
#include <sdbusplus/message/types.hpp>
#include <cstdint>
@@ -7,18 +9,6 @@
#include <map>
#include <string>
-namespace sdbusplus
-{
-namespace message
-{
-class message;
-}
-namespace bus
-{
-class bus;
-}
-} // namespace sdbusplus
-
namespace phosphor
{
namespace inventory
@@ -41,11 +31,11 @@
using Interface = InterfaceType<InterfaceVariantType>;
using Object = ObjectType<InterfaceVariantType>;
-using Action = std::function<void(sdbusplus::bus::bus&, Manager&)>;
-using Filter = std::function<bool(sdbusplus::bus::bus&,
- sdbusplus::message::message&, Manager&)>;
+using Action = std::function<void(sdbusplus::bus_t&, Manager&)>;
+using Filter =
+ std::function<bool(sdbusplus::bus_t&, sdbusplus::message_t&, Manager&)>;
using PathCondition =
- std::function<bool(const std::string&, sdbusplus::bus::bus&, Manager&)>;
+ std::function<bool(const std::string&, sdbusplus::bus_t&, Manager&)>;
template <typename T>
using GetProperty = std::function<T(Manager&)>;
} // namespace manager