SST  9.0.0
StructuralSimulationToolkit
serialize_list.h
1 // Copyright 2009-2019 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-2019, 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_LIST_H
13 #define SERIALIZE_LIST_H
14 
15 #include <list>
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::list<T> > {
24  typedef std::list<T> List;
25 public:
26  void
27  operator()(List& v, serializer& ser) {
28  typedef typename List::iterator iterator;
29  switch(ser.mode())
30  {
31  case serializer::SIZER: {
32  size_t size = v.size();
33  ser.size(size);
34  iterator it, end = v.end();
35  for (it=v.begin(); it != end; ++it){
36  T& t = *it;
37  serialize<T>()(t, ser);
38  }
39  break;
40  }
41  case serializer::PACK: {
42  size_t size = v.size();
43  ser.pack(size);
44  iterator it, end = v.end();
45  for (it=v.begin(); it != end; ++it){
46  T& t = *it;
47  serialize<T>()(t, ser);
48  }
49  break;
50  }
51  case serializer::UNPACK: {
52  size_t size;
53  ser.unpack(size);
54  for (int i=0; i < size; ++i){
55  T t;
56  serialize<T>()(t, ser);
57  v.push_back(t);
58  }
59  break;
60  }
61  }
62 }
63 
64 };
65 
66 }
67 }
68 }
69 #endif // SERIALIZE_LIST_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