GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
singleton-cleanup.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2011-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_singleton_cleanup_h)
27#define octave_singleton_cleanup_h 1
28
29#include "octave-config.h"
30
31#include <set>
32
34{
35protected:
36
37 singleton_cleanup_list () : m_fcn_list () { }
38
39public:
40
41 typedef void (*fptr) ();
42
43 OCTAVE_DISABLE_COPY_MOVE (singleton_cleanup_list)
44
46
47 static void add (fptr f)
48 {
49 if (instance_ok ())
50 s_instance->do_add (f);
51 }
52
53 static void cleanup ()
54 {
55 delete s_instance;
56 s_instance = nullptr;
57 }
58
59private:
60
61 static singleton_cleanup_list *s_instance;
62
63 static bool instance_ok ();
64
65 static void cleanup_instance ()
66 {
67 delete s_instance;
68 s_instance = nullptr;
69 }
70
71 std::set<fptr> m_fcn_list;
72
73 void do_add (fptr f)
74 {
75 m_fcn_list.insert (f);
76 }
77};
78
79#endif
static void add(fptr f)
F77_RET_T const F77_DBLE const F77_DBLE * f
FloatComplex(* fptr)(const FloatComplex &, float, int, octave_idx_type &)
#define OCTAVE_API
Definition main.in.cc:55