SST  10.1.0
StructuralSimulationToolkit
serialize_deque.h
1 // Copyright 2009-2020 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-2020, 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 SERIALIZE_DEQUE_H
13 #define SERIALIZE_DEQUE_H
14 
15 #include <deque>
16 #include "sst/core/serialization/serializer.h"
17 
18 namespace SST {
19 namespace Core {
20 namespace Serialization {
21 
22 template <class T>
23 class serialize<std::deque<T> > {
24  typedef std::deque<T> Deque;
25 
26 public:
27  void
28  operator()(Deque& v, serializer& ser) {
29  switch(ser.mode()) {
30  case serializer::SIZER: {
31  size_t size = v.size();
32  ser.size(size);
33  for (auto it = v.begin(); it != v.end(); ++it){
34  T& t = const_cast<T&>(*it);
35  serialize<T>()(t,ser);
36  }
37  break;
38  }
39  case serializer::PACK: {
40  size_t size = v.size();
41  ser.pack(size);
42  for (auto it = v.begin(); it != v.end(); ++it){
43  T& t = const_cast<T&>(*it);
44  serialize<T>()(t,ser);
45  }
46  break;
47  }
48  case serializer::UNPACK: {
49  size_t size;
50  ser.unpack(size);
51  for (int i=0; i < size; ++i){
52  T t;
53  serialize<T>()(t,ser);
54  v.push_back(t);
55  }
56  break;
57  }
58  }
59  }
60 };
61 
62 }
63 }
64 }
65 #endif // 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:35
Base serialize class.
Definition: serialize.h:33