message: shorten message type
Create an alias `sdbusplus::message_t` to `sdbusplus::message::message`
to reduce duplication.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ib400b12fe4a412c0c0c3d26a88f3fae46445cfa8
diff --git a/include/sdbusplus/asio/connection.hpp b/include/sdbusplus/asio/connection.hpp
index 7787b61..7e94cdd 100644
--- a/include/sdbusplus/asio/connection.hpp
+++ b/include/sdbusplus/asio/connection.hpp
@@ -86,16 +86,15 @@
template <typename MessageHandler>
inline BOOST_ASIO_INITFN_RESULT_TYPE(MessageHandler,
void(boost::system::error_code,
- message::message&))
- async_send(message::message& m, MessageHandler&& handler,
- uint64_t timeout = 0)
+ message_t&))
+ async_send(message_t& m, MessageHandler&& handler, uint64_t timeout = 0)
{
boost::asio::async_completion<
- MessageHandler, void(boost::system::error_code, message::message)>
+ MessageHandler, void(boost::system::error_code, message_t)>
init(handler);
detail::async_send_handler<typename boost::asio::async_result<
MessageHandler, void(boost::system::error_code,
- message::message)>::completion_handler_type>(
+ message_t)>::completion_handler_type>(
std::move(init.completion_handler))(get(), m, timeout);
return init.result.get();
}
@@ -107,7 +106,7 @@
* continuation for the async dbus method call. The
* arguments to parse on the return are deduced from
* the handler's signature and then passed in along
- * with an error code and optional message::message
+ * with an error code and optional message_t
* @param[in] service - The service to call.
* @param[in] objpath - The object's path for the call.
* @param[in] interf - The object's interface to call.
@@ -136,7 +135,7 @@
{
return std::is_same_v<
std::tuple_element_t<1, FunctionTupleType>,
- sdbusplus::message::message>;
+ sdbusplus::message_t>;
}
return false;
}();
@@ -144,7 +143,7 @@
FunctionTupleType>;
auto applyHandler = [handler = std::forward<MessageHandler>(handler)](
boost::system::error_code ec,
- message::message& r) mutable {
+ message_t& r) mutable {
UnpackType responseData;
if (!ec)
{
@@ -175,7 +174,7 @@
std::apply(handler, response);
}
};
- message::message m;
+ message_t m;
boost::system::error_code ec;
try
{
@@ -201,7 +200,7 @@
* continuation for the async dbus method call. The
* arguments to parse on the return are deduced from
* the handler's signature and then passed in along
- * with an error code and optional message::message
+ * with an error code and optional message_t
* @param[in] service - The service to call.
* @param[in] objpath - The object's path for the call.
* @param[in] interf - The object's interface to call.
@@ -244,7 +243,7 @@
const std::string& interf, const std::string& method,
const InputArgs&... a)
{
- message::message m;
+ message_t m;
try
{
m = new_method_call(service.c_str(), objpath.c_str(),
@@ -256,7 +255,7 @@
ec = boost::system::errc::make_error_code(
static_cast<boost::system::errc::errc_t>(e.get_errno()));
}
- message::message r;
+ message_t r;
if (!ec)
{
r = async_send(m, yield[ec]);
diff --git a/include/sdbusplus/asio/detail/async_send_handler.hpp b/include/sdbusplus/asio/detail/async_send_handler.hpp
index d02075b..13d23e4 100644
--- a/include/sdbusplus/asio/detail/async_send_handler.hpp
+++ b/include/sdbusplus/asio/detail/async_send_handler.hpp
@@ -35,7 +35,7 @@
{}
async_send_handler(Handler& handler) : handler_(handler)
{}
- void operator()(sd_bus* conn, message::message& mesg, uint64_t timeout)
+ void operator()(sd_bus* conn, message_t& mesg, uint64_t timeout)
{
async_send_handler* context = new async_send_handler(std::move(*this));
int ec = sd_bus_call_async(conn, NULL, mesg.get(), &callback, context,
@@ -58,7 +58,7 @@
}
std::unique_ptr<async_send_handler> context(
static_cast<async_send_handler*>(userdata));
- message::message message(mesg);
+ message_t message(mesg);
auto ec = make_error_code(
static_cast<boost::system::errc::errc_t>(message.get_errno()));
context->handler_(ec, message);
diff --git a/include/sdbusplus/asio/object_server.hpp b/include/sdbusplus/asio/object_server.hpp
index 43c0795..6bd90e0 100644
--- a/include/sdbusplus/asio/object_server.hpp
+++ b/include/sdbusplus/asio/object_server.hpp
@@ -33,7 +33,7 @@
{
public:
virtual ~callback() = default;
- virtual int call(message::message& m) = 0;
+ virtual int call(message_t& m) = 0;
};
enum class SetPropertyReturnValue : size_t
@@ -47,7 +47,7 @@
{
public:
virtual ~callback_set() = default;
- virtual SetPropertyReturnValue call(message::message& m) = 0;
+ virtual SetPropertyReturnValue call(message_t& m) = 0;
virtual SetPropertyReturnValue set(const boost::any& value) = 0;
};
@@ -61,13 +61,13 @@
inline const bool FirstArgIsMessage_v =
std::is_same_v<utility::get_first_arg_t<utility::decay_tuple_t<
boost::callable_traits::args_t<T>>>,
- message::message>;
+ message_t>;
template <typename T>
inline const bool SecondArgIsMessage_v = std::is_same_v<
utility::get_first_arg_t<utility::strip_first_arg_t<
utility::decay_tuple_t<boost::callable_traits::args_t<T>>>>,
- message::message>;
+ message_t>;
template <typename T>
static constexpr bool callbackYields = FirstArgIsYield_v<T>;
template <typename T>
@@ -78,7 +78,7 @@
namespace details
{
// small helper class to count the number of non-dbus arguments
-// to a registered dbus function (like message::message or yield_context)
+// to a registered dbus function (like message_t or yield_context)
// so the registered signature can omit them
template <typename FirstArg, typename... Rest>
struct NonDbusArgsCount;
@@ -96,7 +96,7 @@
{
constexpr static std::size_t size()
{
- if constexpr (std::is_same_v<FirstArg, message::message> ||
+ if constexpr (std::is_same_v<FirstArg, message_t> ||
std::is_same_v<FirstArg, boost::asio::yield_context>)
{
return 1 + NonDbusArgsCount<std::tuple<OtherArgs...>>::size();
@@ -116,7 +116,7 @@
public:
callback_method_instance(CallbackType&& func) : func_(std::move(func))
{}
- int call(message::message& m) override
+ int call(message_t& m) override
{
return expandCall(m);
}
@@ -128,20 +128,20 @@
CallbackType func_;
template <typename T>
std::enable_if_t<!std::is_void_v<T>, void>
- callFunction(message::message& m, InputTupleType& inputArgs)
+ callFunction(message_t& m, InputTupleType& inputArgs)
{
ResultType r = std::apply(func_, inputArgs);
m.append(r);
}
template <typename T>
std::enable_if_t<std::is_void_v<T>, void>
- callFunction(message::message&, InputTupleType& inputArgs)
+ callFunction(message_t&, InputTupleType& inputArgs)
{
std::apply(func_, inputArgs);
}
#ifdef __cpp_if_constexpr
// optional message-first-argument callback
- int expandCall(message::message& m)
+ int expandCall(message_t& m)
{
using DbusTupleType = utility::strip_first_n_args_t<
details::NonDbusArgsCount<InputTupleType>::size(), InputTupleType>;
@@ -168,7 +168,7 @@
};
#else
// normal dbus-types-only callback
- int expandCall(message::message& m)
+ int expandCall(message_t& m)
{
InputTupleType inputArgs;
if (!utility::read_into_tuple(inputArgs, m))
@@ -194,15 +194,15 @@
io_(io),
func_(std::move(func))
{}
- int call(message::message& m) override
+ int call(message_t& m) override
{
// make a copy of m to move into the coroutine
- message::message b{m};
+ message_t b{m};
// spawn off a new coroutine to handle the method call
boost::asio::spawn(
io_, [this, b = std::move(b)](boost::asio::yield_context yield) {
- message::message mcpy{std::move(b)};
- std::optional<message::message> err{};
+ message_t mcpy{std::move(b)};
+ std::optional<message_t> err{};
try
{
@@ -234,19 +234,19 @@
CallbackType func_;
template <typename T>
std::enable_if_t<!std::is_void_v<T>, void>
- callFunction(message::message& m, InputTupleType& inputArgs)
+ callFunction(message_t& m, InputTupleType& inputArgs)
{
ResultType r = std::apply(func_, inputArgs);
m.append(r);
}
template <typename T>
std::enable_if_t<std::is_void_v<T>, void>
- callFunction(message::message& m, InputTupleType& inputArgs)
+ callFunction(message_t& m, InputTupleType& inputArgs)
{
std::apply(func_, inputArgs);
}
// co-routine body for call
- void expandCall(boost::asio::yield_context yield, message::message& m)
+ void expandCall(boost::asio::yield_context yield, message_t& m)
{
using DbusTupleType = utility::strip_first_n_args_t<
details::NonDbusArgsCount<InputTupleType>::size(), InputTupleType>;
@@ -290,7 +290,7 @@
value_(value),
func_(std::move(func))
{}
- int call(message::message& m) override
+ int call(message_t& m) override
{
auto r = func_(*value_);
m.append(r);
@@ -311,7 +311,7 @@
value_(value),
func_(std::move(func))
{}
- SetPropertyReturnValue call(message::message& m) override
+ SetPropertyReturnValue call(message_t& m) override
{
PropertyType input;
m.read(input);
@@ -626,7 +626,7 @@
{
dbus_interface* data = static_cast<dbus_interface*>(userdata);
auto func = data->callbacksGet_.find(property);
- auto mesg = message::message(reply);
+ auto mesg = message_t(reply);
if (func != data->callbacksGet_.end())
{
#ifdef __EXCEPTIONS
@@ -657,7 +657,7 @@
{
dbus_interface* data = static_cast<dbus_interface*>(userdata);
auto func = data->callbacksSet_.find(property);
- auto mesg = message::message(value);
+ auto mesg = message_t(value);
if (func != data->callbacksSet_.end())
{
#ifdef __EXCEPTIONS
@@ -695,7 +695,7 @@
sd_bus_error* error)
{
dbus_interface* data = static_cast<dbus_interface*>(userdata);
- auto mesg = message::message(m);
+ auto mesg = message_t(m);
auto func = data->callbacksMethod_.find(mesg.get_member());
if (func != data->callbacksMethod_.end())
{
@@ -732,7 +732,7 @@
{
if (!initialized_)
{
- return message::message(nullptr);
+ return message_t(nullptr);
}
return interface_->new_signal(member);
}