42 #if __cplusplus > 199711L && !defined _MSC_VER
46 #if __cplusplus > 199711L && !defined _MSC_VER
47 std::atomic<TMVA::Types*> TMVA::Types::fgTypesPtr{0};
48 static std::mutex gTypesMutex;
50 TMVA::Types* TMVA::Types::fgTypesPtr = 0;
57 : fLogger( new MsgLogger(
"Types") )
70 TMVA::Types& TMVA::Types::Instance()
72 #if __cplusplus > 199711L && !defined _MSC_VER
74 Types* tmp =
new Types();
76 if(!fgTypesPtr.compare_exchange_strong(expected,tmp)) {
83 return fgTypesPtr ? *fgTypesPtr : *(fgTypesPtr =
new Types());
90 void TMVA::Types::DestroyInstance()
92 #if __cplusplus > 199711L && !defined _MSC_VER
93 if (fgTypesPtr != 0) {
delete fgTypesPtr.load(); fgTypesPtr = 0; }
95 if (fgTypesPtr != 0) {
delete fgTypesPtr; fgTypesPtr = 0; }
101 Bool_t TMVA::Types::AddTypeMapping( Types::EMVA method,
const TString& methodname )
103 #if __cplusplus > 199711L && !defined _MSC_VER
104 std::lock_guard<std::mutex> guard(gTypesMutex);
106 std::map<TString, EMVA>::const_iterator it = fStr2type.find( methodname );
107 if (it != fStr2type.end()) {
109 <<
"Cannot add method " << methodname
110 <<
" to the name->type map because it exists already" << Endl;
114 fStr2type[methodname] = method;
121 TMVA::Types::EMVA TMVA::Types::GetMethodType(
const TString& method )
const
123 #if __cplusplus > 199711L && !defined _MSC_VER
124 std::lock_guard<std::mutex> guard(gTypesMutex);
126 std::map<TString, EMVA>::const_iterator it = fStr2type.find( method );
127 if (it == fStr2type.end()) {
128 Log() << kFATAL <<
"Unknown method in map: " << method << Endl;
131 else return it->second;
136 TString TMVA::Types::GetMethodName( TMVA::Types::EMVA method )
const
138 #if __cplusplus > 199711L && !defined _MSC_VER
139 std::lock_guard<std::mutex> guard(gTypesMutex);
141 std::map<TString, EMVA>::const_iterator it = fStr2type.begin();
142 for (; it!=fStr2type.end(); ++it)
if (it->second == method)
return it->first;
143 Log() << kFATAL <<
"Unknown method index in map: " << method << Endl;