forked from Kistler-Group/sdbus-cpp
proxy: add IProxy::getConnection() (#179)
This provides access to the proxy's bus connection so code using the proxy does not need to store an external reference to it. A matching function is already available in IObject.
This commit is contained in:
@ -267,6 +267,13 @@ namespace sdbus {
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] PropertySetter setProperty(const std::string& propertyName);
|
[[nodiscard]] PropertySetter setProperty(const std::string& propertyName);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Provides D-Bus connection used by the proxy
|
||||||
|
*
|
||||||
|
* @return Reference to the D-Bus connection
|
||||||
|
*/
|
||||||
|
virtual sdbus::IConnection& getConnection() const = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns object path of the underlying DBus object
|
* @brief Returns object path of the underlying DBus object
|
||||||
*/
|
*/
|
||||||
|
@ -199,6 +199,11 @@ void Proxy::unregister()
|
|||||||
interfaces_.clear();
|
interfaces_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sdbus::IConnection& Proxy::getConnection() const
|
||||||
|
{
|
||||||
|
return dynamic_cast<sdbus::IConnection&>(*connection_);
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& Proxy::getObjectPath() const
|
const std::string& Proxy::getObjectPath() const
|
||||||
{
|
{
|
||||||
return objectPath_;
|
return objectPath_;
|
||||||
|
@ -60,6 +60,7 @@ namespace sdbus::internal {
|
|||||||
void finishRegistration() override;
|
void finishRegistration() override;
|
||||||
void unregister() override;
|
void unregister() override;
|
||||||
|
|
||||||
|
sdbus::IConnection& getConnection() const override;
|
||||||
const std::string& getObjectPath() const override;
|
const std::string& getObjectPath() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user