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