DBus::Message Class Referenceabstract

This class represents a basic DBus message and also serves as a base class for the specialized message types (call, return, signal, error). More...

#include <message.h>

Inheritance diagram for DBus::Message:

Public Member Functions

virtual ~Message ()
 
bool operator== (const Message &other)
 
bool is_valid () const
 
void invalidate ()
 
 operator bool () const
 
uint32_t serial () const
 
virtual MessageType type () const =0
 
void set_auto_start (bool auto_start)
 
bool auto_start ()
 Returns true if the bus is allowed to start an owner for this message's destination if it is not running. More...
 
bool set_destination (const std::string &s)
 Set the destination of this message. More...
 
std::string destination () const
 
std::string sender () const
 
Signature signature () const
 
template<typename T >
MessageIterator operator>> (T &value) const
 
template<typename T >
MessageAppendIterator operator<< (const T &value)
 
MessageIterator begin () const
 
MessageIterator end () const
 
MessageAppendIterator append ()
 
bool serialize_to_vector (std::vector< uint8_t > *vec, uint32_t serial) const
 Serialize this message to the given vector. More...
 
Variant header_field (MessageHeaderFields field) const
 Returns the given header field(if it exists), otherwise returns a default constructed variant. More...
 
uint8_t flags () const
 The message flags, as the marshaled byte. More...
 
Variant set_header_field (MessageHeaderFields field, Variant value)
 Set the given header field. More...
 
Endianess endianess () const
 
const std::vector< int > & filedescriptors () const
 

Static Public Member Functions

static std::shared_ptr< Messagecreate_from_data (uint8_t *data, uint32_t data_len, std::vector< int > fds=std::vector< int >())
 

Protected Member Functions

 Message ()
 
void append_signature (std::string toappend)
 
void clear_sig_and_data ()
 Clears the signature and the data, so you can re-append data. More...
 
void set_flags (uint8_t flags)
 

Private Member Functions

std::vector< uint8_t > * body ()
 
const std::vector< uint8_t > * body () const
 
void add_filedescriptor (int fd)
 
uint32_t filedescriptors_size () const
 
int filedescriptor_at_location (int location) const
 
 DBUS_CXX_PROPAGATE_CONST (std::unique_ptr< priv_data >) m_priv
 

Friends

class MessageAppendIterator
 
class MessageIterator
 
std::ostream & operator<< (std::ostream &os, const DBus::Message *msg)
 

Detailed Description

This class represents a basic DBus message and also serves as a base class for the specialized message types (call, return, signal, error).

This class cannot be initialized on its own; create a new Message from one of the subclasses

Author
Rick L Vinyard Jr rviny.nosp@m.ard@.nosp@m.cs.nm.nosp@m.su.e.nosp@m.du

Constructor & Destructor Documentation

◆ Message()

DBus::Message::Message ( )
protected

◆ ~Message()

DBus::Message::~Message ( )
virtual

Member Function Documentation

◆ add_filedescriptor()

void DBus::Message::add_filedescriptor ( int  fd)
private

◆ append()

◆ append_signature()

void DBus::Message::append_signature ( std::string  toappend)
protected

◆ auto_start()

bool DBus::Message::auto_start ( )

Returns true if the bus is allowed to start an owner for this message's destination if it is not running.

Returns

References DBUSCXX_MESSAGE_NO_AUTO_START_FLAG.

Referenced by set_auto_start().

◆ begin()

MessageIterator DBus::Message::begin ( ) const

◆ body() [1/2]

std::vector< uint8_t > * DBus::Message::body ( )
private

◆ body() [2/2]

const std::vector< uint8_t > * DBus::Message::body ( ) const
private

◆ clear_sig_and_data()

void DBus::Message::clear_sig_and_data ( )
protected

Clears the signature and the data, so you can re-append data.

References DBus::Signature.

Referenced by DBus::ErrorMessage::set_message().

◆ create_from_data()

◆ DBUS_CXX_PROPAGATE_CONST()

DBus::Message::DBUS_CXX_PROPAGATE_CONST ( std::unique_ptr< priv_data >  )
private

◆ destination()

std::string DBus::Message::destination ( ) const

◆ end()

MessageIterator DBus::Message::end ( ) const

References MessageIterator.

◆ endianess()

DBus::Endianess DBus::Message::endianess ( ) const

◆ filedescriptor_at_location()

int DBus::Message::filedescriptor_at_location ( int  location) const
private

◆ filedescriptors()

const std::vector< int > & DBus::Message::filedescriptors ( ) const

◆ filedescriptors_size()

uint32_t DBus::Message::filedescriptors_size ( ) const
private

◆ flags()

uint8_t DBus::Message::flags ( ) const

◆ header_field()

Variant DBus::Message::header_field ( MessageHeaderFields  field) const

◆ invalidate()

void DBus::Message::invalidate ( )

◆ is_valid()

bool DBus::Message::is_valid ( ) const

◆ operator bool()

DBus::Message::operator bool ( ) const

◆ operator<<()

template<typename T >
MessageAppendIterator DBus::Message::operator<< ( const T &  value)
inline

◆ operator==()

◆ operator>>()

template<typename T >
MessageIterator DBus::Message::operator>> ( T &  value) const
inline

References begin().

◆ sender()

std::string DBus::Message::sender ( ) const

◆ serial()

◆ serialize_to_vector()

bool DBus::Message::serialize_to_vector ( std::vector< uint8_t > *  vec,
uint32_t  serial 
) const

Serialize this message to the given vector.

The vector will be resized but not cleared. Can fail with an error under the following circumstances:

  • Invalid message type passed in
  • Method return or method call does not have serial set
Parameters
vecThe location to serialize the message to.
serialThe serial of the message.
Returns
True if the message was able to be serialized, false otherwise.

References DBus::Marshaling::align(), DBus::CALL, DBus::default_endianess(), DBus::ERROR, header_field(), DBus::header_field_to_int(), DBus::INVALID, DBus::Little, LOGGER_NAME, DBus::Marshaling::marshal(), DBus::Marshaling::marshal_at_offset(), DBus::Validator::message_is_small_enough(), DBus::Reply_Serial, DBus::RETURN, serial(), DBus::SIGNAL, SIMPLELOGGER_ERROR, DBus::Variant::to_uint32(), DBus::Variant::type(), type(), and DBus::UINT32.

◆ set_auto_start()

void DBus::Message::set_auto_start ( bool  auto_start)

◆ set_destination()

bool DBus::Message::set_destination ( const std::string &  s)

Set the destination of this message.

Parameters
s
Returns
true if the destination was able to be set, false if the destination was unable to be validated

References DBus::Destination, and DBus::Validator::validate_bus_name().

Referenced by DBus::CallMessage::CallMessage().

◆ set_flags()

void DBus::Message::set_flags ( uint8_t  flags)
protected

References flags().

Referenced by DBus::CallMessage::set_no_reply().

◆ set_header_field()

Variant DBus::Message::set_header_field ( MessageHeaderFields  field,
Variant  value 
)

◆ signature()

◆ type()

virtual MessageType DBus::Message::type ( ) const
pure virtual

Friends And Related Function Documentation

◆ MessageAppendIterator

friend class MessageAppendIterator
friend

Referenced by append().

◆ MessageIterator

friend class MessageIterator
friend

Referenced by begin(), and end().

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const DBus::Message msg 
)
friend

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