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>
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< Message > | create_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) |
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
|
protected |
|
virtual |
|
private |
References set_header_field(), and DBus::Unix_FDs.
MessageAppendIterator DBus::Message::append | ( | ) |
References MessageAppendIterator.
Referenced by DBus::ErrorMessage::ErrorMessage(), and DBus::ErrorMessage::set_message().
|
protected |
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.
References DBUSCXX_MESSAGE_NO_AUTO_START_FLAG.
Referenced by set_auto_start().
MessageIterator DBus::Message::begin | ( | ) | const |
References MessageIterator.
Referenced by DBus::ErrorMessage::message(), and operator>>().
|
private |
Referenced by DBus::MessageAppendIterator::MessageAppendIterator().
|
private |
|
protected |
Clears the signature and the data, so you can re-append data.
References DBus::Signature.
Referenced by DBus::ErrorMessage::set_message().
|
static |
References DBus::Demarshaling::align(), DBus::Big, DBus::CallMessage::create(), DBus::ErrorMessage::create(), DBus::ReturnMessage::create(), DBus::SignalMessage::create(), DBus::Demarshaling::current_offset(), DBus::Demarshaling::demarshal_uint32_t(), DBus::Demarshaling::demarshal_uint8_t(), DBus::Demarshaling::demarshal_variant(), flags(), DBus::int_to_header_field(), DBus::Invalid, DBus::Little, LOGGER_NAME, serial(), DBus::Demarshaling::set_endianess(), SIMPLELOGGER_DEBUG, SIMPLELOGGER_TRACE, SIMPLELOGGER_WARN, DBus::Variant::to_uint32(), and DBus::Unix_FDs.
Referenced by DBus::priv::SendmsgTransport::readMessage(), and DBus::priv::SimpleTransport::readMessage().
|
private |
std::string DBus::Message::destination | ( | ) | const |
References DBus::Destination, header_field(), and DBus::STRING.
MessageIterator DBus::Message::end | ( | ) | const |
References MessageIterator.
DBus::Endianess DBus::Message::endianess | ( | ) | const |
|
private |
const std::vector< int > & DBus::Message::filedescriptors | ( | ) | const |
|
private |
uint8_t DBus::Message::flags | ( | ) | const |
The message flags, as the marshaled byte.
Referenced by DBus::CallMessage::create_error_reply(), create_from_data(), DBus::CallMessage::create_reply(), DBus::CallMessage::expects_reply(), set_flags(), and DBus::CallMessage::set_no_reply().
Variant DBus::Message::header_field | ( | MessageHeaderFields | field | ) | const |
Returns the given header field(if it exists), otherwise returns a default constructed variant.
field | The field number to get |
Referenced by destination(), DBus::CallMessage::interface_name(), DBus::SignalMessage::interface_name(), DBus::CallMessage::member(), DBus::SignalMessage::member(), DBus::ErrorMessage::message(), DBus::ErrorMessage::name(), operator==(), DBus::CallMessage::path(), DBus::SignalMessage::path(), DBus::ErrorMessage::reply_serial(), DBus::ReturnMessage::reply_serial(), sender(), serialize_to_vector(), set_header_field(), and signature().
void DBus::Message::invalidate | ( | ) |
bool DBus::Message::is_valid | ( | ) | const |
Referenced by DBus::CallMessage::create_error_reply(), and DBus::CallMessage::create_reply().
DBus::Message::operator bool | ( | ) | const |
|
inline |
bool DBus::Message::operator== | ( | const Message & | other | ) |
|
inline |
References begin().
std::string DBus::Message::sender | ( | ) | const |
References header_field(), DBus::Sender, and DBus::STRING.
Referenced by DBus::CallMessage::create_error_reply(), and DBus::CallMessage::create_reply().
uint32_t DBus::Message::serial | ( | ) | const |
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:
vec | The location to serialize the message to. |
serial | The serial of the message. |
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.
void DBus::Message::set_auto_start | ( | bool | auto_start | ) |
References auto_start(), and DBUSCXX_MESSAGE_NO_AUTO_START_FLAG.
bool DBus::Message::set_destination | ( | const std::string & | s | ) |
Set the destination of this message.
s |
References DBus::Destination, and DBus::Validator::validate_bus_name().
Referenced by DBus::CallMessage::CallMessage().
|
protected |
References flags().
Referenced by DBus::CallMessage::set_no_reply().
Variant DBus::Message::set_header_field | ( | MessageHeaderFields | field, |
Variant | value | ||
) |
Set the given header field.
Returns the previously set value, if it exists.
field | The field to set |
value | The value to set the header field to |
References header_field().
Referenced by add_filedescriptor(), DBus::ErrorMessage::ErrorMessage(), DBus::CallMessage::set_interface(), DBus::SignalMessage::set_interface(), DBus::CallMessage::set_member(), DBus::SignalMessage::set_member(), DBus::ErrorMessage::set_name(), DBus::CallMessage::set_path(), DBus::SignalMessage::set_path(), DBus::ErrorMessage::set_reply_serial(), and DBus::ReturnMessage::set_reply_serial().
Signature DBus::Message::signature | ( | ) | const |
References header_field(), DBus::SIGNATURE, DBus::Signature, DBus::Variant::to_signature(), and DBus::Variant::type().
Referenced by DBus::ErrorMessage::message().
|
pure virtual |
Implemented in DBus::SignalMessage, DBus::ReturnMessage, DBus::ErrorMessage, and DBus::CallMessage.
Referenced by operator==(), and serialize_to_vector().
|
friend |
Referenced by append().
|
friend |
|
friend |