Derecho  0.9
Distributed systems toolkit for RDMA
Classes | Namespaces | Typedefs | Functions | Variables
SerializationSupport.hpp File Reference
#include "SerializationMacros.hpp"
#include "context_ptr.hpp"
#include <cstring>
#include <mutils/macro_utils.hpp>
#include <mutils/mutils.hpp>
#include <mutils/tuple_extras.hpp>
#include <mutils/type_utils.hpp>
#include <tuple>
#include <vector>
Include dependency graph for SerializationSupport.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mutils::ByteRepresentable
 A non-POD type which wishes to mark itself byte representable should extend this class. More...
 
struct  mutils::RemoteDeserializationContext
 If a class which implements ByteRepresentable requires a context in order to correctly deserialize, that context should be represented as a class that extends RemoteDeserializationContext. More...
 
struct  mutils::DeserializationManager
 The manager for any RemoteDeserializationContexts. More...
 
struct  mutils::marshalled
 The "marshalled" type is a wrapper for already-serialized types;. More...
 
struct  mutils::is_string< typename >
 
struct  mutils::is_string< std::string >
 
struct  mutils::is_string< const std::string >
 
struct  mutils::is_pair< typename >
 
struct  mutils::is_pair< std::pair< T, U > >
 
struct  mutils::is_list< typename >
 
struct  mutils::is_list< std::list< T > >
 
struct  mutils::is_map< typename >
 
struct  mutils::is_map< std::map< K, V > >
 
struct  mutils::dsr_info
 

Namespaces

 mutils
 

Typedefs

using mutils::RemoteDeserializationContext_p = RemoteDeserializationContext *
 
using mutils::RemoteDeserialization_v = std::vector< RemoteDeserializationContext_p >
 

Functions

template<typename T , restrict2(std::is_pod< T >::value) >
auto mutils::bytes_size (const T &)
 Just calls sizeof(T) More...
 
std::size_t mutils::bytes_size (const ByteRepresentable &b)
 calls b.bytes_size() when b is a ByteRepresentable; calls sizeof(decay_t<decltype(b)>) when b is a POD; custom logic is implemented for some STL types. More...
 
std::size_t mutils::bytes_size (const std::string &b)
 effectively strlen(). More...
 
template<typename... T>
std::size_t mutils::bytes_size (const std::tuple< T... > &t)
 
template<typename T , typename V >
std::size_t mutils::bytes_size (const std::pair< T, V > &pair)
 sums the size of both pair elements More...
 
std::size_t mutils::bytes_size (const std::vector< bool > &v)
 all of the elements of this vector, plus one int for the number of elements. More...
 
template<typename T >
std::size_t mutils::bytes_size (const std::vector< T > &v)
 
template<typename T >
std::size_t mutils::bytes_size (const std::list< T > &list)
 Sums the size of all elements of this list, plus one int for the number of elements. More...
 
template<typename T >
std::size_t mutils::bytes_size (const std::set< T > &s)
 All the elements of the set, plus one int for the number of elements. More...
 
template<typename K , typename V >
std::size_t mutils::bytes_size (const std::map< K, V > &m)
 Sums the size of each key and value in the map, plus one int for the number of entries. More...
 
template<typename... T>
std::size_t mutils::bytes_size_helper (const T &... t)
 Sums the size of each element of the tuple. More...
 
template<typename F , typename BR , typename... Args>
std::enable_if_t< std::is_pod< BR >::value > mutils::post_object (const F &f, const BR &br, Args &&... args)
 In-place serialization is also sometimes possible. More...
 
void mutils::post_object (const std::function< void(char const *const, std::size_t)> &f, const ByteRepresentable &br)
 
std::size_t mutils::to_bytes (const ByteRepresentable &b, char *v)
 calls b.to_bytes(v) when b is a ByteRepresentable; calls std::memcpy() when b is POD. More...
 
std::size_t mutils::to_bytes (const std::string &b, char *v)
 extracts the C string (char*) equivalent to this std::string and stores it in v More...
 
template<typename T >
std::enable_if_t< std::is_base_of< ByteRepresentable CMA T >::value, std::unique_ptr< T > > mutils::from_bytes (DeserializationManager *ctx, char const *v)
 Calls T::from_bytes(ctx,v) when T is a ByteRepresentable. More...
 
