Teuchos - Trilinos Tools Package
Version of the Day
|
Serialization traits class for types T that use value semantics. More...
#include <Teuchos_SerializationTraits.hpp>
Static Public Member Functions | |
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... | |
Static Public Attributes | |
Serialization type selection | |
static const bool | supportsDirectSerialization = false |
Whether the type T supports direct serialization. More... | |
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.
Ordinal | The same template parameter as that of Comm . The integer type used to count the number of packets sent and received. |
T | The 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.
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
"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.
|
inlinestatic |
Return the number of bytes for count
objects.
Definition at line 148 of file Teuchos_SerializationTraits.hpp.
|
inlinestatic |
Convert the pointer type to char*
.
Definition at line 155 of file Teuchos_SerializationTraits.hpp.
|
inlinestatic |
Convert the pointer type to const char*
.
Definition at line 162 of file Teuchos_SerializationTraits.hpp.
|
inlinestatic |
Return the number of objects for bytes
of storage.
Definition at line 169 of file Teuchos_SerializationTraits.hpp.
|
inlinestatic |
Convert the pointer type from char*
.
Definition at line 176 of file Teuchos_SerializationTraits.hpp.
|
inlinestatic |
Convert the pointer type from char*
.
Definition at line 183 of file Teuchos_SerializationTraits.hpp.
|
inlinestatic |
Return the number of bytes for count
objects.
Definition at line 195 of file Teuchos_SerializationTraits.hpp.
|
inlinestatic |
Serialize to an indirect char[]
buffer.
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.
|
inlinestatic |
Return the number of objects for bytes
of storage.
Definition at line 227 of file Teuchos_SerializationTraits.hpp.
|
inlinestatic |
Deserialize from an indirect char[]
buffer.
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.
|
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.