10 #ifndef SACADO_TAY_SERIALIZATIONTRAITSIMP_HPP
11 #define SACADO_TAY_SERIALIZATIONTRAITSIMP_HPP
15 #ifdef HAVE_SACADO_TEUCHOSCOMM
26 template <
typename Ordinal,
typename TayType,
typename Serializer>
27 struct SerializationImp {
40 static const bool supportsDirectSerialization =
false;
46 static Ordinal fromCountToIndirectBytes(
const Serializer& vs,
48 const TayType buffer[],
54 unsigned int my_sz = buffer[
i].degree()+1;
55 unsigned int tot_sz = sz;
56 if (sz == 0) tot_sz = my_sz;
57 if (tot_sz != my_sz) {
58 x =
new TayType(buffer[
i]);
59 x->resize(tot_sz-1,
true);
64 Ordinal b1 = iSerT::fromCountToIndirectBytes(1, &tot_sz);
65 Ordinal b2 = vs.fromCountToIndirectBytes(
66 tot_sz, &(cx->fastAccessCoeff(0)));
67 Ordinal b3 = oSerT::fromCountToIndirectBytes(1, &b2);
78 static void serialize (
const Serializer& vs,
80 const TayType buffer[],
88 unsigned int my_sz = buffer[
i].degree()+1;
89 unsigned int tot_sz = sz;
90 if (sz == 0) tot_sz = my_sz;
91 Ordinal b1 = iSerT::fromCountToIndirectBytes(1, &tot_sz);
92 iSerT::serialize(1, &tot_sz, b1, charBuffer);
96 if (tot_sz != my_sz) {
97 x =
new TayType(buffer[
i]);
98 x->resize(tot_sz-1,
true);
103 Ordinal b2 = vs.fromCountToIndirectBytes(
104 tot_sz, &(cx->fastAccessCoeff(0)));
105 Ordinal b3 = oSerT::fromCountToIndirectBytes(1, &b2);
106 oSerT::serialize(1, &b2, b3, charBuffer);
108 vs.serialize(tot_sz, &(cx->fastAccessCoeff(0)), b2, charBuffer);
118 static Ordinal fromIndirectBytesToCount(
const Serializer& vs,
120 const char charBuffer[],
124 while (bytes_used < bytes) {
127 Ordinal b1 = iSerT::fromCountToDirectBytes(1);
132 Ordinal b3 = oSerT::fromCountToDirectBytes(1);
133 const Ordinal *b2 = oSerT::convertFromCharPtr(charBuffer);
145 static void deserialize (
const Serializer& vs,
147 const char charBuffer[],
154 Ordinal b1 = iSerT::fromCountToDirectBytes(1);
155 const unsigned int *my_sz = iSerT::convertFromCharPtr(charBuffer);
159 unsigned int tot_sz = sz;
160 if (sz == 0) tot_sz = *my_sz;
161 buffer[
i] = TayType(tot_sz-1, 0.0);
164 Ordinal b3 = oSerT::fromCountToDirectBytes(1);
165 const Ordinal *b2 = oSerT::convertFromCharPtr(charBuffer);
167 vs.deserialize(*b2, charBuffer, *my_sz,
168 &(buffer[
i].fastAccessCoeff(0)));
179 template <
typename Ordinal,
typename TayType>
180 struct SerializationTraitsImp {
191 typedef typename DS::DefaultSerializerType ValueSerializer;
194 typedef SerializationImp<Ordinal,TayType,ValueSerializer> Imp;
199 static const bool supportsDirectSerialization =
200 Imp::supportsDirectSerialization;
207 const TayType buffer[]) {
208 return Imp::fromCountToIndirectBytes(
209 DS::getDefaultSerializer(), count, buffer);
213 static void serialize (
const Ordinal count,
214 const TayType buffer[],
218 DS::getDefaultSerializer(), count, buffer, bytes, charBuffer);
223 const char charBuffer[]) {
224 return Imp::fromIndirectBytesToCount(
225 DS::getDefaultSerializer(), bytes, charBuffer);
229 static void deserialize (
const Ordinal bytes,
230 const char charBuffer[],
234 DS::getDefaultSerializer(), bytes, charBuffer, count, buffer);
242 template <
typename Ordinal,
typename TayType,
typename ValueSerializer>
243 class SerializerImp {
248 typedef SerializationImp<Ordinal,TayType,ValueSerializer> Imp;
259 typedef ValueSerializer value_serializer_type;
262 static const bool supportsDirectSerialization =
263 Imp::supportsDirectSerialization;
271 Ordinal getSerializerSize()
const {
return sz; }
282 const TayType buffer[])
const {
283 return Imp::fromCountToIndirectBytes(*vs, count, buffer, sz);
287 void serialize (
const Ordinal count,
288 const TayType buffer[],
290 char charBuffer[])
const {
291 Imp::serialize(*vs, count, buffer, bytes, charBuffer, sz);
296 const char charBuffer[])
const {
297 return Imp::fromIndirectBytesToCount(*vs, bytes, charBuffer, sz);
301 void deserialize (
const Ordinal bytes,
302 const char charBuffer[],
304 TayType buffer[])
const {
305 return Imp::deserialize(*vs, bytes, charBuffer, count, buffer, sz);
316 #endif // HAVE_SACADO_TEUCHOSCOMM
318 #endif // SACADO_FAD_SERIALIZATIONTRAITSIMP_HPP