SST  14.1.0
StructuralSimulationToolkit
serialize_list.h
1 // Copyright 2009-2024 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-2024, 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_IMPL_SERIALIZE_LIST_H
13 #define SST_CORE_SERIALIZATION_IMPL_SERIALIZE_LIST_H
14 
15 #ifndef SST_INCLUDING_SERIALIZE_H
16 #warning \
17  "The header file sst/core/serialization/impl/serialize_list.h should not be directly included as it is not part of the stable public API. The file is included in sst/core/serialization/serialize.h"
18 #endif
19 
20 #include "sst/core/serialization/serializer.h"
21 
22 #include <list>
23 
24 namespace SST {
25 namespace Core {
26 namespace Serialization {
27 
28 template <class T>
29 class serialize_impl<std::list<T>>
30 {
31  typedef std::list<T> List;
32 
33 public:
34  void operator()(List& v, serializer& ser)
35  {
36  typedef typename List::iterator iterator;
37  switch ( ser.mode() ) {
38  case serializer::SIZER:
39  {
40  size_t size = v.size();
41  ser.size(size);
42  iterator it, end = v.end();
43  for ( it = v.begin(); it != end; ++it ) {
44  T& t = *it;
45  ser& t;
46  }
47  break;
48  }
49  case serializer::PACK:
50  {
51  size_t size = v.size();
52  ser.pack(size);
53  iterator it, end = v.end();
54  for ( it = v.begin(); it != end; ++it ) {
55  T& t = *it;
56  ser& t;
57  }
58  break;
59  }
60  case serializer::UNPACK:
61  {
62  size_t size;
63  ser.unpack(size);
64  for ( size_t i = 0; i < size; ++i ) {
65  T t;
66  ser& t;
67  v.push_back(t);
68  }
69  break;
70  }
71  case serializer::MAP:
72  // The version of function not called in mapping mode
73  break;
74  }
75  }
76 
77  void operator()(List& UNUSED(v), serializer& UNUSED(ser), const char* UNUSED(name))
78  {
79  // TODO: Add support for mapping mode
80  }
81 };
82 
83 } // namespace Serialization
84 } // namespace Core
85 } // namespace SST
86 
87 #endif // SST_CORE_SERIALIZATION_IMPL_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:43
Base serialize class.
Definition: serialize.h:45
Definition: action.cc:18