SST  11.1.0
StructuralSimulationToolkit
serialize_deque.h
1 // Copyright 2009-2021 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2021, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_SERIALIZATION_SERIALIZE_DEQUE_H
13 #define SST_CORE_SERIALIZATION_SERIALIZE_DEQUE_H
14 
15 #include "sst/core/serialization/serializer.h"
16 
17 #include <deque>
18 
19 namespace SST {
20 namespace Core {
21 namespace Serialization {
22 
23 template <class T>
24 class serialize<std::deque<T>>
25 {
26  typedef std::deque<T> Deque;
27 
28 public:
29  void operator()(Deque& v, serializer& ser)
30  {
31  switch ( ser.mode() ) {
32  case serializer::SIZER:
33  {
34  size_t size = v.size();
35  ser.size(size);
36  for ( auto it = v.begin(); it != v.end(); ++it ) {
37  T& t = const_cast<T&>(*it);
38  serialize<T>()(t, ser);
39  }
40  break;
41  }
42  case serializer::PACK:
43  {
44  size_t size = v.size();
45  ser.pack(size);
46  for ( auto it = v.begin(); it != v.end(); ++it ) {
47  T& t = const_cast<T&>(*it);
48  serialize<T>()(t, ser);
49  }
50  break;
51  }
52  case serializer::UNPACK:
53  {
54  size_t size;
55  ser.unpack(size);
56  for ( int i = 0; i < size; ++i ) {
57  T t;
58  serialize<T>()(t, ser);
59  v.push_back(t);
60  }
61  break;
62  }
63  }
64  }
65 };
66 
67 } // namespace Serialization
68 } // namespace Core
69 } // namespace SST
70 
71 #endif // SST_CORE_SERIALIZATION_SERIALIZE_DEQUE_H
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:34
Base serialize class.
Definition: serialize.h:31