Logo ROOT   6.14/05
Reference Guide
Config.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Fredrik Tegenfeldt, Helge Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : Config *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Implementation *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
16  * Fredrik Tegenfeldt <Fredrik.Tegenfeldt@cern.ch> - Iowa State U., USA *
17  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, GER *
18  * *
19  * Copyright (c) 2006: *
20  * CERN, Switzerland *
21  * Iowa State U., USA *
22  * MPI-K Heidelberg, Germany *
23  * *
24  * Redistribution and use in source and binary forms, with or without *
25  * modification, are permitted according to the terms listed in LICENSE *
26  * (http://mva.sourceforge.net/license.txt) *
27  **********************************************************************************/
28 
29 /*! \class TMVA::Config
30 \ingroup TMVA
31 
32 Singleton class for global configuration settings used by TMVA.
33 
34 */
35 
36 #include "TMVA/Config.h"
37 #include "TMVA/MsgLogger.h"
38 
39 #include "Rtypes.h"
40 #include "TString.h"
41 #include "TSystem.h"
42 
44 
45 #if __cplusplus > 199711L
46 std::atomic<TMVA::Config*> TMVA::Config::fgConfigPtr{ 0 };
47 #else
49 #endif
50 
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// constructor - set defaults
55 
57  fDrawProgressBar ( kFALSE ),
58  fNWorkers (1),
59  fUseColoredConsole ( kTRUE ),
60  fSilent ( kFALSE ),
61  fWriteOptionsReference( kFALSE ),
62  fLogger (new MsgLogger("Config"))
63 {
64  // plotting
69 
73 
74  // IO names
75  fIONames.fWeightFileDir = "weights";
76  fIONames.fWeightFileExtension = "weights";
77  fIONames.fOptionsReferenceFileDir = "optionInfo";
78 
79  // get number of CPU
80  SysInfo_t s;
81  gSystem->GetSysInfo(&s);
82  fNCpu = s.fCpus;
83 
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 /// destructor
88 
90 {
91  delete fLogger;
92 }
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// static function: destroy TMVA instance
96 
98 {
99 #if __cplusplus > 199711L
100  delete fgConfigPtr.exchange(0);
101 #else
102  if (fgConfigPtr != 0) { delete fgConfigPtr; fgConfigPtr = 0;}
103 #endif
104 }
105 
106 ////////////////////////////////////////////////////////////////////////////////
107 /// static function: returns TMVA instance
108 
110 {
111 #if __cplusplus > 199711L
112  if(!fgConfigPtr) {
113  TMVA::Config* tmp = new Config();
114  TMVA::Config* expected = 0;
115  if(! fgConfigPtr.compare_exchange_strong(expected,tmp) ) {
116  //another thread beat us to the switch
117  delete tmp;
118  }
119  }
120  return *fgConfigPtr;
121 #else
122  return fgConfigPtr ? *fgConfigPtr :*(fgConfigPtr = new Config());
123 #endif
124 }
125 
TString fOptionsReferenceFileDir
Definition: Config.h:114
Int_t fMaxNumOfAllowedVariablesForScatterPlots
Definition: Config.h:100
UInt_t fNCpu
Definition: Config.h:58
static Config * fgConfigPtr
Definition: Config.h:128
Config & gConfig()
static Config & Instance()
static function: returns TMVA instance
Definition: Config.cxx:109
MsgLogger * fLogger
Definition: Config.h:145
Singleton class for global configuration settings used by TMVA.
Definition: Config.h:53
virtual int GetSysInfo(SysInfo_t *info) const
Returns static system info, like OS type, CPU type, number of CPUs RAM size, etc into the SysInfo_t s...
Definition: TSystem.cxx:2487
TString fWeightFileDir
Definition: Config.h:112
class TMVA::Config::IONames fIONames
TString fWeightFileExtension
Definition: Config.h:113
Int_t fCpus
Definition: TSystem.h:155
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
class TMVA::Config::VariablePlotting fVariablePlotting
const Bool_t kFALSE
Definition: RtypesCore.h:88
#define ClassImp(name)
Definition: Rtypes.h:359
static void DestroyInstance()
static function: destroy TMVA instance
Definition: Config.cxx:97
static constexpr double s
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual ~Config()
destructor
Definition: Config.cxx:89
Config()
constructor - set defaults
Definition: Config.cxx:56