openthread-br  0.3.0-72c0388
Public Types | Public Member Functions | List of all members
otbr::DBus::DBusObject Class Reference

#include <src/dbus/server/dbus_object.hpp>

Inheritance diagram for otbr::DBus::DBusObject:
NonCopyable otbr::DBus::DBusThreadObject

Public Types

using MethodHandlerType = std::function< void(DBusRequest &)>
 
using PropertyHandlerType = std::function< otError(DBusMessageIter &)>
 

Public Member Functions

 DBusObject (DBusConnection *aConnection, const std::string &aObjectPath)
 
virtual otbrError Init (void)
 
void RegisterMethod (const std::string &aInterfaceName, const std::string &aMethodName, const MethodHandlerType &aHandler)
 
virtual void RegisterGetPropertyHandler (const std::string &aInterfaceName, const std::string &aPropertyName, const PropertyHandlerType &aHandler)
 
virtual void RegisterSetPropertyHandler (const std::string &aInterfaceName, const std::string &aPropertyName, const PropertyHandlerType &aHandler)
 
template<typename... FieldTypes>
otbrError Signal (const std::string &aInterfaceName, const std::string &aSignalName, const std::tuple< FieldTypes... > &aArgs)
 
template<typename ValueType >
otbrError SignalPropertyChanged (const std::string &aInterfaceName, const std::string &aPropertyName, const ValueType &aValue)
 
virtual ~DBusObject (void)
 
void Flush (void)
 

Detailed Description

This class is a base class for implementing a d-bus object.

Constructor & Destructor Documentation

◆ DBusObject()

otbr::DBus::DBusObject::DBusObject ( DBusConnection *  aConnection,
const std::string &  aObjectPath 
)

The constructor of a d-bus object.

Parameters
[in]aConnectionThe dbus-connection the object bounds to.
[in]aObjectPathThe path of the object.

◆ ~DBusObject()

otbr::DBus::DBusObject::~DBusObject ( void  )
virtual

The destructor of a d-bus object.

Member Function Documentation

◆ Flush()

void otbr::DBus::DBusObject::Flush ( void  )

Sends all outgoing messages, blocks until the message queue is empty.

◆ Init()

otbrError otbr::DBus::DBusObject::Init ( void  )
virtual

This method initializes the d-bus object.

This method will register the object to the d-bus library.

Return values
OTBR_ERROR_NONESuccessfully registered the object.
OTBR_ERROR_DBUSFailed to ragister an object.

Reimplemented in otbr::DBus::DBusThreadObject.

◆ RegisterGetPropertyHandler()

void otbr::DBus::DBusObject::RegisterGetPropertyHandler ( const std::string &  aInterfaceName,
const std::string &  aPropertyName,
const PropertyHandlerType &  aHandler 
)
virtual

This method registers the get handler for a property.

Parameters
[in]aInterfaceNameThe interface name.
[in]aPropertyNameThe property name.
[in]aHandlerThe method handler.

Reimplemented in otbr::DBus::DBusThreadObject.

◆ RegisterMethod()

void otbr::DBus::DBusObject::RegisterMethod ( const std::string &  aInterfaceName,
const std::string &  aMethodName,
const MethodHandlerType &  aHandler 
)

This method registers the method handler.

Parameters
[in]aInterfaceNameThe interface name.
[in]aMethodNameThe method name.
[in]aHandlerThe method handler.

◆ RegisterSetPropertyHandler()

void otbr::DBus::DBusObject::RegisterSetPropertyHandler ( const std::string &  aInterfaceName,
const std::string &  aPropertyName,
const PropertyHandlerType &  aHandler 
)
virtual

This method registers the set handler for a property.

Parameters
[in]aInterfaceNameThe interface name.
[in]aPropertyNameThe property name.
[in]aHandlerThe method handler.

◆ Signal()

template<typename... FieldTypes>
otbrError otbr::DBus::DBusObject::Signal ( const std::string &  aInterfaceName,
const std::string &  aSignalName,
const std::tuple< FieldTypes... > &  aArgs 
)
inline

This method sends a signal.

Parameters
[in]aInterfaceNameThe interface name.
[in]aSignalNameThe signal name.
[in]aArgsThe tuple to be encoded into the signal.
Return values
OTBR_ERROR_NONESignal successfully sent.
OTBR_ERROR_DBUSFailed to send the signal.

◆ SignalPropertyChanged()

template<typename ValueType >
otbrError otbr::DBus::DBusObject::SignalPropertyChanged ( const std::string &  aInterfaceName,
const std::string &  aPropertyName,
const ValueType &  aValue 
)
inline

This method sends a property changed signal.

Parameters
[in]aInterfaceNameThe interface name.
[in]aPropertyNameThe property name.
[in]aValueNew value of the property.
Return values
OTBR_ERROR_NONESignal successfully sent.
OTBR_ERROR_DBUSFailed to send the signal.

The documentation for this class was generated from the following files: