27#ifndef SDBUS_CXX_STANDARDINTERFACES_H_
28#define SDBUS_CXX_STANDARDINTERFACES_H_
43 static inline const char* INTERFACE_NAME =
"org.freedesktop.DBus.Peer";
65 m_proxy.
callMethod(
"Ping").onInterface(INTERFACE_NAME);
68 std::string GetMachineId()
70 std::string machineUUID;
71 m_proxy.
callMethod(
"GetMachineId").onInterface(INTERFACE_NAME).storeResultsTo(machineUUID);
82 static inline const char* INTERFACE_NAME =
"org.freedesktop.DBus.Introspectable";
102 std::string Introspect()
105 m_proxy.
callMethod(
"Introspect").onInterface(INTERFACE_NAME).storeResultsTo(xml);
116 static inline const char* INTERFACE_NAME =
"org.freedesktop.DBus.Properties";
135 .onInterface(INTERFACE_NAME)
137 ,
const std::map<PropertyName, sdbus::Variant>& changedProperties
138 ,
const std::vector<PropertyName>& invalidatedProperties )
140 this->onPropertiesChanged(interfaceName, changedProperties, invalidatedProperties);
144 virtual void onPropertiesChanged(
const InterfaceName& interfaceName
145 ,
const std::map<PropertyName, sdbus::Variant>& changedProperties
146 ,
const std::vector<PropertyName>& invalidatedProperties ) = 0;
151 return m_proxy.
getProperty(propertyName).onInterface(interfaceName);
154 sdbus::Variant Get(std::string_view interfaceName, std::string_view propertyName)
156 return m_proxy.
getProperty(propertyName).onInterface(interfaceName);
159 template <
typename _Function>
162 return m_proxy.
getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
165 template <
typename _Function>
168 return m_proxy.
getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
173 return m_proxy.
getPropertyAsync(propertyName).onInterface(interfaceName).getResultAsFuture();
176 template <
typename _Function>
177 PendingAsyncCall GetAsync(std::string_view interfaceName, std::string_view propertyName, _Function&& callback)
179 return m_proxy.
getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
182 template <
typename _Function>
183 [[nodiscard]] Slot GetAsync(std::string_view interfaceName, std::string_view propertyName, _Function&& callback,
return_slot_t)
185 return m_proxy.
getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
188 std::future<sdbus::Variant> GetAsync(std::string_view interfaceName, std::string_view propertyName,
with_future_t)
190 return m_proxy.
getPropertyAsync(propertyName).onInterface(interfaceName).getResultAsFuture();
195 m_proxy.
setProperty(propertyName).onInterface(interfaceName).toValue(value);
198 void Set(std::string_view interfaceName,
const std::string_view propertyName,
const sdbus::Variant& value)
200 m_proxy.
setProperty(propertyName).onInterface(interfaceName).toValue(value);
205 m_proxy.
setProperty(propertyName).onInterface(interfaceName).toValue(value, dont_expect_reply);
210 m_proxy.
setProperty(propertyName).onInterface(interfaceName).toValue(value, dont_expect_reply);
213 template <
typename _Function>
216 return m_proxy.
setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback));
219 template <
typename _Function>
222 return m_proxy.
setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
227 return m_proxy.
setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).getResultAsFuture();
230 template <
typename _Function>
233 return m_proxy.
setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback));
236 template <
typename _Function>
237 [[nodiscard]] Slot SetAsync(std::string_view interfaceName, std::string_view propertyName,
const sdbus::Variant& value, _Function&& callback,
return_slot_t)
239 return m_proxy.
setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
242 std::future<void> SetAsync(std::string_view interfaceName, std::string_view propertyName,
const sdbus::Variant& value,
with_future_t)
244 return m_proxy.
setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).getResultAsFuture();
247 std::map<PropertyName, sdbus::Variant> GetAll(
const InterfaceName& interfaceName)
252 std::map<PropertyName, sdbus::Variant> GetAll(std::string_view interfaceName)
257 template <
typename _Function>
260 return m_proxy.
getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
263 template <
typename _Function>
266 return m_proxy.
getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
274 template <
typename _Function>
275 PendingAsyncCall GetAllAsync(std::string_view interfaceName, _Function&& callback)
277 return m_proxy.
getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
280 template <
typename _Function>
281 [[nodiscard]] Slot GetAllAsync(std::string_view interfaceName, _Function&& callback,
return_slot_t)
283 return m_proxy.
getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
286 std::future<std::map<PropertyName, sdbus::Variant>> GetAllAsync(std::string_view interfaceName,
with_future_t)
298 static inline const char* INTERFACE_NAME =
"org.freedesktop.DBus.ObjectManager";
317 .onInterface(INTERFACE_NAME)
319 ,
const std::map<
sdbus::InterfaceName, std::map<PropertyName, sdbus::Variant>>& interfacesAndProperties )
321 this->onInterfacesAdded(objectPath, interfacesAndProperties);
326 .onInterface(INTERFACE_NAME)
328 ,
const std::vector<sdbus::InterfaceName>& interfaces )
330 this->onInterfacesRemoved(objectPath, interfaces);
335 ,
const std::map<
sdbus::InterfaceName, std::map<PropertyName, sdbus::Variant>>& interfacesAndProperties) = 0;
337 ,
const std::vector<sdbus::InterfaceName>& interfaces) = 0;
340 std::map<sdbus::ObjectPath, std::map<sdbus::InterfaceName, std::map<PropertyName, sdbus::Variant>>> GetManagedObjects()
342 std::map<sdbus::ObjectPath, std::map<sdbus::InterfaceName, std::map<PropertyName, sdbus::Variant>>> objectsInterfacesAndProperties;
343 m_proxy.
callMethod(
"GetManagedObjects").onInterface(INTERFACE_NAME).storeResultsTo(objectsInterfacesAndProperties);
344 return objectsInterfacesAndProperties;
347 template <
typename _Function>
350 return m_proxy.
callMethodAsync(
"GetManagedObjects").onInterface(INTERFACE_NAME).uponReplyInvoke(std::forward<_Function>(callback));
353 template <
typename _Function>
354 [[nodiscard]] Slot GetManagedObjectsAsync(_Function&& callback,
return_slot_t)
356 return m_proxy.
callMethodAsync(
"GetManagedObjects").onInterface(INTERFACE_NAME).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
359 std::future<std::map<sdbus::ObjectPath, std::map<sdbus::InterfaceName, std::map<PropertyName, sdbus::Variant>>>> GetManagedObjectsAsync(
with_future_t)
361 return m_proxy.
callMethodAsync(
"GetManagedObjects").onInterface(INTERFACE_NAME).getResultAsFuture<std::map<sdbus::ObjectPath, std::map<sdbus::InterfaceName, std::map<PropertyName, sdbus::Variant>>>>();
375 static inline const char* INTERFACE_NAME =
"org.freedesktop.DBus.Properties";
389 void registerAdaptor()
394 void emitPropertiesChangedSignal(
const InterfaceName& interfaceName,
const std::vector<PropertyName>& properties)
399 void emitPropertiesChangedSignal(
const char* interfaceName,
const std::vector<PropertyName>& properties)
404 void emitPropertiesChangedSignal(
const InterfaceName& interfaceName)
409 void emitPropertiesChangedSignal(
const char* interfaceName)
430 static inline const char* INTERFACE_NAME =
"org.freedesktop.DBus.ObjectManager";
444 void registerAdaptor()
479 void registerAdaptor()
virtual void emitInterfacesRemovedSignal()=0
Emits InterfacesRemoved signal on this object path.
virtual void emitPropertiesChangedSignal(const InterfaceName &interfaceName, const std::vector< PropertyName > &propNames)=0
Emits PropertyChanged signal for specified properties under a given interface of this object path.
virtual void addObjectManager()=0
Adds an ObjectManager interface at the path of this D-Bus object.
virtual void emitInterfacesAddedSignal()=0
Emits InterfacesAdded signal on this object path.
PropertyGetter getProperty(const PropertyName &propertyName)
Gets value of a property of the D-Bus object.
Definition: IProxy.h:789
AsyncPropertyGetter getPropertyAsync(const PropertyName &propertyName)
Gets value of a property of the D-Bus object asynchronously.
Definition: IProxy.h:799
AsyncAllPropertiesGetter getAllPropertiesAsync()
Gets values of all properties of the D-Bus object asynchronously.
Definition: IProxy.h:834
PropertySetter setProperty(const PropertyName &propertyName)
Sets value of a property of the D-Bus object.
Definition: IProxy.h:809
MethodInvoker callMethod(const MethodName &methodName)
Calls method on the D-Bus object.
Definition: IProxy.h:744
AsyncMethodInvoker callMethodAsync(const MethodName &methodName)
Calls method on the D-Bus object asynchronously.
Definition: IProxy.h:759
SignalSubscriber uponSignal(const SignalName &signalName)
Registers signal handler for a given signal of the D-Bus object.
Definition: IProxy.h:774
AllPropertiesGetter getAllProperties()
Gets values of all properties of the D-Bus object.
Definition: IProxy.h:829
AsyncPropertySetter setPropertyAsync(const PropertyName &propertyName)
Sets value of a property of the D-Bus object asynchronously.
Definition: IProxy.h:819
Definition: StandardInterfaces.h:81
Managed Object Convenience Adaptor.
Definition: StandardInterfaces.h:465
void emitInterfacesRemovedSignal()
Emits InterfacesRemoved signal for this object path.
Definition: StandardInterfaces.h:509
void emitInterfacesAddedSignal()
Emits InterfacesAdded signal for this object path.
Definition: StandardInterfaces.h:489
void emitInterfacesAddedSignal(const std::vector< sdbus::InterfaceName > &interfaces)
Emits InterfacesAdded signal for this object path.
Definition: StandardInterfaces.h:499
void emitInterfacesRemovedSignal(const std::vector< InterfaceName > &interfaces)
Emits InterfacesRemoved signal for this object path.
Definition: StandardInterfaces.h:519
Object Manager Convenience Adaptor.
Definition: StandardInterfaces.h:429
Definition: StandardInterfaces.h:297
Definition: StandardInterfaces.h:42
Definition: StandardInterfaces.h:374
Definition: StandardInterfaces.h:115
Definition: TypeTraits.h:107
Definition: TypeTraits.h:88
Definition: TypeTraits.h:104