actor-framework
Public Types | Public Member Functions | Static Public Member Functions | Related Functions | List of all members
caf::message Class Reference

Describes a fixed-length, copy-on-write, type-erased tuple with elements of any type. More...

#include <message.hpp>

Public Types

using data_ptr = intrusive_cow_ptr< detail::message_data >
 

Public Member Functions

 message (data_ptr data) noexcept
 
 message (message &&) noexcept=default
 
 message (const message &) noexcept=default
 
messageoperator= (message &&) noexcept=default
 
messageoperator= (const message &) noexcept=default
 
auto types () const noexcept
 
size_t size () const noexcept
 
size_t empty () const noexcept
 
bool unique () const noexcept
 
template<class... Ts>
bool match_elements () const noexcept
 
 operator bool () const noexcept
 
bool operator! () const noexcept
 
template<class... Ts>
bool matches (const Ts &... values) const
 Checks whether this messages contains the types Ts... with values values.... More...
 
bool save (serializer &sink) const
 
bool save (binary_serializer &sink) const
 
bool save (detail::stringification_inspector &sink) const
 
bool load (deserializer &source)
 
bool load (binary_deserializer &source)
 
type_id_t type_at (size_t index) const noexcept
 Returns the type ID of the element at index. More...
 
template<class T >
bool match_element (size_t index) const noexcept
 Returns whether the element at index is of type T. More...
 
template<class T >
const T & get_as (size_t index) const noexcept
 
template<class T >
T & get_mutable_as (size_t index) noexcept
 
void swap (message &other) noexcept
 
void reset (detail::message_data *new_ptr=nullptr, bool add_ref=true) noexcept
 
void force_unshare ()
 Forces the message to copy its content if more than one reference to the content exists. More...
 

Static Public Member Functions

template<class... Ts>
static message concat (Ts &&... xs)
 

Related Functions

(Note that these are not member functions.)

message make_message ()
 
template<class... Ts>
message make_message (Ts &&... xs)
 
template<class T , class... Ts>
message make_message_nowrap (T &&arg, Ts &&... args)
 Same as make_message except when called with a single message argument. More...
 
template<class Tuple , size_t... Is>
message make_message_from_tuple (Tuple &&xs, std::index_sequence< Is... >)
 
template<class Tuple >
message make_message_from_tuple (Tuple &&xs)
 
template<class Inspector >
auto inspect (Inspector &f, message &x) -> std::enable_if_t< Inspector::is_loading, decltype(x.load(f))>
 
template<class Inspector >
auto inspect (Inspector &f, message &x) -> std::enable_if_t<!Inspector::is_loading, decltype(x.save(f))>
 
CAF_CORE_EXPORT std::string to_string (const message &x)
 

Detailed Description

Describes a fixed-length, copy-on-write, type-erased tuple with elements of any type.

Member Function Documentation

◆ force_unshare()

void caf::message::force_unshare ( )
inline

Forces the message to copy its content if more than one reference to the content exists.

◆ get_as()

template<class T >
const T& caf::message::get_as ( size_t  index) const
inlinenoexcept
Precondition
index < size()
match_element<T>(index)

◆ get_mutable_as()

template<class T >
T& caf::message::get_mutable_as ( size_t  index)
inlinenoexcept
Precondition
index < size()
match_element<T>(index)

◆ match_element()

template<class T >
bool caf::message::match_element ( size_t  index) const
inlinenoexcept

Returns whether the element at index is of type T.

Precondition
index < size()

◆ matches()

template<class... Ts>
bool caf::message::matches ( const Ts &...  values) const
inline

Checks whether this messages contains the types Ts... with values values....

Users may pass std::ignore as a wildcard for individual elements. Elements are compared using operator==.

◆ type_at()

type_id_t caf::message::type_at ( size_t  index) const
inlinenoexcept

Returns the type ID of the element at index.

Precondition
index < size()

Friends And Related Function Documentation

◆ inspect() [1/2]

template<class Inspector >
auto inspect ( Inspector &  f,
message x 
) -> std::enable_if_t<Inspector::is_loading, decltype(x.load(f))>
related

◆ inspect() [2/2]

template<class Inspector >
auto inspect ( Inspector &  f,
message x 
) -> std::enable_if_t<!Inspector::is_loading, decltype(x.save(f))>
related

◆ make_message() [1/2]

message make_message ( )
related

◆ make_message() [2/2]

template<class... Ts>
message make_message ( Ts &&...  xs)
related

◆ make_message_from_tuple() [1/2]

template<class Tuple , size_t... Is>
message make_message_from_tuple ( Tuple &&  xs,
std::index_sequence< Is... >   
)
related

◆ make_message_from_tuple() [2/2]

template<class Tuple >
message make_message_from_tuple ( Tuple &&  xs)
related

◆ make_message_nowrap()

template<class T , class... Ts>
message make_message_nowrap ( T &&  arg,
Ts &&...  args 
)
related

Same as make_message except when called with a single message argument.

In the latter case, simply returns the message instead of wrapping it into another message.

◆ to_string()

CAF_CORE_EXPORT std::string to_string ( const message x)
related

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