SST  15.1.0
StructuralSimulationToolkit
checkpointableInfo.h
1 // Copyright 2009-2025 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-2025, 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_CHECKPOINTABLE_INFO_H
13 #define SST_CORE_CHECKPOINTABLE_INFO_H
14 
15 #include "sst/core/eli/elibase.h"
16 #include "sst/core/warnmacros.h"
17 
18 #include <cstdint>
19 #include <iostream>
20 #include <string>
21 #include <type_traits>
22 #include <vector>
23 
24 namespace SST::ELI {
25 
26 template <typename, typename = void>
28 {
29  static bool get() { return false; }
30 };
31 
32 template <class T>
33 struct GetCheckpointable<T, std::void_t<decltype(T::ELI_isCheckpointable())>>
34 {
35  static bool get() { return T::ELI_isCheckpointable(); }
36 };
37 
38 
40 {
41 public:
42  bool isCheckpointable() const { return checkpointable_; }
43 
44  void toString(std::ostream& os) const
45  {
46  os << " Checkpointable: " << (checkpointable_ ? "true" : "false") << "\n";
47  }
48 
49  template <class XMLNode>
50  void outputXML(XMLNode* UNUSED(node))
51  {
52  node->SetAttribute("Checkpointable", checkpointable_);
53  }
54 
55 protected:
56  template <class T>
57  explicit ProvidesCheckpointable(T* UNUSED(t)) :
58  checkpointable_(GetCheckpointable<T>::get())
59  {}
60 
61 private:
62  bool checkpointable_;
63 };
64 
65 #define SST_ELI_IS_CHECKPOINTABLE() \
66  static bool ELI_isCheckpointable() \
67  { \
68  return true; \
69  }
70 
71 } // namespace SST::ELI
72 
73 #endif
Definition: checkpointableInfo.h:27
Definition: attributeInfo.h:22
Definition: checkpointableInfo.h:39