GENIEGenerator
Loading...
Searching...
No Matches
AlgFactory.h
Go to the documentation of this file.
1//____________________________________________________________________________
2/*!
3
4\class genie::AlgFactory
5
6\brief The GENIE Algorithm Factory.
7
8\author Costas Andreopoulos <c.andreopoulos \at cern.ch>
9 University of Liverpool
10
11\created May 12, 2004
12
13\cpright Copyright (c) 2003-2025, The GENIE Collaboration
14 For the full text of the license visit http://copyright.genie-mc.org
15*/
16//____________________________________________________________________________
17
18#ifndef _ALG_FACTORY_H_
19#define _ALG_FACTORY_H_
20
21#include <map>
22#include <string>
23#include <iostream>
24
26
27using std::map;
28using std::pair;
29using std::string;
30using std::ostream;
31
32namespace genie {
33
34class Algorithm;
35class AlgFactory;
36
37ostream & operator << (ostream & stream, const genie::AlgFactory & algf);
38
40
41public:
42 static AlgFactory * Instance();
43
44 //! Instantiates, configures and returns a pointer to the specified algorithm.
45 //! The algorithm is placed at the AlgFactory pool (is owned by the factory)
46 //! from where it will be looked up at subsequent calls.
47 const Algorithm * GetAlgorithm (const AlgId & algid);
48 const Algorithm * GetAlgorithm (string name, string conf="Default");
49
50 //! Like GetAlgorithm() but the algorithm is not placed at the AlgFactory pool
51 //! and its ownership is transfered to the caller
52 Algorithm * AdoptAlgorithm (const AlgId & algid) const;
53 Algorithm * AdoptAlgorithm (string name, string conf="Default") const;
54
55 //! Forces a reconfiguration of all algorithms kept at the factory pool.
56 //! The algorithms look up their nominal configuration from the config pool.
57 //! Use that to propagate modifications made directly at the config pool.
58 void ForceReconfiguration(bool ignore_alg_opt_out=false);
59
60 //! print algorithm factory
61 void Print(ostream & stream) const;
62 friend ostream & operator << (ostream & stream, const AlgFactory & algf);
63
64private:
65 AlgFactory();
66 AlgFactory(const AlgFactory & alg_factory);
67 virtual ~AlgFactory();
68
69 //! method instantiating (based on TClass * TROOT::GetClass(name))
70 //! & configuring algorithmic objects
71 Algorithm * InstantiateAlgorithm(string name, string config) const;
72
73 //! sinleton's self
75
76 //! 'algorithm key' (namespace::name/config) -> 'algorithmic object' map
77 map<string, Algorithm *> fAlgPool;
78
79 //! singleton cleaner
80 struct Cleaner {
83 if (AlgFactory::fInstance !=0) {
86 }
87 }
88 };
89 friend struct Cleaner;
90};
91
92} // genie namespace
93
94#endif // _ALG_FACTORY_H_
The GENIE Algorithm Factory.
Definition AlgFactory.h:39
const Algorithm * GetAlgorithm(const AlgId &algid)
static AlgFactory * Instance()
map< string, Algorithm * > fAlgPool
'algorithm key' (namespace::name/config) -> 'algorithmic object' map
Definition AlgFactory.h:77
virtual ~AlgFactory()
Algorithm * AdoptAlgorithm(const AlgId &algid) const
Algorithm * InstantiateAlgorithm(string name, string config) const
static AlgFactory * fInstance
sinleton's self
Definition AlgFactory.h:74
void Print(ostream &stream) const
print algorithm factory
AlgFactory(const AlgFactory &alg_factory)
void ForceReconfiguration(bool ignore_alg_opt_out=false)
friend ostream & operator<<(ostream &stream, const AlgFactory &algf)
Algorithm ID (algorithm name + configuration set name)
Definition AlgId.h:34
Algorithm abstract base class.
Definition Algorithm.h:54
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
singleton cleaner
Definition AlgFactory.h:80