Changeset ed58ad


Ignore:
Timestamp:
Mar 11, 2010, 2:29:04 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
0f6f3a, cd032d
Parents:
aee1a3
Message:

Made the errorLogger use the new Singleton framework

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/errorlogger.cpp

    raee1a3 red58ad  
    99#include "errorlogger.hpp"
    1010#include "verbose.hpp"
     11#include "Patterns/Singleton_impl.hpp"
    1112
    1213ofstream null("/dev/null");
    13 
    14 errorLogger* errorLogger::instance = NULL;
    1514int errorLogger::verbosity = 2;
    1615ostream* errorLogger::nix = &null;
     
    2322errorLogger::errorLogger()
    2423{
    25   instance = NULL;
    2624  verbosity = 2;
    2725};
     
    3432}
    3533
    36 /**
    37  * Returns the singleton errorLogger instance.
    38  *
    39  * \return errorLogger instance
    40  */
    41 errorLogger* errorLogger::getInstance() {
    42   if (instance == NULL) {
    43     instance = new errorLogger();
    44   }
    45 
    46   return instance;
    47 }
    48 
    49 
    50 /**
    51  * Purges the current errorLogger instance.
    52  */
    53 void errorLogger::purgeInstance() {
    54   if (instance != NULL) {
    55     delete instance;
    56   }
    57 
    58   instance = NULL;
    59 }
     34CONSTRUCT_SINGLETON(errorLogger)
    6035
    6136/**
  • src/errorlogger.hpp

    raee1a3 red58ad  
    1111#include <iostream>
    1212
     13#include "Patterns/Singleton.hpp"
     14
    1315using namespace std;
    1416
    1517class Verbose;
    1618
    17 class errorLogger {
     19class errorLogger : public Singleton<errorLogger>{
     20  friend class Singleton<errorLogger>;
    1821public :
    1922  static ostream *nix;
    2023  static int verbosity;
    2124
    22   static errorLogger* getInstance();
    23   static void purgeInstance();
    2425  static bool DoOutput();
    2526  static void setVerbosity(int verbosityLevel);
     
    3132  ~errorLogger();
    3233
    33 private:
    34   static errorLogger* instance;
    3534};
    3635
  • src/log.cpp

    raee1a3 red58ad  
    1616void setVerbosity(int verbosityLevel) {
    1717  logger::getInstance().setVerbosity(verbosityLevel);
    18   errorLogger::getInstance()->setVerbosity(verbosityLevel);
     18  errorLogger::getInstance().setVerbosity(verbosityLevel);
    1919}
    2020
     
    3333 * \param indentation level of the message to log
    3434 */
    35 class errorLogger * eLog() {
     35class errorLogger & eLog() {
    3636  return errorLogger::getInstance();
    3737}
Note: See TracChangeset for help on using the changeset viewer.