GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
singleton-cleanup.h
Go to the documentation of this file.
1 #if !defined (octave_singleton_cleanup_h)
2 #define octave_singleton_cleanup_h 1
3 
4 #include <set>
5 
6 class
7 OCTAVE_API
9 {
10 protected:
11 
12  singleton_cleanup_list (void) : fcn_list () { }
13 
14 public:
15 
16  typedef void (*fptr) (void);
17 
18  ~singleton_cleanup_list (void);
19 
20  static void add (fptr f)
21  {
22  if (instance_ok ())
23  instance->do_add (f);
24  }
25 
26  static void cleanup (void) { delete instance; instance = 0; }
27 
28 private:
29 
31 
32  static bool instance_ok (void);
33 
34  static void cleanup_instance (void) { delete instance; instance = 0; }
35 
36  std::set<fptr> fcn_list;
37 
38  void do_add (fptr f)
39  {
40  fcn_list.insert (f);
41  }
42 
43  // No copying!
44 
46 
48 };
49 
50 #endif