Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members
Teuchos::SerializationTraits< Ordinal, T > Class Template Reference

Serialization traits class for types T that use value semantics. More...

#include <Teuchos_SerializationTraits.hpp>

Inheritance diagram for Teuchos::SerializationTraits< Ordinal, T >:
Inheritance graph
[legend]

Serialization type selection

static const bool supportsDirectSerialization = false
 Whether the type T supports direct serialization. More...
 

Direct serialization functions (not defined if supportsDirectSerialization==false)

static Ordinal fromCountToDirectBytes (const Ordinal count)
 Return the number of bytes for count objects. More...
 
static char * convertToCharPtr (T *ptr)
 Convert the pointer type to char*. More...
 
static const char * convertToCharPtr (const T *ptr)
 Convert the pointer type to const char*. More...
 
static Ordinal fromDirectBytesToCount (const Ordinal bytes)
 Return the number of objects for bytes of storage. More...
 
static T * convertFromCharPtr (char *ptr)
 Convert the pointer type from char*. More...
 
static const T * convertFromCharPtr (const char *ptr)
 Convert the pointer type from char*. More...
 

Indirect serialization functions (always defined and supported)

static Ordinal fromCountToIndirectBytes (const Ordinal count, const T buffer[])
 Return the number of bytes for count objects. More...
 
static void serialize (const Ordinal count, const T buffer[], const Ordinal bytes, char charBuffer[])
 Serialize to an indirect char[] buffer. More...
 
static Ordinal fromIndirectBytesToCount (const Ordinal bytes, const char charBuffer[])
 Return the number of objects for bytes of storage. More...
 
static void deserialize (const Ordinal bytes, const char charBuffer[], const Ordinal count, T buffer[])
 Deserialize from an indirect char[] buffer. More...
 

Detailed Description

template<typename Ordinal, typename T>
class Teuchos::SerializationTraits< Ordinal, T >

Serialization traits class for types T that use value semantics.

This traits class describes how to convert between arrays of T, and arrays of char. We call the process of converting from T to char "serialization," and from char to T "deserialization." Teuchos uses serialization and deserialization mainly for implementing distributed-memory message-passing communication in a generic way.

Template Parameters
OrdinalThe same template parameter as that of Comm. The integer type used to count the number of packets sent and received.
TThe type of the objects that this class shows how to serialize.

Teuchos defines specializations of this class for many commonly used types in distributed-memory communication, such as char, int (signed and unsigned), float, double, and std::pair<P1, P2> for certain types P1 and P2. Depending on your Trilinos build options, other specializations may be defined as well, for example for long long int, double-double and quad-double real types (dd_real resp. qd_real), or certain std::complex<T> specializations. If a specialization of this class does not exist for your type T, you may define your own specialization.

Note
Before defining specializations of this class, make sure that they do not duplicate specializations already present in PyTrilinos (see packages/PyTrilinos/src/Teuchos_Traits.i)

There are two different serialization modes: direct and indirect. "Direct" serialization means that you can convert directly between an object of type T and an array of char, of a specific length dependent only on the type T and not on the particular instance. Specifically, it means you can

  1. reinterpret_cast a pointer to an instance of T into an array of char (which array has length dependent only on the type T and not on the specific T instance),
  2. serialize the resulting array of char, and finally
  3. deserialize by reading in the array of char and doing a reinterpret_cast back into a T.

"Indirect" serialization is defined as any serialization method more general than that. The supportsDirectSerialization class Boolean tells you whether this specialization supports direct serialization.

SerializationTraits is used by classes such as ValueTypeSerializationBuffer, ConstValueTypeSerializationBuffer, ValueTypeDeserializationBuffer, and ConstValueTypeDeserializationBuffer.

Definition at line 130 of file Teuchos_SerializationTraits.hpp.

Member Function Documentation

template<typename Ordinal , typename T >
static Ordinal Teuchos::SerializationTraits< Ordinal, T >::fromCountToDirectBytes ( const Ordinal  count)
inlinestatic

