1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
|
//=========================================================================
// ProcessItem.hh
//
// We will employ a compile-time visitor pattern. The idea
// is to replace function calls (which are difficult to develop)
// with partial template specializations (which are relatively
// easy to develop).
//
// The call signature of the visitor will be
//
// bool InspectingVisitor<Arg1, Arg2, T, Stage>::process(
// const T&, Arg1&, Arg2*, const bool processClassId);
//
// or
//
// bool ModifyingVisitor<Arg1, Arg2, T, Stage>::process(
// T&, Arg1&, Arg2*, const bool processClassId);
//
// The processing will be terminated as soon as any call to
// the visitor's process function returns "false".
//
// I. Volobouev
// October 2010
//=========================================================================
#ifndef GENERS_PROCESSITEM_HH_
#define GENERS_PROCESSITEM_HH_
#include "Alignment/Geners/interface/IOTraits.hh"
#include "Alignment/Geners/interface/Int2Type.hh"
namespace gs {
// Special types to designate stages in container processing
struct InContainerHeader {
static const char *stage() { return "InContainerHeader"; }
};
struct InContainerSize {
static const char *stage() { return "InContainerSize"; }
};
struct InContainerFooter {
static const char *stage() { return "InContainerFooter"; }
};
struct InContainerCycle {
static const char *stage() { return "InContainerCycle"; }
};
struct InPODArray {
static const char *stage() { return "InPODArray"; }
};
} // namespace gs
// I am not aware of an easy way to have both const and non-const
// version of a template defined in the same code fragment. This is
// why you see some preprocessor tricks below -- the alternative
// of maintaining separate const and non-const codes is much worse.
#ifdef GENERS_GENERATE_CONST_IO_PROCESSOR
#undef GENERS_GENERATE_CONST_IO_PROCESSOR
#endif
//
// This is an internal header. Applications should NEVER use it directly.
//
#ifdef GENERS_GENERATED_IO_PROCESSOR
#undef GENERS_GENERATED_IO_PROCESSOR
#endif
#ifdef GENERS_GENERATED_IO_CONSTNESS
#undef GENERS_GENERATED_IO_CONSTNESS
#endif
#ifdef GENERS_CONTAINER_ITERATION_PROC
#undef GENERS_CONTAINER_ITERATION_PROC
#endif
#ifdef GENERS_GENERIC_ITEM_PROCESSOR
#undef GENERS_GENERIC_ITEM_PROCESSOR
#endif
#ifdef GENERS_GENERATE_CONST_IO_PROCESSOR
#define GENERS_GENERATED_IO_PROCESSOR ProcessItemLVL1
#define GENERS_GENERATED_IO_CONSTNESS const
#define GENERS_CONTAINER_ITERATION_PROC iterate_const_container
#define GENERS_GENERIC_ITEM_PROCESSOR process_const_item
#else
#define GENERS_GENERATED_IO_PROCESSOR ProcessItemLVL2
#define GENERS_GENERATED_IO_CONSTNESS
#define GENERS_CONTAINER_ITERATION_PROC iterate_container
#define GENERS_GENERIC_ITEM_PROCESSOR process_item
#endif
namespace gs {
namespace Private {
template <template <typename, typename, typename, typename> class Visitor,
typename T,
typename Arg1,
typename Arg2,
int Mode>
struct GENERS_GENERATED_IO_PROCESSOR;
}
} // namespace gs
namespace gs {
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
bool GENERS_GENERIC_ITEM_PROCESSOR(GENERS_GENERATED_IO_CONSTNESS T &obj,
Arg1 &a1,
Arg2 *p2,
const bool processClassId) {
// The following works like a compile-time "switch" statement.
// This switch is too high level to be implemented using types,
// so we must do something like what is coded below.
typedef IOTraits<T> M;
return Private::GENERS_GENERATED_IO_PROCESSOR<
Visitor,
T,
Arg1,
Arg2,
M::Signature &(M::ISPOD | M::ISSTDCONTAINER | M::ISWRITABLE | M::ISPOINTER | M::ISSHAREDPTR | M::ISIOPTR |
M::ISPAIR | M::ISSTRING | M::ISTUPLE | M::ISEXTERNAL)>::process(obj, a1, p2, processClassId);
}
} // namespace gs
namespace gs {
namespace Private {
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_CONTAINER_ITERATION_PROC {
#ifdef GENERS_GENERATE_CONST_IO_PROCESSOR
static bool process(const T &v, Arg1 &a1, Arg2 *p2, std::size_t) {
bool itemStatus = true;
typename T::const_iterator end = v.end();
for (typename T::const_iterator it = v.begin(); it != end && itemStatus; ++it)
itemStatus = process_const_item<Visitor>(*it, a1, p2, false);
return itemStatus;
}
#else
static bool process(T &obj, Arg1 &a1, Arg2 *p2, const std::size_t newSize) {
bool itemStatus = true;
for (std::size_t i = 0; i < newSize && itemStatus; ++i)
itemStatus = Visitor<Arg1, Arg2, T, InContainerCycle>::process(obj, a1, p2, i);
return itemStatus;
}
#endif
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISPOD> {
// POD-processing visitor
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISPOD>>::process(obj, a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISWRITABLE> {
// Processor of writable objects
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISWRITABLE>>::process(obj, a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISPOINTER> {
// There is not enough info here to decide how the pointer
// should be managed. Therefore, just call the visitor.
// However, turn on the class id writing because pointer
// usually signifies polymorphic class.
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, bool /* processClassId */) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISPOINTER>>::process(obj, a1, p2, true);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISIOPTR> {
// There is not enough info here to decide how the pointer
// should be managed. Therefore, just call the visitor.
// In this particular case, we are passing the "processClassId"
// value as is.
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, typename T::element_type *, Int2Type<IOTraits<int>::ISPOINTER>>::process(
obj.getIOReference(), a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISSHAREDPTR> {
// There is not enough info here to decide how the shared pointer
// should be managed. Therefore, just call the visitor.
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, bool /* processClassId */) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISSHAREDPTR>>::process(obj, a1, p2, true);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISPAIR> {
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISPAIR>>::process(obj, a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISTUPLE> {
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISTUPLE>>::process(obj, a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISEXTERNAL> {
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISEXTERNAL>>::process(obj, a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISSTRING> {
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISSTRING>>::process(obj, a1, p2, processClassId);
}
};
// Processing of containers which do not support "write",
// "read" or "restore"
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISSTDCONTAINER> {
private:
// The following function will be fired on containers which
// store PODs contiguously
static bool process2(
GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId, Int2Type<true>) {
return Visitor<Arg1, Arg2, T, InPODArray>::process(obj, a1, p2, processClassId);
}
// The following function will be fired on containers which
// do not not store PODs contiguously
static bool process2(
GENERS_GENERATED_IO_CONSTNESS T &v, Arg1 &a1, Arg2 *p2, const bool processClassId, Int2Type<false>) {
GENERS_GENERATED_IO_CONSTNESS std::size_t sz = v.size();
return Visitor<Arg1, Arg2, T, InContainerSize>::process(sz, a1, p2, processClassId) &&
GENERS_CONTAINER_ITERATION_PROC<Visitor, T, Arg1, Arg2>::process(v, a1, p2, sz) && sz == v.size();
}
public:
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
if (Visitor<Arg1, Arg2, T, InContainerHeader>::process(obj, a1, p2, processClassId)) {
// Do generic container processing in case the container
// either does not have contiguous storage or its items
// are non-PODs. Otherwise do fast processing.
bool bodyStatus = true, footerStatus = true;
try {
bodyStatus = process2(obj,
a1,
p2,
processClassId,
Int2Type < IOTraits<typename T::value_type>::IsPOD && IOTraits<T>::IsContiguous > ());
} catch (...) {
footerStatus = Visitor<Arg1, Arg2, T, InContainerFooter>::process(obj, a1, p2, processClassId);
throw;
}
footerStatus = Visitor<Arg1, Arg2, T, InContainerFooter>::process(obj, a1, p2, processClassId);
return bodyStatus && footerStatus;
} else
return false;
}
};
} // namespace Private
} // namespace gs
#undef GENERS_GENERATED_IO_PROCESSOR
#undef GENERS_GENERATED_IO_CONSTNESS
#undef GENERS_CONTAINER_ITERATION_PROC
#undef GENERS_GENERIC_ITEM_PROCESSOR
#define GENERS_GENERATE_CONST_IO_PROCESSOR
//
// This is an internal header. Applications should NEVER use it directly.
//
#ifdef GENERS_GENERATED_IO_PROCESSOR
#undef GENERS_GENERATED_IO_PROCESSOR
#endif
#ifdef GENERS_GENERATED_IO_CONSTNESS
#undef GENERS_GENERATED_IO_CONSTNESS
#endif
#ifdef GENERS_CONTAINER_ITERATION_PROC
#undef GENERS_CONTAINER_ITERATION_PROC
#endif
#ifdef GENERS_GENERIC_ITEM_PROCESSOR
#undef GENERS_GENERIC_ITEM_PROCESSOR
#endif
#ifdef GENERS_GENERATE_CONST_IO_PROCESSOR
#define GENERS_GENERATED_IO_PROCESSOR ProcessItemLVL1
#define GENERS_GENERATED_IO_CONSTNESS const
#define GENERS_CONTAINER_ITERATION_PROC iterate_const_container
#define GENERS_GENERIC_ITEM_PROCESSOR process_const_item
#else
#define GENERS_GENERATED_IO_PROCESSOR ProcessItemLVL2
#define GENERS_GENERATED_IO_CONSTNESS
#define GENERS_CONTAINER_ITERATION_PROC iterate_container
#define GENERS_GENERIC_ITEM_PROCESSOR process_item
#endif
namespace gs {
namespace Private {
template <template <typename, typename, typename, typename> class Visitor,
typename T,
typename Arg1,
typename Arg2,
int Mode>
struct GENERS_GENERATED_IO_PROCESSOR;
}
} // namespace gs
namespace gs {
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
bool GENERS_GENERIC_ITEM_PROCESSOR(GENERS_GENERATED_IO_CONSTNESS T &obj,
Arg1 &a1,
Arg2 *p2,
const bool processClassId) {
// The following works like a compile-time "switch" statement.
// This switch is too high level to be implemented using types,
// so we must do something like what is coded below.
typedef IOTraits<T> M;
return Private::GENERS_GENERATED_IO_PROCESSOR<
Visitor,
T,
Arg1,
Arg2,
M::Signature &(M::ISPOD | M::ISSTDCONTAINER | M::ISWRITABLE | M::ISPOINTER | M::ISSHAREDPTR | M::ISIOPTR |
M::ISPAIR | M::ISSTRING | M::ISTUPLE | M::ISEXTERNAL)>::process(obj, a1, p2, processClassId);
}
} // namespace gs
namespace gs {
namespace Private {
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_CONTAINER_ITERATION_PROC {
#ifdef GENERS_GENERATE_CONST_IO_PROCESSOR
static bool process(const T &v, Arg1 &a1, Arg2 *p2, std::size_t) {
bool itemStatus = true;
typename T::const_iterator end = v.end();
for (typename T::const_iterator it = v.begin(); it != end && itemStatus; ++it)
itemStatus = process_const_item<Visitor>(*it, a1, p2, false);
return itemStatus;
}
#else
static bool process(T &obj, Arg1 &a1, Arg2 *p2, const std::size_t newSize) {
bool itemStatus = true;
for (std::size_t i = 0; i < newSize && itemStatus; ++i)
itemStatus = Visitor<Arg1, Arg2, T, InContainerCycle>::process(obj, a1, p2, i);
return itemStatus;
}
#endif
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISPOD> {
// POD-processing visitor
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISPOD>>::process(obj, a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISWRITABLE> {
// Processor of writable objects
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISWRITABLE>>::process(obj, a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISPOINTER> {
// There is not enough info here to decide how the pointer
// should be managed. Therefore, just call the visitor.
// However, turn on the class id writing because pointer
// usually signifies polymorphic class.
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, bool /* processClassId */) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISPOINTER>>::process(obj, a1, p2, true);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISIOPTR> {
// There is not enough info here to decide how the pointer
// should be managed. Therefore, just call the visitor.
// In this particular case, we are passing the "processClassId"
// value as is.
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, typename T::element_type *, Int2Type<IOTraits<int>::ISPOINTER>>::process(
obj.getIOReference(), a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISSHAREDPTR> {
// There is not enough info here to decide how the shared pointer
// should be managed. Therefore, just call the visitor.
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, bool /* processClassId */) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISSHAREDPTR>>::process(obj, a1, p2, true);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISPAIR> {
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISPAIR>>::process(obj, a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISTUPLE> {
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISTUPLE>>::process(obj, a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISEXTERNAL> {
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISEXTERNAL>>::process(obj, a1, p2, processClassId);
}
};
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISSTRING> {
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
return Visitor<Arg1, Arg2, T, Int2Type<IOTraits<int>::ISSTRING>>::process(obj, a1, p2, processClassId);
}
};
// Processing of containers which do not support "write",
// "read" or "restore"
template <template <typename, typename, typename, typename> class Visitor, typename T, typename Arg1, typename Arg2>
struct GENERS_GENERATED_IO_PROCESSOR<Visitor, T, Arg1, Arg2, IOTraits<int>::ISSTDCONTAINER> {
private:
// The following function will be fired on containers which
// store PODs contiguously
static bool process2(
GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId, Int2Type<true>) {
return Visitor<Arg1, Arg2, T, InPODArray>::process(obj, a1, p2, processClassId);
}
// The following function will be fired on containers which
// do not not store PODs contiguously
static bool process2(
GENERS_GENERATED_IO_CONSTNESS T &v, Arg1 &a1, Arg2 *p2, const bool processClassId, Int2Type<false>) {
GENERS_GENERATED_IO_CONSTNESS std::size_t sz = v.size();
return Visitor<Arg1, Arg2, T, InContainerSize>::process(sz, a1, p2, processClassId) &&
GENERS_CONTAINER_ITERATION_PROC<Visitor, T, Arg1, Arg2>::process(v, a1, p2, sz) && sz == v.size();
}
public:
static bool process(GENERS_GENERATED_IO_CONSTNESS T &obj, Arg1 &a1, Arg2 *p2, const bool processClassId) {
if (Visitor<Arg1, Arg2, T, InContainerHeader>::process(obj, a1, p2, processClassId)) {
// Do generic container processing in case the container
// either does not have contiguous storage or its items
// are non-PODs. Otherwise do fast processing.
bool bodyStatus = true, footerStatus = true;
try {
bodyStatus = process2(obj,
a1,
p2,
processClassId,
Int2Type < IOTraits<typename T::value_type>::IsPOD && IOTraits<T>::IsContiguous > ());
} catch (...) {
footerStatus = Visitor<Arg1, Arg2, T, InContainerFooter>::process(obj, a1, p2, processClassId);
throw;
}
footerStatus = Visitor<Arg1, Arg2, T, InContainerFooter>::process(obj, a1, p2, processClassId);
return bodyStatus && footerStatus;
} else
return false;
}
};
} // namespace Private
} // namespace gs
#undef GENERS_GENERATED_IO_PROCESSOR
#undef GENERS_GENERATED_IO_CONSTNESS
#undef GENERS_CONTAINER_ITERATION_PROC
#undef GENERS_GENERIC_ITEM_PROCESSOR
#undef GENERS_GENERATE_CONST_IO_PROCESSOR
#endif // GENERS_PROCESSITEM_HH_
|