|
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. | |
| static char * | convertToCharPtr (T *ptr) |
Convert the pointer type to char*. | |
| static const char * | convertToCharPtr (const T *ptr) |
Convert the pointer type to const char*. | |
| static Ordinal | fromDirectBytesToCount (const Ordinal bytes) |
Return the number of objects for bytes of storage. | |
| static T * | convertFromCharPtr (char *ptr) |
Convert the pointer type from char*. | |
| static const T * | convertFromCharPtr (const char *ptr) |
Convert the pointer type from char*. | |
Indirect serialization functions (always defined and supported) | |
| static Ordinal | fromCountToIndirectBytes (const Ordinal count, const T buffer[]) |
Return the number of bytes for count objects. | |
| static void | serialize (const Ordinal count, const T buffer[], const Ordinal bytes, char charBuffer[]) |
Serialize to an indirect char[] buffer. | |
| static Ordinal | fromIndirectBytesToCount (const Ordinal bytes, const char charBuffer[]) |
Return the number of objects for bytes of storage. | |
| static void | deserialize (const Ordinal bytes, const char charBuffer[], const Ordinal count, T buffer[]) |
Deserialize from an indirect char[] buffer. | |
Static Public Attributes | |
Serialization type selection | |
| static const bool | supportsDirectSerialization = false |
| Whether the type T supports direct serialization. | |
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
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 126 of file Teuchos_SerializationTraits.hpp.
| static Ordinal Teuchos::SerializationTraits< Ordinal, T >::fromCountToDirectBytes | ( | const Ordinal | count | ) | [inline, static] |
Return the number of bytes for count objects.
Definition at line 144 of file Teuchos_SerializationTraits.hpp.
| static char* Teuchos::SerializationTraits< Ordinal, T >::convertToCharPtr | ( | T * | ptr | ) | [inline, static] |
Convert the pointer type to char*.
Definition at line 151 of file Teuchos_SerializationTraits.hpp.
| static const char* Teuchos::SerializationTraits< Ordinal, T >::convertToCharPtr | ( | const T * | ptr | ) | [inline, static] |
Convert the pointer type to const char*.
Definition at line 158 of file Teuchos_SerializationTraits.hpp.
| static Ordinal Teuchos::SerializationTraits< Ordinal, T >::fromDirectBytesToCount | ( | const Ordinal | bytes | ) | [inline, static] |
Return the number of objects for bytes of storage.
Definition at line 165 of file Teuchos_SerializationTraits.hpp.
| static T* Teuchos::SerializationTraits< Ordinal, T >::convertFromCharPtr | ( | char * | ptr | ) | [inline, static] |
Convert the pointer type from char*.
Definition at line 172 of file Teuchos_SerializationTraits.hpp.
| static const T* Teuchos::SerializationTraits< Ordinal, T >::convertFromCharPtr | ( | const char * | ptr | ) | [inline, static] |
Convert the pointer type from char*.
Definition at line 179 of file Teuchos_SerializationTraits.hpp.
| static Ordinal Teuchos::SerializationTraits< Ordinal, T >::fromCountToIndirectBytes | ( | const Ordinal | count, |
| const T | buffer[] | ||
| ) | [inline, static] |
Return the number of bytes for count objects.
Definition at line 191 of file Teuchos_SerializationTraits.hpp.
| static void Teuchos::SerializationTraits< Ordinal, T >::serialize | ( | const Ordinal | count, |
| const T | buffer[], | ||
| const Ordinal | bytes, | ||
| char | charBuffer[] | ||
| ) | [inline, static] |
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 213 of file Teuchos_SerializationTraits.hpp.
| static Ordinal Teuchos::SerializationTraits< Ordinal, T >::fromIndirectBytesToCount | ( | const Ordinal | bytes, |
| const char | charBuffer[] | ||
| ) | [inline, static] |
Return the number of objects for bytes of storage.
Definition at line 223 of file Teuchos_SerializationTraits.hpp.
| static void Teuchos::SerializationTraits< Ordinal, T >::deserialize | ( | const Ordinal | bytes, |
| const char | charBuffer[], | ||
| const Ordinal | count, | ||
| T | buffer[] | ||
| ) | [inline, static] |
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 245 of file Teuchos_SerializationTraits.hpp.
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 136 of file Teuchos_SerializationTraits.hpp.
1.7.6.1