Return the number of bytes for count objects.

Definition at line 148 of file Teuchos_SerializationTraits.hpp.

template<typename Ordinal , typename T >
static char* Teuchos::SerializationTraits< Ordinal, T >::convertToCharPtr ( T *  ptr)
inlinestatic

Convert the pointer type to char*.

Definition at line 155 of file Teuchos_SerializationTraits.hpp.

template<typename Ordinal , typename T >
static const char* Teuchos::SerializationTraits< Ordinal, T >::convertToCharPtr ( const T *  ptr)
inlinestatic

Convert the pointer type to const char*.

Definition at line 162 of file Teuchos_SerializationTraits.hpp.

template<typename Ordinal , typename T >
static Ordinal Teuchos::SerializationTraits< Ordinal, T >::fromDirectBytesToCount ( const Ordinal  bytes)
inlinestatic

Return the number of objects for bytes of storage.

Definition at line 169 of file Teuchos_SerializationTraits.hpp.

template<typename Ordinal , typename T >
static T* Teuchos::SerializationTraits< Ordinal, T >::convertFromCharPtr ( char *  ptr)
inlinestatic

Convert the pointer type from char*.

Definition at line 176 of file Teuchos_SerializationTraits.hpp.

template<typename Ordinal , typename T >
static const T* Teuchos::SerializationTraits< Ordinal, T >::convertFromCharPtr ( const char *  ptr)
inlinestatic

Convert the pointer type from char*.

Definition at line 183 of file Teuchos_SerializationTraits.hpp.

template<typename Ordinal , typename T >
static Ordinal Teuchos::SerializationTraits< Ordinal, T >::fromCountToIndirectBytes ( const Ordinal  count,
const T  buffer[] 
)
inlinestatic

Return the number of bytes for count objects.

Definition at line 195 of file Teuchos_SerializationTraits.hpp.

template<typename Ordinal , typename T >
static void Teuchos::SerializationTraits< Ordinal, T >::serialize ( const Ordinal  count,
const T  buffer[],
const Ordinal  bytes,
char  charBuffer[] 
)
inlinestatic

Serialize to an indirect char[] buffer.

Parameters
count[in] The number of objects to serialize.
buffer[in] The objects to serialize.
bytes[in] Number of bytes in charBuffer[]
charBuffer[out] Array (length bytes) containing the serialized objects.

Preconditions:

  • bytes==fromCountToIndirectBytes(count)

Definition at line 217 of file Teuchos_SerializationTraits.hpp.

template<typename Ordinal , typename T >
static Ordinal Teuchos::SerializationTraits< Ordinal, T >::fromIndirectBytesToCount ( const Ordinal  bytes,
const char  charBuffer[] 
)
inlinestatic

Return the number of objects for bytes of storage.

Definition at line 227 of file Teuchos_SerializationTraits.hpp.

template<typename Ordinal , typename T >
static void Teuchos::SerializationTraits< Ordinal, T >::deserialize ( const Ordinal  bytes,
const char  charBuffer[],
const Ordinal  count,
buffer[] 
)
inlinestatic

Deserialize from an indirect char[] buffer.

Parameters
bytes[in] Number of bytes in charBuffer[]
charBuffer[in] Array (length bytes) containing the serialized objects.
count[in] The number of objects to deserialize.
buffer[out] The deserialized objects.

Preconditions:

  • count==fromIndirectBytesToCount(bytes)

Definition at line 249 of file Teuchos_SerializationTraits.hpp.

Member Data Documentation

template<typename Ordinal , typename T >
const bool Teuchos::SerializationTraits< Ordinal, T >::supportsDirectSerialization = false
static

Whether the type T supports direct serialization.

See the class documentation for definitions of "direct" and "indirect" serialization.

Definition at line 140 of file Teuchos_SerializationTraits.hpp.


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