|
[Rivet-svn] r2623 - in trunk: include/Rivet src/Coreblackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri Jul 30 00:35:56 BST 2010
Author: buckley Date: Fri Jul 30 00:35:56 2010 New Revision: 2623 Log: Improved HistoHandler singleton Modified: trunk/include/Rivet/HistoHandler.hh trunk/src/Core/HistoHandler.cc Modified: trunk/include/Rivet/HistoHandler.hh ============================================================================== --- trunk/include/Rivet/HistoHandler.hh Fri Jul 30 00:32:27 2010 (r2622) +++ trunk/include/Rivet/HistoHandler.hh Fri Jul 30 00:35:56 2010 (r2623) @@ -25,17 +25,13 @@ /// class HistoHandler { private: - + /// @name Construction. */ //@{ /// The standard constructor. HistoHandler() { } //@} - /// Singleton instance - /// @todo Threading? - static HistoHandler* _instance; - /// Private destructor means no inheritance from this class. ~HistoHandler(); @@ -48,12 +44,11 @@ public: - /// Singleton creation function - static HistoHandler* create(); - - - /// Singleton deletion function - static void destroy(); + /// Singleton getter function + static HistoHandler& getInstance() { + static HistoHandler _instance; + return _instance; + } //////////////////////////////////////////////////////// Modified: trunk/src/Core/HistoHandler.cc ============================================================================== --- trunk/src/Core/HistoHandler.cc Fri Jul 30 00:32:27 2010 (r2622) +++ trunk/src/Core/HistoHandler.cc Fri Jul 30 00:35:56 2010 (r2623) @@ -8,26 +8,6 @@ namespace Rivet { - // Initialize instance pointer to null. - HistoHandler* HistoHandler::_instance = 0; - - - HistoHandler* HistoHandler::create() { - if (!_instance) { - _instance = new HistoHandler(); - Log::getLog("Rivet.HistoHandler") - << Log::TRACE << "Created new HistoHandler at " - << _instance << endl; - } - return _instance; - } - - - void HistoHandler::destroy() { - delete _instance; - } - - // Get a logger. Log& HistoHandler::getLog() const { return Log::getLog("Rivet.HistoHandler"); @@ -52,7 +32,7 @@ << " analysis object " << &ao << " for parent " << &parent << "(" << parent.name() << ")" << " with name '" << name << "'" << endl; - + // If this name is already registered for this analysis, throw a complaint NamedHistosMap::const_iterator nhs = _namedhistos.find(&parent); if (nhs != _namedhistos.end()) {
More information about the Rivet-svn mailing list |