forked from Kistler-Group/sdbus-cpp
perf: provide also const char* overloads for convenience functions
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "Utils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include SDBUS_HEADER
|
||||
#include <utility>
|
||||
|
||||
@@ -46,8 +47,8 @@ Proxy::Proxy(sdbus::internal::IConnection& connection, ServiceName destination,
|
||||
, destination_(std::move(destination))
|
||||
, objectPath_(std::move(objectPath))
|
||||
{
|
||||
SDBUS_CHECK_SERVICE_NAME(destination_);
|
||||
SDBUS_CHECK_OBJECT_PATH(objectPath_);
|
||||
SDBUS_CHECK_SERVICE_NAME(destination_.c_str());
|
||||
SDBUS_CHECK_OBJECT_PATH(objectPath_.c_str());
|
||||
|
||||
// The connection is not ours only, it is owned and managed by the user and we just reference
|
||||
// it here, so we expect the client to manage the event loop upon this connection themselves.
|
||||
@@ -60,8 +61,8 @@ Proxy::Proxy( std::unique_ptr<sdbus::internal::IConnection>&& connection
|
||||
, destination_(std::move(destination))
|
||||
, objectPath_(std::move(objectPath))
|
||||
{
|
||||
SDBUS_CHECK_SERVICE_NAME(destination_);
|
||||
SDBUS_CHECK_OBJECT_PATH(objectPath_);
|
||||
SDBUS_CHECK_SERVICE_NAME(destination_.c_str());
|
||||
SDBUS_CHECK_OBJECT_PATH(objectPath_.c_str());
|
||||
|
||||
// The connection is ours only, i.e. it's us who has to manage the event loop upon this connection,
|
||||
// in order that we get and process signals, async call replies, and other messages from D-Bus.
|
||||
@@ -76,8 +77,8 @@ Proxy::Proxy( std::unique_ptr<sdbus::internal::IConnection>&& connection
|
||||
, destination_(std::move(destination))
|
||||
, objectPath_(std::move(objectPath))
|
||||
{
|
||||
SDBUS_CHECK_SERVICE_NAME(destination_);
|
||||
SDBUS_CHECK_OBJECT_PATH(objectPath_);
|
||||
SDBUS_CHECK_SERVICE_NAME(destination_.c_str());
|
||||
SDBUS_CHECK_OBJECT_PATH(objectPath_.c_str());
|
||||
|
||||
// Even though the connection is ours only, we don't start an event loop thread.
|
||||
// This proxy is meant to be created, used for simple synchronous D-Bus call(s) and then dismissed.
|
||||
@@ -88,6 +89,11 @@ MethodCall Proxy::createMethodCall(const InterfaceName& interfaceName, const Met
|
||||
return connection_->createMethodCall(destination_, objectPath_, interfaceName, methodName);
|
||||
}
|
||||
|
||||
MethodCall Proxy::createMethodCall(const char* interfaceName, const char* methodName)
|
||||
{
|
||||
return connection_->createMethodCall(destination_.c_str(), objectPath_.c_str(), interfaceName, methodName);
|
||||
}
|
||||
|
||||
MethodReply Proxy::callMethod(const MethodCall& message, uint64_t timeout)
|
||||
{
|
||||
SDBUS_THROW_ERROR_IF(!message.isValid(), "Invalid method call message provided", EINVAL);
|
||||
@@ -137,6 +143,13 @@ std::future<MethodReply> Proxy::callMethodAsync(const MethodCall& message, uint6
|
||||
void Proxy::registerSignalHandler( const InterfaceName& interfaceName
|
||||
, const SignalName& signalName
|
||||
, signal_handler signalHandler )
|
||||
{
|
||||
Proxy::registerSignalHandler(interfaceName.c_str(), signalName.c_str(), std::move(signalHandler));
|
||||
}
|
||||
|
||||
void Proxy::registerSignalHandler( const char* interfaceName
|
||||
, const char* signalName
|
||||
, signal_handler signalHandler )
|
||||
{
|
||||
auto slot = Proxy::registerSignalHandler(interfaceName, signalName, std::move(signalHandler), return_slot);
|
||||
|
||||
@@ -147,6 +160,14 @@ Slot Proxy::registerSignalHandler( const InterfaceName& interfaceName
|
||||
, const SignalName& signalName
|
||||
, signal_handler signalHandler
|
||||
, return_slot_t )
|
||||
{
|
||||
return Proxy::registerSignalHandler(interfaceName.c_str(), signalName.c_str(), std::move(signalHandler), return_slot);
|
||||
}
|
||||
|
||||
Slot Proxy::registerSignalHandler( const char* interfaceName
|
||||
, const char* signalName
|
||||
, signal_handler signalHandler
|
||||
, return_slot_t )
|
||||
{
|
||||
SDBUS_CHECK_INTERFACE_NAME(interfaceName);
|
||||
SDBUS_CHECK_MEMBER_NAME(signalName);
|
||||
@@ -154,8 +175,8 @@ Slot Proxy::registerSignalHandler( const InterfaceName& interfaceName
|
||||
|
||||
auto signalInfo = std::make_unique<SignalInfo>(SignalInfo{std::move(signalHandler), *this, {}});
|
||||
|
||||
signalInfo->slot = connection_->registerSignalHandler( destination_
|
||||
, objectPath_
|
||||
signalInfo->slot = connection_->registerSignalHandler( destination_.c_str()
|
||||
, objectPath_.c_str()
|
||||
, interfaceName
|
||||
, signalName
|
||||
, &Proxy::sdbus_signal_handler
|
||||
|
||||
Reference in New Issue
Block a user