Add support for PropertyChanged signal on server side

This commit is contained in:
Stanislav Angelovič
2019-06-03 22:02:15 +02:00
committed by GitHub
parent 38552483ca
commit 01e2a7a570
13 changed files with 140 additions and 19 deletions
+19
View File
@@ -187,6 +187,25 @@ namespace sdbus {
*/
virtual void emitSignal(const sdbus::Signal& message) = 0;
/*!
* @brief Emits PropertyChanged signal for specified properties under a given interface
*
* @param[in] interfaceName Name of an interface that properties belong to
* @param[in] propNames Names of properties that will be included in the PropertiesChanged signal
*
* @throws sdbus::Error in case of failure
*/
virtual void emitPropertiesChangedSignal(const std::string& interfaceName, const std::vector<std::string>& propNames) = 0;
/*!
* @brief Emits PropertyChanged signal for all properties of a given interface
*
* @param[in] interfaceName Name of an interface
*
* @throws sdbus::Error in case of failure
*/
virtual void emitPropertiesChangedSignal(const std::string& interfaceName) = 0;
/*!
* @brief Provides D-Bus connection used by the object
*
+28 -2
View File
@@ -178,8 +178,34 @@ namespace sdbus {
};
// Adaptors for the above-listed standard D-Bus interfaces are not necessary because the functionality
// is provided automatically for each D-Bus object by underlying libsystemd (with the exception of
// object manager which is provided but needs to be added explicitly, see IObject::addObjectManager).
// is provided by underlying libsystemd implementation. The exception is Properties_adaptor and
// ObjectManager_adaptor, which provide convenience functionality to emit signals.
class Properties_adaptor
{
static constexpr const char* INTERFACE_NAME = "org.freedesktop.DBus.Properties";
protected:
Properties_adaptor(sdbus::IObject& object)
: object_(object)
{
}
public:
void emitPropertiesChangedSignal(const std::string& interfaceName, const std::vector<std::string>& properties)
{
object_.emitPropertiesChangedSignal(interfaceName, properties);
}
void emitPropertiesChangedSignal(const std::string& interfaceName)
{
object_.emitPropertiesChangedSignal(interfaceName);
}
private:
sdbus::IObject& object_;
};
}
#endif /* SDBUS_CXX_STANDARDINTERFACES_H_ */