SST  15.1.0
StructuralSimulationToolkit
statics.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_SERIALIZATION_STATICS_H
13 #define SST_CORE_SERIALIZATION_STATICS_H
14 
15 #include <list>
16 
17 namespace SST::Core::Serialization {
18 
19 class statics
20 {
21 public:
22  using clear_fxn = void (*)(void);
23 
24  static void register_finish(clear_fxn fxn);
25 
26  static void finish();
27 
28 protected:
29  static std::list<clear_fxn>* fxns_;
30 };
31 
32 template <class T>
34 {
35 public:
36  need_delete_statics() { statics::register_finish(&T::delete_statics); }
37 };
38 
39 #define free_static_ptr(x) \
40  if ( x ) delete x; \
41  x = 0
42 
43 } // namespace SST::Core::Serialization
44 
45 #endif // SST_CORE_SERIALIZATION_STATICS_H
Definition: statics.h:19