Algorithm.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7  University of Liverpool & STFC Rutherford Appleton Laboratory
8 */
9 //____________________________________________________________________________
10 
11 #include <vector>
12 #include <string>
13 #include <sstream>
14 
20 
21 using std::vector;
22 using std::string;
23 using std::endl;
24 
25 using namespace genie;
26 using namespace genie::utils;
27 
28 //____________________________________________________________________________
29 namespace genie
30 {
31  ostream & operator << (ostream & stream, const Algorithm & alg)
32  {
33  alg.Print(stream);
34  return stream;
35  }
36 }
37 //____________________________________________________________________________
39 {
40  this->Initialize();
41 }
42 //____________________________________________________________________________
44 {
45  this->Initialize();
46  fID.SetId(name);
47 }
48 //____________________________________________________________________________
50 {
51  this->Initialize();
52  fID.SetId(name,config);
53  this->FindConfig();
54 }
55 //____________________________________________________________________________
57 {
58  this->DeleteConfig();
59  this->DeleteSubstructure();
60 }
61 //____________________________________________________________________________
63 {
64 // Configure the Algorithm using the input configuration Registry
65 
66  LOG("Algorithm", pNOTICE) << "Input configuration: " << config;
67 
68  if ( config.NEntries() <= 0 ) {
69 
70  LOG("Algorithm", pNOTICE) "Registry " << config.Name() << " is empty. Not added to " << fID.Name();
71  return;
72  }
73 
74  Registry* rp = ExtractLocalConfig( config ) ;
75  if ( rp ) {
76 
77  MergeTopRegistry( *rp ) ;
78  LOG("Algorithm", pNOTICE) << fID.Name() << " merged with external configuration: " << *rp;
79 
80  // The memory handled by this pointer has been copied and needs to be cleared
81  delete rp ;
82  }
83 
84  if(!fOwnsSubstruc) return; // doesn't own substructure
85  if(fOwnedSubAlgMp->size()==0) return; // no sub-algorithms
86 
87  LOG("Algorithm", pNOTICE) << "Configuring algorithms stored at local pool";
88 
89  // loop over local pool algorithms
90 
91  for( AlgMapIter alg_iter = fOwnedSubAlgMp->begin();
92  alg_iter != fOwnedSubAlgMp->end(); ++alg_iter) {
93 
94  string alg_key = alg_iter->first;
95  Algorithm * alg = alg_iter->second;
96 
97  if(!alg) {
98  LOG("Algorithm", pERROR)
99  << "Key: " << alg_key << " points to a null algorithm at local pool";
100  continue;
101  }
102 
103  LOG("Algorithm", pNOTICE) << "Configuring sub-alg: " << alg->Id().Key();
104 
105  rp = ExtractLowerConfig( config, alg_key ) ;
106  if ( rp ) {
107 
108  alg -> Configure( *rp ) ;
109 
110  delete rp ;
111 
112  }
113 
114  }
115 
116 }
117 //____________________________________________________________________________
119 {
120 // Configure the Algorithm looking up at the ConfigPool singleton for a
121 // configuration Registry corresponding to the input named parameter set.
122 
123  fID.SetConfig(config);
124  this->FindConfig();
125 }
126 //____________________________________________________________________________
128 {
129 // Finds its configration Registry from the ConfigPool and gets a pointer to
130 // it. If the Registry comes from the ConfigPool then the Algorithm does not
131 // own its configuration (the ConfigPool singleton keeps the ownership and the
132 // responsibility to -eventually- delete all the Registries it instantiates
133 // by parsing the XML config files).
134 
135  DeleteConfig() ;
136 
138 
139  Registry * config = 0 ;
140 
141  // load the Default config if config is not the default
142  if ( fID.Config() != "Default" ) {
143  config = pool -> FindRegistry( fID.Name(), "Default" );
144  if ( config ) {
145  if ( config -> NEntries() > 0 ) {
146  AddTopRegistry( config, false ) ;
147  LOG("Algorithm", pDEBUG) << "\n" << *config;
148  }
149  }
150  }
151 
152  // Load the right config
153  config = pool->FindRegistry(this);
154 
155  if(!config)
156  // notify & keep whatever config Registry was used before.
157  LOG("Algorithm", pWARN)
158  << "No Configuration available for "
159  << this->Id().Key() << " at the ConfigPool";
160  else {
161  if ( config -> NEntries() > 0 ) {
162  AddTopRegistry( config, false ) ;
163  LOG("Algorithm", pDEBUG) << "\n" << config;
164  }
165  }
166 
167  const string common_key_root = "Common" ;
168  std::map<string, string> common_lists;
169 
170  // Load Common Parameters if key that start with "Common" is found
171  for ( unsigned int i = 0 ; i < fConfVect.size() ; ++i ) {
172  const Registry & temp = * fConfVect[i] ;
173  for ( RgIMapConstIter it = temp.GetItemMap().begin() ; it != temp.GetItemMap().end() ; ++it ) {
174 
175  // check if it is a "Common" entry
176  if ( it -> first.find( common_key_root ) == 0 ) {
177  // retrieve the type of the common entry
178  std::string type = it -> first.substr(common_key_root.size() ) ;
179 
180  if ( temp.ItemIsLocal( it -> first ) ) {
181 
182  string temp_list = temp.GetString( it -> first ) ;
183  if ( temp_list.length() > 0 ) {
184  common_lists[type] = temp_list ;
185  }
186  }
187  }
188 
189  }
190 
191  } // loop over the local registries
192 
193 
194  for ( std::map<string, string>::const_iterator it = common_lists.begin() ;
195  it != common_lists.end() ; ++it ) {
196 
197  vector<string> list = str::Split( it -> second , "," ) ;
198 
199  for ( unsigned int i = 0; i < list.size(); ++i ) {
200 
201  config = pool -> CommonList( it -> first, list[i] ) ;
202 
203  if ( ! config ) {
204  LOG("Algorithm", pFATAL)
205  << "No Common parameters available for " << it -> first << " list "
206  << list[i] << " at the ConfigPool";
207 
208  exit( 78 ) ;
209  }
210  else {
211  AddLowRegistry( config, false ) ;
212  LOG("Algorithm", pDEBUG) << "Loading "
213  << it -> first << " registry "
214  << list[i] << " \n" << config;
215  }
216 
217  }
218 
219  }
220 
221 
222  // Load Tunable from CommonParameters
223  // only if the option is specified in RunOpt
224  config = pool -> CommonList( "Param", "Tunable" ) ;
225  if ( config ) {
226  if ( config -> NEntries() > 0 ) {
227  AddTopRegistry( config, false ) ;
228  LOG("Algorithm", pDEBUG) << "Loading Tunable registry \n" << config;
229  }
230  }
231  else {
232  // notify & keep whatever config Registry was used before.
233  LOG("Algorithm", pWARN)
234  << "No Tunable parameter set available at the ConfigPool";
235  }
236 
237  if ( fConfig ) {
238  delete fConfig ;
239  fConfig = 0 ;
240  }
241 
242 }
243 
244 //____________________________________________________________________________
245 
246 const Registry & Algorithm::GetConfig(void) const {
247 
248  if ( fConfig ) return * fConfig ;
249 
250  const_cast<Algorithm*>( this ) -> fConfig = new Registry( fID.Key() + "_summary", false ) ;
251 
252  // loop and append
253  // understand the append mechanism
254  for ( unsigned int i = 0 ; i < fConfVect.size(); ++i ) {
255  fConfig -> Append( * fConfVect[i] ) ;
256  }
257 
258  if ( fOwnsSubstruc ) {
259 
260  for ( AlgMapConstIter iter = fOwnedSubAlgMp -> begin() ;
261  iter != fOwnedSubAlgMp -> end() ; ++iter ) {
262 
263  Algorithm * subalg = iter -> second ;
264 
265  LOG("Algorithm", pDEBUG) << "Appending config from " << iter -> first << " -> " << subalg -> Id() ;
266  const Registry & r = subalg->GetConfig();
267  RgKey prefix = iter -> first + "/";
268  fConfig -> Append(r,prefix);
269 
270  }
271 
272  } //if owned substructure
273 
274  return * fConfig ;
275 }
276 
277 
278 //____________________________________________________________________________
280 {
281 
282  GetConfig() ;
283  return fConfig;
284 }
285 //____________________________________________________________________________
287 {
288 // Compares itself with the input algorithm
289 
290  string alg1 = this->Id().Name();
291  string config1 = this->Id().Config();
292  string alg2 = algo->Id().Name();
293  string config2 = algo->Id().Config();
294 
295  if(alg1 == alg2)
296  {
297  if(config1 == config2) return kAlgCmpIdentical;
298  else return kAlgCmpDiffConfig;
299  }
300  else return kAlgCmpDiffAlg;
301 
302  return kAlgCmpUnknown;
303 }
304 //____________________________________________________________________________
305 void Algorithm::SetId(const AlgId & id)
306 {
307  fID.Copy(id);
308 }
309 //____________________________________________________________________________
310 void Algorithm::SetId(string name, string config)
311 {
312  fID.SetId(name, config);
313 }
314 //____________________________________________________________________________
315 void Algorithm::Print(ostream & stream) const
316 {
317  // print algorithm name & parameter-set
318  stream << "\nAlgorithm Key: " << this->fID.Key();
319  stream << " - Owns Substruc: " << ((fOwnsSubstruc) ? "[true]" : "[false]");
320 
321  // print algorithm configuration
322  const Registry & r = this->GetConfig();
323  stream << r;
324 
325  if(fOwnsSubstruc) {
326  AlgMapConstIter iter = fOwnedSubAlgMp->begin();
327  for(; iter!=fOwnedSubAlgMp->end(); ++iter) {
328  Algorithm * alg = iter->second;
329  stream << "<Next algorithm is owned by : " << this->fID.Key() << ">";
330  stream << *alg;
331  }
332  }
333 }
334 //____________________________________________________________________________
336 {
337 // Algorithm initialization
338 //
339  fAllowReconfig = true;
340  fOwnsSubstruc = false;
341  fConfig = 0;
342  fOwnedSubAlgMp = 0;
343 }
344 //____________________________________________________________________________
345 const Algorithm * Algorithm::SubAlg(const RgKey & registry_key) const
346 {
347 // Returns the sub-algorithm pointed to this algorithm's XML config file using
348 // the the values of the key.
349 // This method asserts the existence of these keys in the XML config.
350 // Note: Since only 1 parameter is used, the key value should contain both the
351 // algorithm name and its configuration set according to the usual scheme:
352 // namespace::algorithm_name/configuration_set
353 //
354  LOG("Algorithm", pINFO)
355  << "Fetching sub-alg within alg: " << this->Id().Key()
356  << " pointed to by key: " << registry_key;
357 
358  //-- if the algorithm owns its substructure:
359  // return the sub-algorithm from the local pool
360  //
361  if(fOwnsSubstruc) {
362  AlgMapConstIter iter = fOwnedSubAlgMp->find(registry_key);
363  if(iter!=fOwnedSubAlgMp->end()) return iter->second;
364  LOG("Algorithm", pERROR)
365  << "Owned sub-alg pointed to by key: " << registry_key
366  << " was not found within alg: " << this->Id().Key();
367  return 0;
368  }
369 
370  //-- if the algorithm does not own its substructure:
371  // return the sub-algorithm from the AlgFactory's pool
372  RgAlg alg ;
373  GetParam( registry_key, alg ) ;
374 
375  LOG("Algorithm", pINFO)
376  << "Registry key: " << registry_key << " points to algorithm: " << alg;
377 
378  // retrieve the Algorithm object from the the Algorithm factory
379  AlgFactory * algf = AlgFactory::Instance();
380  const Algorithm * algbase = algf->GetAlgorithm(alg.name, alg.config);
381  assert(algbase);
382 
383  return algbase;
384 }
385 //____________________________________________________________________________
387 
388  LOG("Algorithm", pNOTICE)
389  << this->Id().Key() << " is taking ownership of its configuration";
390 
391  // if(fOwnsConfig) {
392  // LOG("Algorithm", pWARN)
393  // << this->Id().Key() << " already owns its configuration!";
394  // return;
395  // }
396 
397  this->Configure( GetConfig() );
398 }
399 //____________________________________________________________________________
401 {
402 // Take ownership of the algorithms subtructure (sub-algorithms,..) by copying
403 // them from the AlgFactory pool to the local pool. Also bring all the
404 // configuration variables to the top level. See the header for more details.
405 // A secial naming convention is required for configuration parameter keys
406 // for parameters belonging to sub-algorithms (or sub-algorithms of these
407 // sub-algorithms and so on...).
408 // The convention is: "sub-alg-key/sub-sub-alg-key/.../original name"
409 // This is a recursive method: The AdoptSubtructure()of all sub-algorithms is
410 // invoked.
411 //
412  LOG("Algorithm", pNOTICE)
413  << "Algorithm: " << this->Id().Key() << " is adopting its substructure";
414 
415 // Registry deep_config;
416 // deep_config.UnLock();
417 // deep_config.SetName(this->Id().Key());
418 
419  // deep_config.SetName(this->Id().Config() + ";D");
420  // fID.SetConfig(this->Id().Config() + ";D");
421 
422  if(fOwnsSubstruc) this->DeleteSubstructure();
423 
424  fOwnedSubAlgMp = new AlgMap;
425  fOwnsSubstruc = true;
426 
427  AlgFactory * algf = AlgFactory::Instance();
428 
429  const RgIMap & rgmap = GetConfig().GetItemMap();
430 
431  RgIMapConstIter iter = rgmap.begin();
432  for( ; iter != rgmap.end(); ++iter) {
433 
434  RgKey reg_key = iter->first;
435  RegistryItemI * ri = iter->second;
436 
437  if(ri->TypeInfo() == kRgAlg) {
438  LOG("Algorithm", pDEBUG)
439  << "Found sub-algorithm pointed to by " << reg_key;
440  RgAlg reg_alg = fConfig->GetAlg(reg_key);
441  AlgId id(reg_alg);
442 
443  LOG("Algorithm", pDEBUG) << "Adopting sub-algorithm = " << id.Key();
444  Algorithm * subalg = algf->AdoptAlgorithm(id.Name(),id.Config());
445  subalg->AdoptSubstructure();
446 
447  LOG("Algorithm", pDEBUG) << "Adding sub-algorithm to local pool";
448  AlgMapPair key_alg_pair(reg_key, subalg);
449  fOwnedSubAlgMp->insert(key_alg_pair);
450 
451  }
452 
453  }
454 
455 
456  if ( fConfig ) {
457  delete fConfig ;
458  fConfig = 0 ;
459  }
460 
461 }
462 //____________________________________________________________________________
464 {
465  // there is nothing to delete if the configuration is not owned but is
466  // rather looked up from the configuration pool
467  //
468 
469  for ( unsigned int i = 0 ; i < fConfVect.size() ; ++i ) {
470  if ( fOwnerships[i] ) {
471  delete fConfVect[i] ;
472  }
473  }
474 
475  fConfVect.clear() ;
476  fOwnerships.clear() ;
477 
478  // delete owned configuration registry
479 
480  if(fConfig) {
481  delete fConfig;
482  fConfig=0;
483  }
484 
485 }
486 
487 //____________________________________________________________________________
489 {
490  // there is nothing to delete if the sub-algorithms are not owned but rather
491  // taken from the AlgFactory's pool
492  //
493  if(!fOwnsSubstruc) return;
494 
495  // delete local algorithm pool
496  //
497  AlgMapIter iter = fOwnedSubAlgMp->begin();
498  for( ; iter != fOwnedSubAlgMp->end(); ++iter) {
499  Algorithm * alg = iter->second;
500  if(alg) {
501  delete alg;
502  alg=0;
503  }
504  }
505  delete fOwnedSubAlgMp;
506  fOwnedSubAlgMp = 0;
507 }
508 //____________________________________________________________________________
509 
510 string Algorithm::BuildParamVectKey( const std::string & comm_name, unsigned int i ) {
511 
512  std::stringstream name;
513  name << comm_name << '-' << i ;
514  return name.str() ;
515 
516 }
517 
518 //____________________________________________________________________________
519 
520 string Algorithm::BuildParamVectSizeKey( const std::string & comm_name ) {
521 
522  return 'N' + comm_name + 's' ;
523 
524 }
525 
526 //____________________________________________________________________________
527 
528 int Algorithm::GetParamVectKeys( const std::string & comm_name, std::vector<RgKey> & k,
529  bool is_top_call ) const {
530 
531  k.clear() ;
532 
533  int n ;
534  std::string n_name = Algorithm::BuildParamVectSizeKey( comm_name ) ;
535 
536  bool found = GetParam( n_name, n, is_top_call ) ;
537 
538  if ( ! found ) {
539  return 0 ;
540  }
541 
542  for ( int i = 0; i < n; ++i ) {
543 
544  RgKey temp_key = Algorithm::BuildParamVectKey( comm_name, i ) ;
545 
546  // potentially, if it is a top call,
547  // we might want to check if the key actually exist in the global Registry
548  // Not a priority irght now
549 
550  k.push_back( temp_key ) ;
551  }
552 
553  return k.size() ;
554 }
555 
556 
557 //____________________________________________________________________________
559 
560  const RgIMap & rgmap = in.GetItemMap();
561  Registry * out = new Registry( in.Name(), false );
562 
563  for( RgIMapConstIter reg_iter = rgmap.begin();
564  reg_iter != rgmap.end(); ++reg_iter ) {
565 
566  RgKey reg_key = reg_iter->first;
567  if( reg_key.find( '/' ) != string::npos) continue;
568 
569  // at this point
570  // this key is referred to the local algorithm
571  // it has to be copied in out;
572 
573  RegistryItemI * ri = reg_iter->second;
574  RgIMapPair key_item_pair( reg_key, ri->Clone() );
575  out -> Set(key_item_pair);
576 
577  }
578 
579  if ( out -> NEntries() <= 0 ) {
580  delete out ;
581  out = 0 ;
582  }
583 
584  return out ;
585 }
586 
587 //____________________________________________________________________________
588 
589 Registry * Algorithm::ExtractLowerConfig( const Registry & in, const string & alg_key ) const {
590 
591  const RgIMap & rgmap = in.GetItemMap();
592  Registry * out = new Registry( in.Name(), false );
593 
594  for( RgIMapConstIter reg_iter = rgmap.begin();
595  reg_iter != rgmap.end(); ++reg_iter ) {
596 
597  RgKey reg_key = reg_iter->first;
598  if( reg_key.find(alg_key+"/") == string::npos) continue;
599 
600  // at this point
601  // this key is referred to the sub-algorithm
602  // indicated by alg_key: it has to be copied in out;
603 
604  int new_key_start = reg_key.find_first_of('/')+1;
605  RgKey new_reg_key = reg_key.substr( new_key_start, reg_key.length() );
606 
607  RegistryItemI * ri = reg_iter->second;
608  RgIMapPair key_item_pair(new_reg_key, ri->Clone());
609  out -> Set(key_item_pair);
610 
611  }
612 
613  if ( out -> NEntries() <= 0 ) {
614  delete out ;
615  out = 0 ;
616  }
617 
618  return out ;
619 
620 }
621 
622 
623 //____________________________________________________________________________
624 
625 int Algorithm::AddTopRegistry( Registry * rp, bool own ) {
626 
627  fConfVect.insert( fConfVect.begin(), rp ) ;
628  fOwnerships.insert( fOwnerships.begin(), own ) ;
629 
630  if ( fConfig ) {
631  delete fConfig ;
632  fConfig = 0 ;
633  }
634 
635  return fConfVect.size() ;
636 
637 }
638 
639 //____________________________________________________________________________
640 
641 int Algorithm::AddLowRegistry( Registry * rp, bool own ) {
642 
643  fConfVect.push_back( rp ) ;
644  fOwnerships.push_back( own ) ;
645 
646  if ( fConfig ) {
647  delete fConfig ;
648  fConfig = 0 ;
649  }
650 
651  return fConfVect.size() ;
652 
653 }
654 
655 //____________________________________________________________________________
656 
657 
659 
660  if ( fOwnerships.empty() ) {
661 
662  // this algorithm is not configured right now, the incoming registry is the only configuration
663  Registry * p = new Registry( r ) ;
664  AddTopRegistry( p ) ;
665 
666  return 1 ;
667  }
668 
669  if ( fOwnerships[0] ) {
670  //the top registry is owned: it can be changed with no consequences for other algorithms
671  fConfVect[0] -> Merge( r ) ;
672  }
673  else {
674  // The top registry is not owned so it cannot be changed
675  // The registry will be added with top priority
676 
677  Registry * p = new Registry( r ) ;
678  AddTopRegistry( p ) ;
679  }
680 
681  // The configuration has changed so the summary is not updated anymore and must be deleted
682  if ( fConfig ) {
683  delete fConfig ;
684  fConfig = 0 ;
685  }
686 
687  return fConfVect.size() ;
688 }
689 
690 //____________________________________________________________________________
691 
692 
693 int Algorithm::AddTopRegisties( const vector<Registry*> & rs, bool own ) {
694 
695  fConfVect.insert( fConfVect.begin(), rs.begin(), rs.end() ) ;
696 
697  fOwnerships.insert( fOwnerships.begin(), rs.size(), own ) ;
698 
699  if ( fConfig ) {
700  delete fConfig ;
701  fConfig = 0 ;
702  }
703 
704  return fConfVect.size() ;
705 
706 }
static QCString name
Definition: declinfo.cpp:673
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Registry * GetOwnedConfig(void)
Definition: Algorithm.cxx:279
virtual ~Algorithm()
Definition: Algorithm.cxx:56
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
#define pERROR
Definition: Messenger.h:59
void DeleteSubstructure(void)
Definition: Algorithm.cxx:488
std::string string
Definition: nybbler.cc:12
Registry * ExtractLowerConfig(const Registry &in, const string &alg_key) const
Split an incoming configuration Registry into a block valid for the sub-algo identified by alg_key...
Definition: Algorithm.cxx:589
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:40
#define pFATAL
Definition: Messenger.h:56
struct vector vector
ChannelGroupService::Name Name
int MergeTopRegistry(const Registry &r)
Definition: Algorithm.cxx:658
Algorithm abstract base class.
Definition: Algorithm.h:53
intermediate_table::const_iterator const_iterator
int AddTopRegisties(const vector< Registry * > &rs, bool owns=false)
Add registries with top priority, also udated Ownerships.
Definition: Algorithm.cxx:693
map< string, Algorithm * > AlgMap
Definition: Algorithm.h:48
ostream & operator<<(ostream &stream, const T2KEvGenMetaData &md)
Registry item pABC.
Definition: RegistryItemI.h:29
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
enum genie::EAlgCmp AlgCmp_t
string Name(void) const
get the registry name
Definition: Registry.cxx:597
virtual RgType_t TypeInfo(void) const =0
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
map< RgKey, RegistryItemI * >::const_iterator RgIMapConstIter
Definition: Registry.h:49
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
const RgIMap & GetItemMap(void) const
Definition: Registry.h:161
string Name(void) const
Definition: AlgId.h:44
virtual void FindConfig(void)
Definition: Algorithm.cxx:127
static Config * config
Definition: config.cpp:1054
std::void_t< T > n
bool ItemIsLocal(RgKey key) const
local or global?
Definition: Registry.cxx:178
constexpr BitMask< Storage > Set(Flag_t< Storage > flag)
Returns a bit mask which sets the specified flag.
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
const Algorithm * GetAlgorithm(const AlgId &algid)
Definition: AlgFactory.cxx:75
p
Definition: test.py:223
void Initialize(void)
#define pINFO
Definition: Messenger.h:62
void AdoptSubstructure(void)
Definition: Algorithm.cxx:400
void Initialize(void)
Definition: Algorithm.cxx:335
pair< string, Algorithm * > AlgMapPair
Definition: Algorithm.h:51
Algorithm * AdoptAlgorithm(const AlgId &algid) const
Definition: AlgFactory.cxx:116
pair< RgKey, RegistryItemI * > RgIMapPair
Definition: Registry.h:46
int AddTopRegistry(Registry *rp, bool owns=true)
add registry with top priority, also update ownership
Definition: Algorithm.cxx:625
#define pWARN
Definition: Messenger.h:60
void AdoptConfig(void)
Definition: Algorithm.cxx:386
Algorithm ID (algorithm name + configuration set name)
Definition: AlgId.h:34
void DeleteConfig(void)
Definition: Algorithm.cxx:463
map< string, Algorithm * >::const_iterator AlgMapConstIter
Definition: Algorithm.h:50
virtual const AlgId & Id(void) const
Get algorithm ID.
Definition: Algorithm.h:97
RgStr GetString(RgKey key) const
Definition: Registry.cxx:481
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
static AlgFactory * Instance()
Definition: AlgFactory.cxx:64
static string BuildParamVectSizeKey(const std::string &comm_name)
Definition: Algorithm.cxx:520
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
virtual RegistryItemI * Clone(void) const =0
void Configure(string mesg)
Definition: gEvServ.cxx:196
int GetParamVectKeys(const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
Definition: Algorithm.cxx:528
static QCString type
Definition: declinfo.cpp:672
virtual AlgCmp_t Compare(const Algorithm *alg) const
Compare with input algorithm.
Definition: Algorithm.cxx:286
virtual void Print(ostream &stream) const
Print algorithm info.
Definition: Algorithm.cxx:315
Registry * FindRegistry(string key) const
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
virtual void SetId(const AlgId &id)
Set algorithm ID.
Definition: Algorithm.cxx:305
int AddLowRegistry(Registry *rp, bool owns=true)
add registry with lowest priority, also update ownership
Definition: Algorithm.cxx:641
Registry * ExtractLocalConfig(const Registry &in) const
Definition: Algorithm.cxx:558
#define pNOTICE
Definition: Messenger.h:61
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
map< string, Algorithm * >::iterator AlgMapIter
Definition: Algorithm.h:49
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
static string BuildParamVectKey(const std::string &comm_name, unsigned int i)
Definition: Algorithm.cxx:510
string Key(void) const
Definition: AlgId.h:46
Root of GENIE utility namespaces.
QTextStream & endl(QTextStream &s)
static AlgConfigPool * Instance()
#define pDEBUG
Definition: Messenger.h:63
map< RgKey, RegistryItemI * > RgIMap
Definition: Registry.h:45
string Config(void) const
Definition: AlgId.h:45
int NEntries(void) const
get number of items
Definition: Registry.cxx:582
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:345