SST 15.0
Structural Simulation Toolkit
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
17namespace SST::Core::Serialization {
18
20{
21public:
22 using clear_fxn = void (*)(void);
23
24 static void register_finish(clear_fxn fxn);
25
26 static void finish();
27
28protected:
29 static std::list<clear_fxn>* fxns_;
30};
31
32template <class T>
33class need_delete_statics
34{
35public:
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:20