refactor: add nodiscard attribute for some functions

This commit is contained in:
Stanislav Angelovic
2023-12-30 19:57:48 +01:00
parent 18aece04d5
commit f7afe3d1b1
5 changed files with 17 additions and 17 deletions

View File

@ -57,7 +57,7 @@ namespace sdbus {
object_.addVTable(std::move(interfaceName), std::move(vtable_)); object_.addVTable(std::move(interfaceName), std::move(vtable_));
} }
inline Slot VTableAdder::forInterface(std::string interfaceName, return_slot_t) [[nodiscard]] inline Slot VTableAdder::forInterface(std::string interfaceName, return_slot_t)
{ {
return object_.addVTable(std::move(interfaceName), std::move(vtable_), return_slot); return object_.addVTable(std::move(interfaceName), std::move(vtable_), return_slot);
} }
@ -311,7 +311,7 @@ namespace sdbus {
} }
template <typename _Function> template <typename _Function>
inline Slot SignalSubscriber::call(_Function&& callback, return_slot_t) [[nodiscard]] inline Slot SignalSubscriber::call(_Function&& callback, return_slot_t)
{ {
assert(!interfaceName_.empty()); // onInterface() must be placed/called prior to this function assert(!interfaceName_.empty()); // onInterface() must be placed/called prior to this function

View File

@ -82,7 +82,7 @@ namespace sdbus {
* *
* @throws sdbus::Error in case of failure * @throws sdbus::Error in case of failure
*/ */
virtual std::string getUniqueName() const = 0; [[nodiscard]] virtual std::string getUniqueName() const = 0;
/*! /*!
* @brief Enters I/O event loop on this bus connection * @brief Enters I/O event loop on this bus connection
@ -225,7 +225,7 @@ namespace sdbus {
* *
* @return Currently processed D-Bus message * @return Currently processed D-Bus message
*/ */
virtual Message getCurrentlyProcessedMessage() const = 0; [[nodiscard]] virtual Message getCurrentlyProcessedMessage() const = 0;
/*! /*!
* @brief Sets general method call timeout * @brief Sets general method call timeout
@ -256,7 +256,7 @@ namespace sdbus {
* *
* @throws sdbus::Error in case of failure * @throws sdbus::Error in case of failure
*/ */
virtual uint64_t getMethodCallTimeout() const = 0; [[nodiscard]] virtual uint64_t getMethodCallTimeout() const = 0;
/*! /*!
* @brief Adds an ObjectManager at the specified D-Bus object path * @brief Adds an ObjectManager at the specified D-Bus object path

View File

@ -140,7 +140,7 @@ namespace sdbus {
* *
* @throws sdbus::Error in case of failure * @throws sdbus::Error in case of failure
*/ */
virtual Slot addVTable(std::string interfaceName, std::vector<VTableItem> vtable, return_slot_t) = 0; [[nodiscard]] virtual Slot addVTable(std::string interfaceName, std::vector<VTableItem> vtable, return_slot_t) = 0;
/*! /*!
* @brief A little more convenient overload of addVTable() above * @brief A little more convenient overload of addVTable() above
@ -187,7 +187,7 @@ namespace sdbus {
* *
* @throws sdbus::Error in case of failure * @throws sdbus::Error in case of failure
*/ */
virtual Signal createSignal(const std::string& interfaceName, const std::string& signalName) = 0; [[nodiscard]] virtual Signal createSignal(const std::string& interfaceName, const std::string& signalName) = 0;
/*! /*!
* @brief Emits signal for this object path * @brief Emits signal for this object path
@ -288,14 +288,14 @@ namespace sdbus {
* @brief Tests whether ObjectManager interface is added at the path of this D-Bus object * @brief Tests whether ObjectManager interface is added at the path of this D-Bus object
* @return True if ObjectManager interface is there, false otherwise * @return True if ObjectManager interface is there, false otherwise
*/ */
virtual bool hasObjectManager() const = 0; [[nodiscard]] virtual bool hasObjectManager() const = 0;
/*! /*!
* @brief Provides D-Bus connection used by the object * @brief Provides D-Bus connection used by the object
* *
* @return Reference to the D-Bus connection * @return Reference to the D-Bus connection
*/ */
virtual sdbus::IConnection& getConnection() const = 0; [[nodiscard]] virtual sdbus::IConnection& getConnection() const = 0;
/*! /*!
* @brief Emits signal on D-Bus * @brief Emits signal on D-Bus
@ -321,7 +321,7 @@ namespace sdbus {
/*! /*!
* @brief Returns object path of the underlying DBus object * @brief Returns object path of the underlying DBus object
*/ */
virtual const std::string& getObjectPath() const = 0; [[nodiscard]] virtual const std::string& getObjectPath() const = 0;
/*! /*!
* @brief Provides access to the currently processed D-Bus message * @brief Provides access to the currently processed D-Bus message
@ -336,7 +336,7 @@ namespace sdbus {
* *
* @return Currently processed D-Bus message * @return Currently processed D-Bus message
*/ */
virtual Message getCurrentlyProcessedMessage() const = 0; [[nodiscard]] virtual Message getCurrentlyProcessedMessage() const = 0;
}; };
// Out-of-line member definitions // Out-of-line member definitions

View File

@ -80,7 +80,7 @@ namespace sdbus {
* *
* @throws sdbus::Error in case of failure * @throws sdbus::Error in case of failure
*/ */
virtual MethodCall createMethodCall(const std::string& interfaceName, const std::string& methodName) = 0; [[nodiscard]] virtual MethodCall createMethodCall(const std::string& interfaceName, const std::string& methodName) = 0;
/*! /*!
* @brief Calls method on the remote D-Bus object * @brief Calls method on the remote D-Bus object
@ -107,7 +107,7 @@ namespace sdbus {
* *
* Note: To avoid messing with messages, use API on a higher level of abstraction defined below. * Note: To avoid messing with messages, use API on a higher level of abstraction defined below.
* *
* @throws sdbus::Error in case of failure * @throws sdbus::Error in case of failure (also in case the remote function returned an error)
*/ */
virtual MethodReply callMethod(const MethodCall& message, uint64_t timeout = 0) = 0; virtual MethodReply callMethod(const MethodCall& message, uint64_t timeout = 0) = 0;
@ -426,12 +426,12 @@ namespace sdbus {
* *
* @return Reference to the D-Bus connection * @return Reference to the D-Bus connection
*/ */
virtual sdbus::IConnection& getConnection() const = 0; [[nodiscard]] virtual sdbus::IConnection& getConnection() const = 0;
/*! /*!
* @brief Returns object path of the underlying DBus object * @brief Returns object path of the underlying DBus object
*/ */
virtual const std::string& getObjectPath() const = 0; [[nodiscard]] virtual const std::string& getObjectPath() const = 0;
/*! /*!
* @brief Provides access to the currently processed D-Bus message * @brief Provides access to the currently processed D-Bus message
@ -446,7 +446,7 @@ namespace sdbus {
* *
* @return Currently processed D-Bus message * @return Currently processed D-Bus message
*/ */
virtual Message getCurrentlyProcessedMessage() const = 0; [[nodiscard]] virtual Message getCurrentlyProcessedMessage() const = 0;
}; };
/********************************************//** /********************************************//**

View File

@ -73,7 +73,7 @@ namespace sdbus::internal {
virtual MethodReply callMethod(const MethodCall& message, uint64_t timeout) = 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; virtual void callMethod(const MethodCall& message, void* callback, void* userData, uint64_t timeout, floating_slot_t) = 0;
virtual Slot callMethod(const MethodCall& message, void* callback, void* userData, uint64_t timeout) = 0; [[nodiscard]] virtual Slot callMethod(const MethodCall& message, void* callback, void* userData, uint64_t timeout) = 0;
virtual void emitPropertiesChangedSignal( const std::string& objectPath virtual void emitPropertiesChangedSignal( const std::string& objectPath
, const std::string& interfaceName , const std::string& interfaceName