mirror of
https://github.com/Kistler-Group/sdbus-cpp.git
synced 2025-07-29 17:47:18 +02:00
refactor: add nodiscard attribute for more functions
This commit is contained in:
@ -55,17 +55,17 @@ namespace sdbus {
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& getName() const
|
||||
[[nodiscard]] const std::string& getName() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
const std::string& getMessage() const
|
||||
[[nodiscard]] const std::string& getMessage() const
|
||||
{
|
||||
return message_;
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
[[nodiscard]] bool isValid() const
|
||||
{
|
||||
return !getName().empty();
|
||||
}
|
||||
|
@ -74,21 +74,21 @@ namespace sdbus {
|
||||
flags_.set(flag, value);
|
||||
}
|
||||
|
||||
bool test(GeneralFlags flag) const
|
||||
[[nodiscard]] bool test(GeneralFlags flag) const
|
||||
{
|
||||
return flags_.test(flag);
|
||||
}
|
||||
|
||||
bool test(PropertyUpdateBehaviorFlags flag) const
|
||||
[[nodiscard]] bool test(PropertyUpdateBehaviorFlags flag) const
|
||||
{
|
||||
return flags_.test(flag);
|
||||
}
|
||||
|
||||
uint64_t toSdBusInterfaceFlags() const;
|
||||
uint64_t toSdBusMethodFlags() const;
|
||||
uint64_t toSdBusSignalFlags() const;
|
||||
uint64_t toSdBusPropertyFlags() const;
|
||||
uint64_t toSdBusWritablePropertyFlags() const;
|
||||
[[nodiscard]] uint64_t toSdBusInterfaceFlags() const;
|
||||
[[nodiscard]] uint64_t toSdBusMethodFlags() const;
|
||||
[[nodiscard]] uint64_t toSdBusSignalFlags() const;
|
||||
[[nodiscard]] uint64_t toSdBusPropertyFlags() const;
|
||||
[[nodiscard]] uint64_t toSdBusWritablePropertyFlags() const;
|
||||
|
||||
private:
|
||||
std::bitset<FLAG_COUNT> flags_;
|
||||
|
@ -381,7 +381,7 @@ namespace sdbus {
|
||||
*
|
||||
* @deprecated This function has been replaced by getEventLoopPollData()
|
||||
*/
|
||||
[[deprecated("This function has been replaced by getEventLoopPollData()")]] PollData getProcessLoopPollData() const;
|
||||
[[nodiscard]] [[deprecated("This function has been replaced by getEventLoopPollData()")]] PollData getProcessLoopPollData() const;
|
||||
|
||||
/*!
|
||||
* @struct PollData
|
||||
|
@ -488,7 +488,7 @@ namespace sdbus {
|
||||
* Pending call in this context means a call whose results have not arrived, or
|
||||
* have arrived and are currently being processed by the callback handler.
|
||||
*/
|
||||
bool isPending() const;
|
||||
[[nodiscard]] bool isPending() const;
|
||||
|
||||
private:
|
||||
friend internal::Proxy;
|
||||
|
@ -256,7 +256,7 @@ namespace sdbus {
|
||||
close();
|
||||
}
|
||||
|
||||
int get() const
|
||||
[[nodiscard]] int get() const
|
||||
{
|
||||
return fd_;
|
||||
}
|
||||
@ -276,7 +276,7 @@ namespace sdbus {
|
||||
return std::exchange(fd_, -1);
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
[[nodiscard]] bool isValid() const
|
||||
{
|
||||
return fd_ >= 0;
|
||||
}
|
||||
|
@ -83,11 +83,11 @@ namespace sdbus::internal {
|
||||
|
||||
void requestName(const std::string& name) override;
|
||||
void releaseName(const std::string& name) override;
|
||||
std::string getUniqueName() const override;
|
||||
[[nodiscard]] std::string getUniqueName() const override;
|
||||
void enterEventLoop() override;
|
||||
void enterEventLoopAsync() override;
|
||||
void leaveEventLoop() override;
|
||||
PollData getEventLoopPollData() const override;
|
||||
[[nodiscard]] PollData getEventLoopPollData() const override;
|
||||
bool processPendingEvent() override;
|
||||
Message getCurrentlyProcessedMessage() const override;
|
||||
|
||||
@ -96,7 +96,7 @@ namespace sdbus::internal {
|
||||
Slot addObjectManager(const std::string& objectPath, return_slot_t) override;
|
||||
|
||||
void setMethodCallTimeout(uint64_t timeout) override;
|
||||
uint64_t getMethodCallTimeout() const override;
|
||||
[[nodiscard]] uint64_t getMethodCallTimeout() const override;
|
||||
|
||||
[[nodiscard]] Slot addMatch(const std::string& match, message_handler callback) override;
|
||||
void addMatch(const std::string& match, message_handler callback, floating_slot_t) override;
|
||||
@ -107,22 +107,22 @@ namespace sdbus::internal {
|
||||
void detachSdEventLoop() override;
|
||||
sd_event *getSdEventLoop() override;
|
||||
|
||||
const ISdBus& getSdBusInterface() const override;
|
||||
ISdBus& getSdBusInterface() override;
|
||||
[[nodiscard]] const ISdBus& getSdBusInterface() const override;
|
||||
[[nodiscard]] ISdBus& getSdBusInterface() override;
|
||||
|
||||
Slot addObjectVTable( const std::string& objectPath
|
||||
, const std::string& interfaceName
|
||||
, const sd_bus_vtable* vtable
|
||||
, void* userData ) override;
|
||||
|
||||
PlainMessage createPlainMessage() const override;
|
||||
MethodCall createMethodCall( const std::string& destination
|
||||
, const std::string& objectPath
|
||||
, const std::string& interfaceName
|
||||
, const std::string& methodName ) const override;
|
||||
Signal createSignal( const std::string& objectPath
|
||||
, const std::string& interfaceName
|
||||
, const std::string& signalName ) const override;
|
||||
[[nodiscard]] PlainMessage createPlainMessage() const override;
|
||||
[[nodiscard]] MethodCall createMethodCall( const std::string& destination
|
||||
, const std::string& objectPath
|
||||
, const std::string& interfaceName
|
||||
, const std::string& methodName ) const override;
|
||||
[[nodiscard]] Signal createSignal( const std::string& objectPath
|
||||
, const std::string& interfaceName
|
||||
, const std::string& signalName ) const override;
|
||||
|
||||
MethodReply callMethod(const MethodCall& message, uint64_t timeout) override;
|
||||
void callMethod(const MethodCall& message, void* callback, void* userData, uint64_t timeout, floating_slot_t) override;
|
||||
@ -155,7 +155,7 @@ namespace sdbus::internal {
|
||||
void finishHandshake(sd_bus* bus);
|
||||
bool waitForNextEvent();
|
||||
|
||||
bool arePendingMessagesInReadQueue() const;
|
||||
[[nodiscard]] bool arePendingMessagesInReadQueue() const;
|
||||
|
||||
void notifyEventLoopToExit();
|
||||
void notifyEventLoopToWakeUpFromPoll();
|
||||
|
@ -56,22 +56,22 @@ namespace sdbus::internal {
|
||||
public:
|
||||
~IConnection() override = default;
|
||||
|
||||
virtual const ISdBus& getSdBusInterface() const = 0;
|
||||
virtual ISdBus& getSdBusInterface() = 0;
|
||||
[[nodiscard]] virtual const ISdBus& getSdBusInterface() const = 0;
|
||||
[[nodiscard]] virtual ISdBus& getSdBusInterface() = 0;
|
||||
|
||||
[[nodiscard]] virtual Slot addObjectVTable( const std::string& objectPath
|
||||
, const std::string& interfaceName
|
||||
, const sd_bus_vtable* vtable
|
||||
, void* userData ) = 0;
|
||||
|
||||
virtual PlainMessage createPlainMessage() const = 0;
|
||||
virtual MethodCall createMethodCall( const std::string& destination
|
||||
, const std::string& objectPath
|
||||
, const std::string& interfaceName
|
||||
, const std::string& methodName ) const = 0;
|
||||
virtual Signal createSignal( const std::string& objectPath
|
||||
, const std::string& interfaceName
|
||||
, const std::string& signalName ) const = 0;
|
||||
[[nodiscard]] virtual PlainMessage createPlainMessage() const = 0;
|
||||
[[nodiscard]] virtual MethodCall createMethodCall( const std::string& destination
|
||||
, const std::string& objectPath
|
||||
, const std::string& interfaceName
|
||||
, const std::string& methodName ) const = 0;
|
||||
[[nodiscard]] virtual Signal createSignal( const std::string& objectPath
|
||||
, const std::string& interfaceName
|
||||
, const std::string& signalName ) const = 0;
|
||||
|
||||
virtual MethodReply callMethod(const MethodCall& message, uint64_t timeout) = 0;
|
||||
virtual void callMethod(const MethodCall& message, void* callback, void* userData, uint64_t timeout, floating_slot_t) = 0;
|
||||
|
@ -62,11 +62,11 @@ namespace sdbus::internal {
|
||||
|
||||
void addObjectManager() override;
|
||||
void removeObjectManager() override;
|
||||
bool hasObjectManager() const override;
|
||||
[[nodiscard]] bool hasObjectManager() const override;
|
||||
|
||||
sdbus::IConnection& getConnection() const override;
|
||||
const std::string& getObjectPath() const override;
|
||||
Message getCurrentlyProcessedMessage() const override;
|
||||
[[nodiscard]] sdbus::IConnection& getConnection() const override;
|
||||
[[nodiscard]] const std::string& getObjectPath() const override;
|
||||
[[nodiscard]] Message getCurrentlyProcessedMessage() const override;
|
||||
|
||||
private:
|
||||
// A vtable record comprising methods, signals, properties, flags.
|
||||
|
@ -70,9 +70,9 @@ namespace sdbus::internal {
|
||||
, return_slot_t ) override;
|
||||
void unregister() override;
|
||||
|
||||
sdbus::IConnection& getConnection() const override;
|
||||
const std::string& getObjectPath() const override;
|
||||
Message getCurrentlyProcessedMessage() const override;
|
||||
[[nodiscard]] sdbus::IConnection& getConnection() const override;
|
||||
[[nodiscard]] const std::string& getObjectPath() const override;
|
||||
[[nodiscard]] Message getCurrentlyProcessedMessage() const override;
|
||||
|
||||
private:
|
||||
static int sdbus_signal_handler(sd_bus_message *sdbusMessage, void *userData, sd_bus_error *retError);
|
||||
|
Reference in New Issue
Block a user