00001 /***************************************************************************** 00002 * Project: RooFit * 00003 * Package: RooFitCore * 00004 * @(#)root/roofitcore:$Id: RooSentinel.cxx 34064 2010-06-22 15:05:19Z wouter $ 00005 * Authors: * 00006 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu * 00007 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu * 00008 * * 00009 * Copyright (c) 2000-2005, Regents of the University of California * 00010 * and Stanford University. All rights reserved. * 00011 * * 00012 * Redistribution and use in source and binary forms, * 00013 * with or without modification, are permitted according to the terms * 00014 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) * 00015 *****************************************************************************/ 00016 00017 ////////////////////////////////////////////////////////////////////////////// 00018 // 00019 // BEGIN_HTML 00020 // RooSentinel is a special purposes singleton class that terminates 00021 // all other RooFit singleton services when the process exists. 00022 // 00023 // All function RooFit singleton services are created on the heap with 00024 // a static wrapper function to avoid the 'static initialization order fiasco' 00025 // but are not automatically destroyed at the end of the session. This class 00026 // installs an atexit() function that takes care of this 00027 // END_HTML 00028 // 00029 00030 #include "RooFit.h" 00031 00032 #include "RooSentinel.h" 00033 #include "RooSentinel.h" 00034 #include "RooMinuit.h" 00035 #include "RooMsgService.h" 00036 #include "RooNumIntConfig.h" 00037 #include "RooNumIntFactory.h" 00038 #include "RooNumGenFactory.h" 00039 #include "RooNumGenConfig.h" 00040 #include "RooNameReg.h" 00041 #include "RooArgSet.h" 00042 #include "RooRealConstant.h" 00043 #include "RooResolutionModel.h" 00044 #include "RooExpensiveObjectCache.h" 00045 #include "RooMath.h" 00046 00047 Bool_t RooSentinel::_active = kFALSE ; 00048 00049 static void CleanUpRooFitAtExit() 00050 { 00051 // Clean up function called at program termination before global objects go out of scope. 00052 RooMinuit::cleanup() ; 00053 RooMsgService::cleanup() ; 00054 RooNumIntConfig::cleanup() ; 00055 RooNumGenConfig::cleanup() ; 00056 RooNumIntFactory::cleanup() ; 00057 RooNumGenFactory::cleanup() ; 00058 RooNameReg::cleanup() ; 00059 RooArgSet::cleanup() ; 00060 RooRealConstant::cleanup() ; 00061 RooResolutionModel::cleanup() ; 00062 RooMath::cleanup() ; 00063 RooExpensiveObjectCache::cleanup() ; 00064 } 00065 00066 00067 00068 //_____________________________________________________________________________ 00069 void RooSentinel::activate() 00070 { 00071 // Install atexit handler that calls CleanupRooFitAtExit() 00072 // on program termination 00073 00074 if (!_active) { 00075 _active = kTRUE ; 00076 atexit(CleanUpRooFitAtExit) ; 00077 } 00078 } 00079 00080 00081