singleton-cleanup.cc

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include <lo-error.h>
00028 #include <singleton-cleanup.h>
00029 
00030 singleton_cleanup_list *singleton_cleanup_list::instance = 0;
00031 
00032 singleton_cleanup_list::~singleton_cleanup_list (void)
00033 {
00034   for (std::set<fptr>::iterator p = fcn_list.begin ();
00035        p != fcn_list.end (); p++)
00036     {
00037       fptr fcn = *p;
00038 
00039       fcn ();
00040     }
00041 }
00042 
00043 bool
00044 singleton_cleanup_list::instance_ok (void)
00045 {
00046   bool retval = true;
00047 
00048   if (! instance)
00049     instance = new singleton_cleanup_list ();
00050 
00051   if (! instance)
00052     {
00053       current_liboctave_error_handler
00054         ("unable to create singleton_cleanup_list object!");
00055 
00056       retval = false;
00057     }
00058 
00059   return retval;
00060 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines