sdbus-c++: include/sdbus-c++/IObject.h Source File

sdbus-c++ 1.3.0 High-level C++ D-Bus library based on systemd D-Bus implementation

Loading...
Searching...
No Matches
IObject.h
Go to the documentation of this file.
1
27#ifndef SDBUS_CXX_IOBJECT_H_
28#define SDBUS_CXX_IOBJECT_H_
29
30#include <sdbus-c++/ConvenienceApiClasses.h>
31#include <sdbus-c++/TypeTraits.h>
32#include <sdbus-c++/Flags.h>
33#include <functional>
34#include <string>
35#include <memory>
36#include <vector>
37
38// Forward declarations
39namespace sdbus {
40 class Signal;
41 class IConnection;
42}
43
44namespace sdbus {
45
46 /********************************************/
59 class IObject
60 {
61 public:
62 virtual ~IObject() = default;
63
76 virtual void registerMethod( const std::string& interfaceName
77 , std::string methodName
78 , std::string inputSignature
79 , std::string outputSignature
80 , method_callback methodCallback
81 , Flags flags = {} ) = 0;
82
102 virtual void registerMethod( const std::string& interfaceName
103 , std::string methodName
104 , std::string inputSignature
105 , const std::vector<std::string>& inputNames
106 , std::string outputSignature
107 , const std::vector<std::string>& outputNames
108 , method_callback methodCallback
109 , Flags flags = {} ) = 0;
110
121 virtual void registerSignal( const std::string& interfaceName
122 , std::string signalName
123 , std::string signature
124 , Flags flags = {} ) = 0;
125
142 virtual void registerSignal( const std::string& interfaceName
143 , std::string signalName
144 , std::string signature
145 , const std::vector<std::string>& paramNames
146 , Flags flags = {} ) = 0;
147
159 virtual void registerProperty( const std::string& interfaceName
160 , std::string propertyName
161 , std::string signature
162 , property_get_callback getCallback
163 , Flags flags = {} ) = 0;
164
177 virtual void registerProperty( const std::string& interfaceName
178 , std::string propertyName
179 , std::string signature
180 , property_get_callback getCallback
181 , property_set_callback setCallback
182 , Flags flags = {} ) = 0;
183
192 virtual void setInterfaceFlags(const std::string& interfaceName, Flags flags) = 0;
193
202 virtual void finishRegistration() = 0;
203
214 virtual void unregister() = 0;
215
229 virtual Signal createSignal(const std::string& interfaceName, const std::string& signalName) = 0;
230
240 virtual void emitSignal(const sdbus::Signal& message) = 0;
241
250 virtual void emitPropertiesChangedSignal(const std::string& interfaceName, const std::vector<std::string>& propNames) = 0;
251
259 virtual void emitPropertiesChangedSignal(const std::string& interfaceName) = 0;
260
273 virtual void emitInterfacesAddedSignal() = 0;
274
286 virtual void emitInterfacesAddedSignal(const std::vector<std::string>& interfaces) = 0;
287
297 virtual void emitInterfacesRemovedSignal() = 0;
298
310 virtual void emitInterfacesRemovedSignal(const std::vector<std::string>& interfaces) = 0;
311
321 virtual void addObjectManager() = 0;
322
328 virtual void removeObjectManager() = 0;
329
334 virtual bool hasObjectManager() const = 0;
335
341 virtual sdbus::IConnection& getConnection() const = 0;
342
361 [[nodiscard]] MethodRegistrator registerMethod(const std::string& methodName);
362
380 [[nodiscard]] SignalRegistrator registerSignal(const std::string& signalName);
381
399 [[nodiscard]] PropertyRegistrator registerProperty(const std::string& propertyName);
400
416 [[nodiscard]] InterfaceFlagsSetter setInterfaceFlags(const std::string& interfaceName);
417
437 [[nodiscard]] SignalEmitter emitSignal(const std::string& signalName);
438
442 virtual const std::string& getObjectPath() const = 0;
443
458 virtual const Message* getCurrentlyProcessedMessage() const = 0;
459 };
460
461 // Out-of-line member definitions
462
463 inline MethodRegistrator IObject::registerMethod(const std::string& methodName)
464 {
465 return MethodRegistrator(*this, methodName);
466 }
467
468 inline SignalRegistrator IObject::registerSignal(const std::string& signalName)
469 {
470 return SignalRegistrator(*this, signalName);
471 }
472
473 inline PropertyRegistrator IObject::registerProperty(const std::string& propertyName)
474 {
475 return PropertyRegistrator(*this, propertyName);
476 }
477
478 inline InterfaceFlagsSetter IObject::setInterfaceFlags(const std::string& interfaceName)
479 {
480 return InterfaceFlagsSetter(*this, interfaceName);
481 }
482
483 inline SignalEmitter IObject::emitSignal(const std::string& signalName)
484 {
485 return SignalEmitter(*this, signalName);
486 }
487
506 [[nodiscard]] std::unique_ptr<sdbus::IObject> createObject(sdbus::IConnection& connection, std::string objectPath);
507
508}
509
510#include <sdbus-c++/ConvenienceApiClasses.inl>
511
512#endif /* SDBUS_CXX_IOBJECT_H_ */
ConvenienceApiClasses.h
ConvenienceApiClasses.inl
Flags.h
sdbus::createObject
std::unique_ptr< sdbus::IObject > createObject(sdbus::IConnection &connection, std::string objectPath)
Creates instance representing a D-Bus object.
TypeTraits.h
sdbus::Flags
Definition Flags.h:37
sdbus::IConnection
Definition IConnection.h:50
sdbus::IObject
Definition IObject.h:60
sdbus::IObject::hasObjectManager
virtual bool hasObjectManager() const =0
Tests whether ObjectManager interface is added at the path of this D-Bus object.
sdbus::IObject::setInterfaceFlags
virtual void setInterfaceFlags(const std::string &interfaceName, Flags flags)=0
Sets flags for a given interface.
sdbus::IObject::getObjectPath
virtual const std::string & getObjectPath() const =0
Returns object path of the underlying DBus object.
sdbus::IObject::registerSignal
virtual void registerSignal(const std::string &interfaceName, std::string signalName, std::string signature, const std::vector< std::string > &paramNames, Flags flags={})=0
Registers signal that the object will emit on D-Bus.
sdbus::IObject::removeObjectManager
virtual void removeObjectManager()=0
Removes an ObjectManager interface from the path of this D-Bus object.
sdbus::IObject::registerProperty
virtual void registerProperty(const std::string &interfaceName, std::string propertyName, std::string signature, property_get_callback getCallback, property_set_callback setCallback, Flags flags={})=0
Registers read/write property that the object will provide on D-Bus.
sdbus::IObject::emitInterfacesRemovedSignal
virtual void emitInterfacesRemovedSignal()=0
Emits InterfacesRemoved signal on this object path.
sdbus::IObject::emitSignal
virtual void emitSignal(const sdbus::Signal &message)=0
Emits signal for this object path.
sdbus::IObject::getCurrentlyProcessedMessage
virtual const Message * getCurrentlyProcessedMessage() const =0
Provides currently processed D-Bus message.
sdbus::IObject::registerProperty
virtual void registerProperty(const std::string &interfaceName, std::string propertyName, std::string signature, property_get_callback getCallback, Flags flags={})=0
Registers read-only property that the object will provide on D-Bus.
sdbus::IObject::registerMethod
virtual void registerMethod(const std::string &interfaceName, std::string methodName, std::string inputSignature, std::string outputSignature, method_callback methodCallback, Flags flags={})=0
Registers method that the object will provide on D-Bus.
sdbus::IObject::emitInterfacesAddedSignal
virtual void emitInterfacesAddedSignal(const std::vector< std::string > &interfaces)=0
Emits InterfacesAdded signal on this object path.
sdbus::IObject::createSignal
virtual Signal createSignal(const std::string &interfaceName, const std::string &signalName)=0
Creates a signal message.
sdbus::IObject::addObjectManager
virtual void addObjectManager()=0
Adds an ObjectManager interface at the path of this D-Bus object.
sdbus::IObject::getConnection
virtual sdbus::IConnection & getConnection() const =0
Provides D-Bus connection used by the object.
sdbus::IObject::registerSignal
virtual void registerSignal(const std::string &interfaceName, std::string signalName, std::string signature, Flags flags={})=0
Registers signal that the object will emit on D-Bus.
sdbus::IObject::registerMethod
virtual void registerMethod(const std::string &interfaceName, std::string methodName, std::string inputSignature, const std::vector< std::string > &inputNames, std::string outputSignature, const std::vector< std::string > &outputNames, method_callback methodCallback, Flags flags={})=0
Registers method that the object will provide on D-Bus.
sdbus::IObject::emitInterfacesAddedSignal
virtual void emitInterfacesAddedSignal()=0
Emits InterfacesAdded signal on this object path.
sdbus::IObject::finishRegistration
virtual void finishRegistration()=0
Finishes object API registration and publishes the object on the bus.
sdbus::IObject::emitInterfacesRemovedSignal
virtual void emitInterfacesRemovedSignal(const std::vector< std::string > &interfaces)=0
Emits InterfacesRemoved signal on this object path.
sdbus::IObject::emitPropertiesChangedSignal
virtual void emitPropertiesChangedSignal(const std::string &interfaceName)=0
Emits PropertyChanged signal for all properties on a given interface of this object path.
sdbus::IObject::emitPropertiesChangedSignal
virtual void emitPropertiesChangedSignal(const std::string &interfaceName, const std::vector< std::string > &propNames)=0
Emits PropertyChanged signal for specified properties under a given interface of this object path.
sdbus::IObject::unregister
virtual void unregister()=0
Unregisters object's API and removes object from the bus.
sdbus::InterfaceFlagsSetter
Definition ConvenienceApiClasses.h:130
sdbus::Message
Definition Message.h:76
sdbus::MethodRegistrator
Definition ConvenienceApiClasses.h:52
sdbus::PropertyRegistrator
Definition ConvenienceApiClasses.h:105
sdbus::SignalEmitter
Definition ConvenienceApiClasses.h:149
sdbus::SignalRegistrator
Definition ConvenienceApiClasses.h:82
sdbus::Signal
Definition Message.h:270