template<typename T >
std::enable_if_t< std::is_pod< T >::value, std::unique_ptr< std::decay_t< T > > > mutils::from_bytes (DeserializationManager *, char const *v)
 Calls T::from_bytes(ctx,v) when T is a ByteRepresentable. More...
 
template<typename T >
std::enable_if_t< std::is_base_of< ByteRepresentable CMA std::decay_t< T > >::value, context_ptr< T > > mutils::from_bytes_noalloc (DeserializationManager *ctx, const char *v, context_ptr< std::decay_t< T >>=context_ptr< std::decay_t< T >>{})
 Calls T::from_bytes_noalloc(ctx,v) when T is a ByteRepresentable. More...
 
template<typename T >
std::enable_if_t< std::is_pod< T >::value, context_ptr< std::decay_t< T > > > mutils::from_bytes_noalloc (DeserializationManager *, char *v)
 Calls T::from_bytes_noalloc(ctx,v) when T is a ByteRepresentable. More...
 
template<typename T >
std::enable_if_t< std::is_pod< T >::value, context_ptr< const std::decay_t< T > > > mutils::from_bytes_noalloc (DeserializationManager *, char const *const v, context_ptr< T >=context_ptr< T >{})
 
template<typename T , typename F >
auto mutils::deserialize_and_run (DeserializationManager *dsm, char *v, const F &fun)
 Calls mutils::from_bytes_noalloc<T>(ctx,v), dereferences the result, and passes it to fun. More...
 
void mutils::post_object (const std::function< void(char const *const, std::size_t)> &f, const std::string &str)
 
template<typename T , typename V >
void mutils::post_object (const std::function< void(char const *const, std::size_t)> &f, const std::pair< T, V > &pair)
 
template<typename... T>
void mutils::post_object_helper (const std::function< void(char const *const, std::size_t)> &f, const T &... t)
 
template<typename... T>
void mutils::post_object (const std::function< void(char const *const, std::size_t)> &f, const std::tuple< T... > &t)
 
void mutils::post_object (const std::function< void(char const *const, std::size_t)> &f, const std::vector< bool > &vec)
 
template<typename T >
void mutils::post_object (const std::function< void(char const *const, std::size_t)> &f, const std::vector< T > &vec)
 
template<typename T >
void mutils::post_object (const std::function< void(char const *const, std::size_t)> &f, const std::list< T > &list)
 
template<typename T >
void mutils::post_object (const std::function< void(char const *const, std::size_t)> &f, const std::set< T > &s)
 
template<typename K , typename V >
void mutils::post_object (const std::function< void(char const *const, std::size_t)> &f, const std::map< K, V > &map)
 
template<typename T , restrict(std::is_pod< T >::value) >
std::size_t mutils::to_bytes (const T &t, char *v)
 Special to_bytes for POD types, which just uses memcpy. More...
 
std::size_t mutils::to_bytes (const std::vector< bool > &vec, char *v)
 
template<typename T >
std::size_t mutils::to_bytes (const std::vector< T > &vec, char *v)
 
template<typename T >
std::size_t mutils::to_bytes (const std::list< T > &list, char *buffer)
 
template<typename T , typename V >
std::size_t mutils::to_bytes (const std::pair< T, V > &pair, char *buffer)
 
template<typename... T>
std::size_t mutils::to_bytes (const std::tuple< T... > &tuple, char *buffer)
 
template<typename T >
std::size_t mutils::to_bytes (const std::set< T > &s, char *_v)
 
template<typename K , typename V >
std::size_t mutils::to_bytes (const std::map< K, V > &m, char *buffer)
 
template<typename T >
std::unique_ptr< type_check< std::is_integral, T > > mutils::from_string (DeserializationManager *, char const *v, std::size_t length)
 
template<typename T >
std::unique_ptr< type_check< std::is_floating_point, T > > mutils::from_string (DeserializationManager *, char const *v, std::size_t length)
 
template<typename T >
std::unique_ptr< type_check< is_string, T > > mutils::from_string (DeserializationManager *, char const *v, std::size_t length)
 
template<typename T >
std::enable_if_t< std::is_pod< T >::value, context_ptr< std::decay_t< T > > > mutils::from_bytes_noalloc (DeserializationManager *, char *v, context_ptr< T >=context_ptr< T >{})
 
