view liboctave/util/singleton-cleanup.h @ 21210:4f7d3989c462

move UMFPACK_DNAME and UMFPACK_ZNAME macros to oct-sparse.h * oct-sparse.h: Define internal UMFPACK_DNAME and UMFPACK_ZNAME macros here instead of in the CSparse.h and dSparse.h public header files.
author John W. Eaton <jwe@octave.org>
date Sat, 06 Feb 2016 07:43:32 -0500
parents f7084eae3318
children 1473547f50f5
line wrap: on
line source

#if ! defined (octave_singleton_cleanup_h)
#define octave_singleton_cleanup_h 1

#include <set>

class
OCTAVE_API
singleton_cleanup_list
{
protected:

  singleton_cleanup_list (void) : fcn_list () { }

public:

  typedef void (*fptr) (void);

  ~singleton_cleanup_list (void);

  static void add (fptr f)
  {
    if (instance_ok ())
      instance->do_add (f);
  }

  static void cleanup (void) { delete instance; instance = 0; }

private:

  static singleton_cleanup_list *instance;

  static bool instance_ok (void);

  static void cleanup_instance (void) { delete instance; instance = 0; }

  std::set<fptr> fcn_list;

  void do_add (fptr f)
  {
    fcn_list.insert (f);
  }

  // No copying!

  singleton_cleanup_list (const singleton_cleanup_list&);

  singleton_cleanup_list& operator = (const singleton_cleanup_list&);
};

#endif