gtestConfigPool.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \program gtestConfigPool
5 
6 \brief Program used for testing / debugging GENIE's AlgConfigPool
7 
8 \author Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
9  University of Liverpool & STFC Rutherford Appleton Laboratory
10 
11 \created May 4, 2004
12 
13 \cpright Copyright (c) 2003-2020, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15 
16 */
17 //____________________________________________________________________________
18 
25 
26 using namespace genie;
27 
28 int main(int /*argc*/, char ** /*argv*/)
29 {
30  // Get an instance of the ConfigPool
31  LOG("test", pINFO) << "Get config pool instance";
33 
34  // Print the ConfigPool ( => print all its configuration registries )
35  LOG("test", pINFO) << "Printing the config pool\n" << *pool;
36 
37  // Get the algorithm factory
39 
40  // Instantiate an algorithm
41  LOG("test", pINFO) << "Instantiate a concrete algorithm";
42  const Algorithm * alg0 =
43  algf->GetAlgorithm("genie::LwlynSmithFFCC","Default");
44  const QELFormFactorsModelI * llewellyn_smith =
45  dynamic_cast<const QELFormFactorsModelI *> (alg0);
46  LOG("test", pINFO) << *alg0;
47 
48  LOG("test", pINFO) << "Instantiate another concrete algorithm";
49  const Algorithm * alg1 =
50  algf->GetAlgorithm("genie::DipoleELFormFactorsModel","Default");
51  const ELFormFactorsModelI * dipole_elff =
52  dynamic_cast<const ELFormFactorsModelI *> (alg1);
53  LOG("test", pINFO) << *alg1;
54 
55  // Ask the ConfigPool for this algorithm's config registry and print it
56 
57  LOG("test", pINFO) << "Find the configuration for both algorithms";
58 
59  Registry * config1 = pool->FindRegistry( llewellyn_smith );
60  Registry * config2 = pool->FindRegistry( dipole_elff );
61 
62  if(config1) LOG("test", pINFO) << "1st algorithm config: \n" << *config1;
63  if(config2) LOG("test", pINFO) << "2nd algorithm config: \n" << *config2;
64 
65  return 0;
66 }
67 
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:40
Algorithm abstract base class.
Definition: Algorithm.h:53
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
Pure abstract base class. Defines the QELFormFactorsModelI interface to be implemented by any algorit...
Pure abstract base class. Defines the ELFormFactorsModelI interface to be implemented by any algorith...
const Algorithm * GetAlgorithm(const AlgId &algid)
Definition: AlgFactory.cxx:75
#define pINFO
Definition: Messenger.h:62
int main(int, char **)
static AlgFactory * Instance()
Definition: AlgFactory.cxx:64
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
Registry * FindRegistry(string key) const
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
static AlgConfigPool * Instance()