template<typename T >
std::unique_ptr< type_check< is_string, T > > mutils::from_bytes (DeserializationManager *, char const *v)
 
template<typename T >
context_ptr< type_check< is_string, T > > mutils::from_bytes_noalloc (DeserializationManager *, char const *v, context_ptr< T >=context_ptr< T >{})
 
template<typename T >
std::unique_ptr< type_check< is_set, T > > mutils::from_bytes (DeserializationManager *ctx, const char *_v)
 
template<typename T >
context_ptr< type_check< is_set, T > > mutils::from_bytes_noalloc (DeserializationManager *ctx, char const *v, context_ptr< T >=context_ptr< T >{})
 
template<typename T >
std::unique_ptr< type_check< is_pair, T > > mutils::from_bytes (DeserializationManager *ctx, const char *v)
 
template<typename L >
std::unique_ptr< type_check< is_list, L > > mutils::from_bytes (DeserializationManager *ctx, const char *buffer)
 
template<typename T >
context_ptr< type_check< is_pair, T > > mutils::from_bytes_noalloc (DeserializationManager *ctx, char const *v, context_ptr< T >=context_ptr< T >{})
 
template<typename T >
std::unique_ptr< T > mutils::boolvec_from_bytes (DeserializationManager *ctx, char const *v)
 
template<typename TupleType , std::size_t N>
auto mutils::from_bytes_helper (DeserializationManager *ctx, char const *v)
 
template<typename T >
std::unique_ptr< type_check< is_tuple, T > > mutils::from_bytes (DeserializationManager *ctx, char const *v)
 
template<typename T >
std::enable_if_t< is_vector< T >::value, std::unique_ptr< T > > mutils::from_bytes (DeserializationManager *ctx, char const *v)
 
template<typename T >
context_ptr< type_check< is_vector, T > > mutils::from_bytes_noalloc (DeserializationManager *ctx, char const *v, context_ptr< T >=context_ptr< T >{})
 
template<typename T >
std::enable_if_t< is_map< T >::value, std::unique_ptr< T > > mutils::from_bytes (DeserializationManager *ctx, char const *buffer)
 
template<typename T >
context_ptr< type_check< is_map, T > > mutils::from_bytes_noalloc (DeserializationManager *ctx, char const *v, context_ptr< T >=context_ptr< T >{})
 
std::size_t mutils::to_bytes_v (char *)
 For Serializing and Deserializing many objects at once. More...
 
template<typename T , typename... Rest>
std::size_t mutils::to_bytes_v (char *buf, const T &first, const Rest &... rest)
 
std::size_t mutils::from_bytes_v (DeserializationManager *, char const *const)
 
template<typename T , typename... Rest>
std::size_t mutils::from_bytes_v (DeserializationManager *dsm, char const *const buf, std::unique_ptr< T > &first, Rest &... rest)
 
std::size_t mutils::from_bytes_noalloc_v (DeserializationManager *, char const *const)
 
template<typename T , typename... Rest>
std::size_t mutils::from_bytes_noalloc_v_nc (DeserializationManager *dsm, char *buf, context_ptr< T > &first, context_ptr< Rest > &... rest)
 
template<typename T , typename... Rest>
std::size_t mutils::from_bytes_noalloc_v (DeserializationManager *dsm, char *buf, context_ptr< T > &first, context_ptr< Rest > &... rest)
 
template<typename T , typename... Rest>
std::size_t mutils::from_bytes_noalloc_v (DeserializationManager *dsm, char const *const buf, context_ptr< const T > &first, context_ptr< const Rest > &... rest)
 
template<typename F , typename R , typename... Args>
auto mutils::deserialize_and_run (DeserializationManager *dsm, char const *const v, const F &fun, std::function< R(Args...)> const *const)
 
template<typename F >
auto mutils::deserialize_and_run (DeserializationManager *dsm, char const *const v, const F &fun)
 

Variables

std::function< void(char const *const, std::size_t)> mutils::post_to_buffer (std::size_t &index, char *dest_buf)
 Serialization is also implemented for the following STL types: vector pair string set. More...
 

Class Documentation

◆ mutils::dsr_info

struct mutils::dsr_info

Definition at line 954 of file SerializationSupport.hpp.

Class Members
time_point start_time
nanoseconds to_callfunc
nanoseconds to_exit