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