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