Rivet: /Users/chrisg/software/rivet/include/Rivet/AnalysisBuilder.hh Source File

| Rivet 3.1.9

AnalysisBuilder.hh
1// -*- C++ -*-
2#ifndef RIVET_AnalysisBuilder_HH
3#define RIVET_AnalysisBuilder_HH
4
5#include "Rivet/Config/RivetCommon.hh"
6#include "Rivet/AnalysisLoader.hh"
7#include "Rivet/Tools/Logging.hh"
8
9namespace Rivet {
10
11
12 // Forward declaration
13 class Analysis;
14
15
17
19 class AnalysisBuilderBase {
20 public:
21
23 AnalysisBuilderBase() = default;
24
26 AnalysisBuilderBase(const string& alias)
27 : _alias(alias) { }
28
30 virtual ~AnalysisBuilderBase() = default;
31
33 virtual unique_ptr<Analysis> mkAnalysis() const = 0;
34
36 string name() const {
37 auto a = mkAnalysis();
38 return a->name();
39 }
40
44 const string& alias() const {
45 return _alias;
46 }
47
48 protected:
49
51 void _register() {
52 AnalysisLoader::_registerBuilder(this);
53 }
54
55 private:
56
58 string _alias;
59
60 };
61
62
64 template <typename T>
65 class AnalysisBuilder : public AnalysisBuilderBase {
66 public:
67
68 AnalysisBuilder() {
69 _register();
70 }
71
72 AnalysisBuilder(const string& alias)
73 : AnalysisBuilderBase(alias)
74 {
75 _register();
76 }
77
78 unique_ptr<Analysis> mkAnalysis() const {
79 return unique_ptr<T>(new T);
80 }
81
82 };
83
85
86}
87
88#endif
Rivet
Definition MC_Cent_pPb.hh:10