/usr/include/root/TMVA/ClassifierFactory.h is in libroot-tmva-dev 5.34.30-0ubuntu8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | // @(#)Root/tmva $Id$
// Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss
/**********************************************************************************
* Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
* Package: TMVA *
* Class : Factory *
* Web : http://tmva.sourceforge.net *
* *
* Description: *
* This template creates ClassifierFactory stores creator functors *
* to template parameter class. ClassifierFactory is a singelton class *
* which is explicitly deleted. *
* *
* Authors (alphabetical): *
* Joerg Stelzer <stelzer@cern.ch> - DESY, Germany *
* *
* Copyright (c) 2008: *
* DESY, Germany *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted according to the terms listed in LICENSE *
* (http://tmva.sourceforge.net/LICENSE) *
**********************************************************************************/
#ifndef ROOT_TMVA_ClassifierFactory
#define ROOT_TMVA_ClassifierFactory
/////////////////////////////////////////////////////////////////
///
/// Abstract ClassifierFactory template that handles arbitrary types
///
/// This template creates ClassifierFactory stores creator functors
/// to template parameter class. ClassifierFactory is a singelton class
/// which is explicitly deleted.
///
/// Source: Andrei Alexandrescu, Modern C++ Design
///
/////////////////////////////////////////////////////////////////
// C++
#include <map>
#include <string>
#include <vector>
// Local
#ifndef ROOT_TString
#include "TString.h"
#endif
namespace TMVA {
class IMethod;
class DataSetInfo;
class ClassifierFactory {
public:
// typedef for functor that creates object of class IMethod
typedef IMethod* (*Creator)(const TString& job, const TString& title,
DataSetInfo& dsi, const TString& option );
public:
static ClassifierFactory& Instance();
static void DestroyInstance();
Bool_t Register ( const std::string &name, Creator creator );
Bool_t Unregister( const std::string &name );
IMethod* Create ( const std::string &name,
const TString& job,
const TString& title,
DataSetInfo& dsi,
const TString& option );
IMethod* Create ( const std::string &name,
DataSetInfo& dsi,
const TString& weightfile ="" );
const std::vector<std::string> List() const;
void Print() const;
private:
// must use Instance() method to access/create ClassifierFactory
ClassifierFactory() {}
~ClassifierFactory() {}
// ClassifierFactory is singleton and can not be copied
// These two methods are private and not defined by design
ClassifierFactory( const ClassifierFactory& );
const ClassifierFactory& operator =(const ClassifierFactory& );
private:
static ClassifierFactory *fgInstance;
typedef std::map<std::string, Creator> CallMap;
CallMap fCalls;
};
}
/////////////////////////////////////////////////////////////////
///
/// for example
///
/// REGISTER_METHOD(Fisher)
///
/// expands to this code:
///
/// namespace
/// {
/// TMVA::IMethod* CreateMethod()
/// {
/// return (TMVA::IMethod*) new TMVA::MethodFisher;
/// }
/// Bool_t RegisteredMethod = TMVA::ClassifierFactory<TMVA::MethodBase>::Instance().
/// Register("Method", CreateMethodFisher);
/// }
///
/////////////////////////////////////////////////////////////////
#define REGISTER_METHOD(CLASS) \
namespace \
{ \
TMVA::IMethod* CreateMethod##CLASS(const TString& job, const TString& title, TMVA::DataSetInfo& dsi, const TString& option) \
{ \
if(job=="" && title=="") { \
return (TMVA::IMethod*) new TMVA::Method##CLASS(dsi, option); \
} else { \
return (TMVA::IMethod*) new TMVA::Method##CLASS(job, title, dsi, option); \
} \
} \
Bool_t RegisteredMethod = TMVA::ClassifierFactory::Instance(). \
Register(#CLASS, CreateMethod##CLASS); \
Bool_t AddedTypeMapping = TMVA::Types::Instance().AddTypeMapping(TMVA::Types::k##CLASS, #CLASS); \
}
#endif
|