CAF 0.17.6
Public Member Functions | Static Public Member Functions | Related Functions | List of all members
caf::type_erased_tuple Class Referenceabstract

Represents a tuple of type-erased values. More...

#include <type_erased_tuple.hpp>

Inheritance diagram for caf::type_erased_tuple:
caf::empty_type_erased_tuple caf::message

Public Member Functions

 type_erased_tuple (const type_erased_tuple &)=default
 
type_erased_tupleoperator= (const type_erased_tuple &)=default
 
virtual void * get_mutable (size_t pos)=0
 Returns a mutable pointer to the element at position pos. More...
 
virtual error load (size_t pos, deserializer &source)=0
 Load the content for the element at position pos from source. More...
 
virtual error load (deserializer &source)
 Load the content for the tuple from source. More...
 
virtual size_t size () const noexcept=0
 Returns the size of this tuple. More...
 
virtual uint32_t type_token () const noexcept=0
 Returns a type hint for the element types. More...
 
virtual rtti_pair type (size_t pos) const noexcept=0
 Returns the type number and std::type_info object for the element at position pos. More...
 
virtual const void * get (size_t pos) const noexcept=0
 Returns the element at position pos. More...
 
virtual std::string stringify (size_t pos) const =0
 Returns a string representation of the element at position pos. More...
 
virtual type_erased_value_ptr copy (size_t pos) const =0
 Returns a copy of the element at position pos. More...
 
virtual error save (size_t pos, serializer &sink) const =0
 Saves the element at position pos to sink. More...
 
virtual bool shared () const noexcept
 Returns whether multiple references to this tuple exist. More...
 
bool empty () const
 Returns size() == 0.
 
std::string stringify () const
 Returns a string representation of the tuple.
 
virtual error save (serializer &sink) const
 Saves the content of the tuple to sink. More...
 
bool matches (size_t pos, uint16_t nr, const std::type_info *ptr) const noexcept
 Checks whether the type of the stored value at position pos matches type number n and run-time type information p.
 
uint16_t type_nr (size_t pos) const noexcept
 Returns the type number for the element at position pos.
 
bool matches (size_t pos, const rtti_pair &rtti) const noexcept
 Checks whether the type of the stored value matches rtti.
 
template<class T >
const T & get_as (size_t pos) const
 Convenience function for *reinterpret_cast<const T*>(get()).
 
template<class T , size_t Pos>
const T & get_as (typed_index< T, Pos >) const
 
template<class... Ts, long... Is>
std::tuple< const Ts &... > get_as_tuple (detail::type_list< Ts... >, detail::int_list< Is... >) const
 
template<class... Ts>
std::tuple< const Ts &... > get_as_tuple () const
 
template<class T >
T & get_mutable_as (size_t pos)
 Convenience function for *reinterpret_cast<T*>(get_mutable()).
 
template<class T >
move_if_unshared (size_t pos)
 Convenience function for moving a value out of the tuple if it is unshared. More...
 
template<class T >
bool match_element (size_t pos) const noexcept
 Returns true if the element at pos matches T.
 
template<class... Ts>
bool match_elements () const noexcept
 Returns true if the pattern Ts... matches the content of this tuple.
 
template<class F >
auto apply (F fun) -> optional< typename detail::get_callable_trait< F >::result_type >
 

Static Public Member Functions

template<class T , size_t Pos>
static constexpr typed_index< T, Pos > make_typed_index ()
 

Related Functions

(Note that these are not member functions.)

template<class... Ts>
detail::type_erased_tuple_view< Ts... > make_type_erased_tuple_view (Ts &... xs)
 
template<class Processor >
std::enable_if< Processor::reads_state >::type serialize (Processor &proc, type_erased_tuple &x)
 
template<class Processor >
std::enable_if< Processor::writes_state >::type serialize (Processor &proc, type_erased_tuple &x)
 
std::string to_string (const type_erased_tuple &x)
 

Detailed Description

Represents a tuple of type-erased values.

Member Function Documentation

◆ copy()

virtual type_erased_value_ptr caf::type_erased_tuple::copy ( size_t  pos) const
pure virtual

Returns a copy of the element at position pos.

Implemented in caf::message, and caf::empty_type_erased_tuple.

◆ get()

virtual const void * caf::type_erased_tuple::get ( size_t  pos) const
pure virtualnoexcept

Returns the element at position pos.

Implemented in caf::message, and caf::empty_type_erased_tuple.

◆ get_mutable()

virtual void * caf::type_erased_tuple::get_mutable ( size_t  pos)
pure virtual

Returns a mutable pointer to the element at position pos.

Implemented in caf::message, and caf::empty_type_erased_tuple.

◆ load() [1/2]

virtual error caf::type_erased_tuple::load ( deserializer source)
virtual

Load the content for the tuple from source.

Reimplemented in caf::message.

◆ load() [2/2]

virtual error caf::type_erased_tuple::load ( size_t  pos,
deserializer source 
)
pure virtual

Load the content for the element at position pos from source.

Implemented in caf::message, and caf::empty_type_erased_tuple.

◆ move_if_unshared()

template<class T >
T caf::type_erased_tuple::move_if_unshared ( size_t  pos)

Convenience function for moving a value out of the tuple if it is unshared.

Returns a copy otherwise.

◆ save() [1/2]

virtual error caf::type_erased_tuple::save ( serializer sink) const
virtual

Saves the content of the tuple to sink.

Reimplemented in caf::message.

◆ save() [2/2]

virtual error caf::type_erased_tuple::save ( size_t  pos,
serializer sink 
) const
pure virtual

Saves the element at position pos to sink.

Implemented in caf::message, and caf::empty_type_erased_tuple.

◆ shared()

virtual bool caf::type_erased_tuple::shared ( ) const
virtualnoexcept

Returns whether multiple references to this tuple exist.

The default implementation returns false.

Reimplemented in caf::message.

◆ size()

virtual size_t caf::type_erased_tuple::size ( ) const
pure virtualnoexcept

Returns the size of this tuple.

Implemented in caf::message, and caf::empty_type_erased_tuple.

◆ stringify()

virtual std::string caf::type_erased_tuple::stringify ( size_t  pos) const
pure virtual

Returns a string representation of the element at position pos.

Implemented in caf::message, and caf::empty_type_erased_tuple.

◆ type()

virtual rtti_pair caf::type_erased_tuple::type ( size_t  pos) const
pure virtualnoexcept

Returns the type number and std::type_info object for the element at position pos.

Implemented in caf::message, and caf::empty_type_erased_tuple.

◆ type_token()

virtual uint32_t caf::type_erased_tuple::type_token ( ) const
pure virtualnoexcept

Returns a type hint for the element types.

Implemented in caf::message, and caf::empty_type_erased_tuple.


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