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: I8c73d8de128b218ee4885a5e133314ad5d9a0ff8
diff --git a/dbusSensor.hpp b/dbusSensor.hpp
index bfda9b0..5c119a5 100644
--- a/dbusSensor.hpp
+++ b/dbusSensor.hpp
@@ -18,7 +18,7 @@
* @param[in] bus - Handle to system dbus
* @param[in] path - The Dbus path of sensor
*/
- DbusSensor(sdbusplus::bus::bus& bus, const std::string& path, void* ctx) :
+ DbusSensor(sdbusplus::bus_t& bus, const std::string& path, void* ctx) :
bus(bus), path(path),
signal(
bus,
@@ -51,7 +51,7 @@
private:
/** @brief sdbusplus bus client connection. */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief complete path for sensor */
std::string path{};
/** @brief service name for the sensor daemon */
diff --git a/dbusUtils.hpp b/dbusUtils.hpp
index 72546e1..52d19c1 100644
--- a/dbusUtils.hpp
+++ b/dbusUtils.hpp
@@ -13,7 +13,7 @@
using Value = std::variant<int64_t, double, std::string, bool>;
-std::string getService(sdbusplus::bus::bus& bus, const std::string& path,
+std::string getService(sdbusplus::bus_t& bus, const std::string& path,
const char* intf)
{
/* Get mapper object for sensor path */
@@ -30,7 +30,7 @@
auto msg = bus.call(mapper);
msg.read(resp);
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
if (ex.name() == std::string(sdbusplus::xyz::openbmc_project::Common::
Error::ResourceNotFound::errName))
@@ -53,7 +53,7 @@
template <typename T>
-T getDbusProperty(sdbusplus::bus::bus& bus, const std::string& service,
+T getDbusProperty(sdbusplus::bus_t& bus, const std::string& service,
const std::string& path, const std::string& intf,
const std::string& property)
{
@@ -70,7 +70,7 @@
auto msg = bus.call(method);
msg.read(value);
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
return std::numeric_limits<T>::quiet_NaN();
}
diff --git a/thresholds.hpp b/thresholds.hpp
index 96486d3..2e42938 100644
--- a/thresholds.hpp
+++ b/thresholds.hpp
@@ -10,7 +10,7 @@
{
template <typename... T>
-using ServerObject = typename sdbusplus::server::object::object<T...>;
+using ServerObject = typename sdbusplus::server::object_t<T...>;
namespace threshold_ns =
sdbusplus::xyz::openbmc_project::Sensor::Threshold::server;
diff --git a/virtualSensor.cpp b/virtualSensor.cpp
index 4a60f4d..82cd5ab 100644
--- a/virtualSensor.cpp
+++ b/virtualSensor.cpp
@@ -26,7 +26,7 @@
throw std::runtime_error("Invalid match");
}
- auto sdbpMsg = sdbusplus::message::message(msg);
+ auto sdbpMsg = sdbusplus::message_t(msg);
std::string msgIfce;
std::map<std::string, std::variant<int64_t, double, bool>> msgData;
@@ -633,7 +633,7 @@
auto reply = bus.call(method);
reply.read(objects);
}
- catch (const sdbusplus::exception::exception& ex)
+ catch (const sdbusplus::exception_t& ex)
{
// If entity manager isn't running yet, keep going.
if (std::string("org.freedesktop.DBus.Error.ServiceUnknown") !=
@@ -646,7 +646,7 @@
return objects;
}
-void VirtualSensors::propertiesChanged(sdbusplus::message::message& msg)
+void VirtualSensors::propertiesChanged(sdbusplus::message_t& msg)
{
std::string path;
PropertyMap properties;
@@ -720,7 +720,7 @@
}
/* Setup matches */
- auto eventHandler = [this](sdbusplus::message::message& message) {
+ auto eventHandler = [this](sdbusplus::message_t& message) {
if (message.is_method_error())
{
error("Callback method error");
@@ -731,7 +731,7 @@
for (const char* iface : calculationIfaces)
{
- auto match = std::make_unique<sdbusplus::bus::match::match>(
+ auto match = std::make_unique<sdbusplus::bus::match_t>(
bus,
sdbusplus::bus::match::rules::propertiesChangedNamespace(
"/xyz/openbmc_project/inventory", iface),
@@ -815,7 +815,7 @@
/* Setup match for interfaces removed */
auto intfRemoved = [this, objpath,
- name](sdbusplus::message::message& message) {
+ name](sdbusplus::message_t& message) {
if (!virtualSensorsMap.contains(name))
{
return;
@@ -828,7 +828,7 @@
virtualSensorsMap.erase(name);
}
};
- auto matchOnRemove = std::make_unique<sdbusplus::bus::match::match>(
+ auto matchOnRemove = std::make_unique<sdbusplus::bus::match_t>(
bus,
sdbusplus::bus::match::rules::interfacesRemoved() +
sdbusplus::bus::match::rules::argNpath(0, objpath),
@@ -950,7 +950,7 @@
auto bus = sdbusplus::bus::new_default();
// Add the ObjectManager interface
- sdbusplus::server::manager::manager objManager(bus, "/");
+ sdbusplus::server::manager_t objManager(bus, "/");
// Create an virtual sensors object
phosphor::virtualSensor::VirtualSensors virtualSensors(bus);
diff --git a/virtualSensor.hpp b/virtualSensor.hpp
index cff46f7..8a9b115 100644
--- a/virtualSensor.hpp
+++ b/virtualSensor.hpp
@@ -32,7 +32,7 @@
using Json = nlohmann::json;
template <typename... T>
-using ServerObject = typename sdbusplus::server::object::object<T...>;
+using ServerObject = typename sdbusplus::server::object_t<T...>;
using ValueIface = sdbusplus::xyz::openbmc_project::Sensor::server::Value;
using ValueObject = ServerObject<ValueIface>;
@@ -66,7 +66,7 @@
* @param[in] path - The Dbus path of sensor
* @param[in] ctx - sensor context for update
*/
- SensorParam(sdbusplus::bus::bus& bus, const std::string& path, void* ctx) :
+ SensorParam(sdbusplus::bus_t& bus, const std::string& path, void* ctx) :
dbusSensor(std::make_unique<DbusSensor>(bus, path, ctx)),
paramType(dbusParam)
{}
@@ -92,7 +92,7 @@
* @param[in] objPath - The Dbus path of sensor
* @param[in] sensorConfig - Json object for sensor config
*/
- VirtualSensor(sdbusplus::bus::bus& bus, const char* objPath,
+ VirtualSensor(sdbusplus::bus_t& bus, const char* objPath,
const Json& sensorConfig, const std::string& name) :
ValueObject(bus, objPath, action::defer_emit),
bus(bus), name(name)
@@ -110,7 +110,7 @@
* @param[in] calcType - Calculation used to calculate sensor value
*
*/
- VirtualSensor(sdbusplus::bus::bus& bus, const char* objPath,
+ VirtualSensor(sdbusplus::bus_t& bus, const char* objPath,
const InterfaceMap& ifacemap, const std::string& name,
const std::string& type, const std::string& calculationType) :
ValueObject(bus, objPath, action::defer_emit),
@@ -133,7 +133,7 @@
private:
/** @brief sdbusplus bus client connection. */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief name of sensor */
std::string name;
/** @brief Expression string for virtual sensor value calculations */
@@ -255,23 +255,23 @@
*
* @param[in] bus - Handle to system dbus
*/
- explicit VirtualSensors(sdbusplus::bus::bus& bus) : bus(bus)
+ explicit VirtualSensors(sdbusplus::bus_t& bus) : bus(bus)
{
createVirtualSensors();
}
/** @brief Calls createVirtualSensor when interface added */
- void propertiesChanged(sdbusplus::message::message& msg);
+ void propertiesChanged(sdbusplus::message_t& msg);
private:
/** @brief sdbusplus bus client connection. */
- sdbusplus::bus::bus& bus;
+ sdbusplus::bus_t& bus;
/** @brief Get virual sensor config from DBus**/
ManagedObjectType getObjectsFromDBus();
/** @brief Parsing virtual sensor config JSON file */
Json parseConfigFile(const std::string& configFile);
/** @brief Matches for virtual sensors */
- std::vector<std::unique_ptr<sdbusplus::bus::match::match>> matches;
+ std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches;
/** @brief Map of the object VirtualSensor */
std::unordered_map<std::string, std::unique_ptr<VirtualSensor>>
virtualSensorsMap;