Implement #104: add getObjectPath() for classes (#105)

* Implement #104: add getObjectPath() for classes

* Implement #104: changes requested in review

Co-authored-by: Christian Schneider <cschneider@radiodata.biz>
This commit is contained in:
ChristianS99
2020-05-28 15:36:58 +02:00
committed by GitHub
parent fb35a9a196
commit ae8849e545
8 changed files with 39 additions and 0 deletions

View File

@ -131,6 +131,14 @@ namespace sdbus {
getObject().unregister();
}
/*!
* @brief Returns object path of the underlying DBus object
*/
const std::string& getObjectPath() const
{
return getObject().getObjectPath();
}
protected:
using base_type = AdaptorInterfaces;
};

View File

@ -435,6 +435,11 @@ namespace sdbus {
* @throws sdbus::Error in case of failure
*/
[[nodiscard]] SignalEmitter emitSignal(const std::string& signalName);
/*!
* @brief Returns object path of the underlying DBus object
*/
virtual const std::string& getObjectPath() const = 0;
};
// Out-of-line member definitions

View File

@ -266,6 +266,11 @@ namespace sdbus {
* @throws sdbus::Error in case of failure
*/
[[nodiscard]] PropertySetter setProperty(const std::string& propertyName);
/*!
* @brief Returns object path of the underlying DBus object
*/
virtual const std::string& getObjectPath() const = 0;
};
/********************************************//**

View File

@ -165,6 +165,14 @@ namespace sdbus {
getProxy().unregister();
}
/*!
* @brief Returns object path of the underlying DBus object
*/
const std::string& getObjectPath() const
{
return getProxy().getObjectPath();
}
protected:
using base_type = ProxyInterfaces;
};

View File

@ -225,6 +225,11 @@ sdbus::IConnection& Object::getConnection() const
return dynamic_cast<sdbus::IConnection&>(connection_);
}
const std::string& Object::getObjectPath() const
{
return objectPath_;
}
const std::vector<sd_bus_vtable>& Object::createInterfaceVTable(InterfaceData& interfaceData)
{
auto& vtable = interfaceData.vtable;

View File

@ -101,6 +101,7 @@ namespace sdbus::internal {
bool hasObjectManager() const override;
sdbus::IConnection& getConnection() const override;
const std::string& getObjectPath() const override;
private:
using InterfaceName = std::string;

View File

@ -198,6 +198,11 @@ void Proxy::unregister()
interfaces_.clear();
}
const std::string& Proxy::getObjectPath() const
{
return objectPath_;
}
int Proxy::sdbus_async_reply_handler(sd_bus_message *sdbusMessage, void *userData, sd_bus_error */*retError*/)
{
auto* asyncCallData = static_cast<AsyncCalls::CallData*>(userData);

View File

@ -60,6 +60,8 @@ namespace sdbus::internal {
void finishRegistration() override;
void unregister() override;
const std::string& getObjectPath() const override;
private:
class SyncCallReplyData
{