68 if (
config.NEntries() <= 0 ) {
70 LOG(
"Algorithm",
pNOTICE)
"Registry " <<
config.Name() <<
" is empty. Not added to " <<
fID.Name();
78 LOG(
"Algorithm",
pNOTICE) <<
fID.Name() <<
" merged with external configuration: " << *rp;
87 LOG(
"Algorithm",
pNOTICE) <<
"Configuring algorithms stored at local pool";
94 string alg_key = alg_iter->first;
99 <<
"Key: " << alg_key <<
" points to a null algorithm at local pool";
103 LOG(
"Algorithm",
pNOTICE) <<
"Configuring sub-alg: " << alg->
Id().
Key();
142 if (
fID.Config() !=
"Default" ) {
143 config = pool -> FindRegistry(
fID.Name(),
"Default" );
145 if (
config -> NEntries() > 0 ) {
158 <<
"No Configuration available for "
159 << this->
Id().
Key() <<
" at the ConfigPool";
161 if ( config -> NEntries() > 0 ) {
167 const string common_key_root =
"Common" ;
168 std::map<string, string> common_lists;
171 for (
unsigned int i = 0 ; i <
fConfVect.size() ; ++i ) {
176 if ( it -> first.find( common_key_root ) == 0 ) {
178 std::string type = it -> first.substr(common_key_root.size() ) ;
182 string temp_list = temp.
GetString( it -> first ) ;
183 if ( temp_list.length() > 0 ) {
184 common_lists[type] = temp_list ;
194 for ( std::map<string, string>::const_iterator it = common_lists.begin() ;
195 it != common_lists.end() ; ++it ) {
197 vector<string> list =
str::Split( it -> second ,
"," ) ;
199 for (
unsigned int i = 0; i < list.size(); ++i ) {
201 config = pool -> CommonList( it -> first, list[i] ) ;
205 <<
"No Common parameters available for " << it -> first <<
" list "
206 << list[i] <<
" at the ConfigPool";
213 << it -> first <<
" registry "
214 << list[i] <<
" \n" <<
config;
224 config = pool -> CommonList(
"Param",
"Tunable" ) ;
226 if (
config -> NEntries() > 0 ) {
234 <<
"No Tunable parameter set available at the ConfigPool";
254 for (
unsigned int i = 0 ; i <
fConfVect.size(); ++i ) {
265 LOG(
"Algorithm",
pDEBUG) <<
"Appending config from " << iter -> first <<
" -> " << subalg ->
Id() ;
267 RgKey prefix = iter -> first +
"/";
290 string alg1 = this->
Id().
Name();
291 string config1 = this->
Id().
Config();
292 string alg2 = algo->
Id().
Name();
293 string config2 = algo->
Id().
Config();
318 stream <<
"\nAlgorithm Key: " << this->
fID.Key();
319 stream <<
" - Owns Substruc: " << ((
fOwnsSubstruc) ?
"[true]" :
"[false]");
329 stream <<
"<Next algorithm is owned by : " << this->
fID.Key() <<
">";
355 <<
"Fetching sub-alg within alg: " << this->
Id().
Key()
356 <<
" pointed to by key: " << registry_key;
365 <<
"Owned sub-alg pointed to by key: " << registry_key
366 <<
" was not found within alg: " << this->
Id().
Key();
376 <<
"Registry key: " << registry_key <<
" points to algorithm: " << alg;
389 << this->
Id().
Key() <<
" is taking ownership of its configuration";
413 <<
"Algorithm: " << this->
Id().
Key() <<
" is adopting its substructure";
432 for( ; iter != rgmap.end(); ++iter) {
434 RgKey reg_key = iter->first;
439 <<
"Found sub-algorithm pointed to by " << reg_key;
443 LOG(
"Algorithm",
pDEBUG) <<
"Adopting sub-algorithm = " <<
id.Key();
447 LOG(
"Algorithm",
pDEBUG) <<
"Adding sub-algorithm to local pool";
469 for (
unsigned int i = 0 ; i <
fConfVect.size() ; ++i ) {
512 std::stringstream name;
513 name << comm_name <<
'-' << i ;
522 return 'N' + comm_name +
's' ;
529 std::stringstream name;
530 name << comm_name <<
'-' << i <<
"-" << j ;
539 return "Nrow" + comm_name +
's' ;
547 return "Ncol" + comm_name +
's' ;
556 bool is_top_call )
const {
563 bool found =
GetParam( n_name, n, is_top_call ) ;
569 for (
int i = 0; i < n; ++i ) {
577 k.push_back( temp_key ) ;
586 bool is_top_call )
const {
590 int n_row = 0, n_col = 0 ;
594 bool found =
GetParam( row_name, n_row, is_top_call ) &&
GetParam( col_name, n_col, is_top_call ) ;
600 for (
int i = 0; i < n_row; ++i ) {
601 for (
int j = 0; j < n_col; ++j ) {
609 k.push_back( temp_key ) ;
625 reg_iter != rgmap.end(); ++reg_iter ) {
627 RgKey reg_key = reg_iter->first;
628 if( reg_key.find(
'/' ) != string::npos)
continue;
636 out -> Set(key_item_pair);
640 if ( out -> NEntries() <= 0 ) {
656 reg_iter != rgmap.end(); ++reg_iter ) {
658 RgKey reg_key = reg_iter->first;
659 if( reg_key.find(alg_key+
"/") == string::npos)
continue;
665 int new_key_start = reg_key.find_first_of(
'/')+1;
666 RgKey new_reg_key = reg_key.substr( new_key_start, reg_key.length() );
670 out -> Set(key_item_pair);
674 if ( out -> NEntries() <= 0 ) {
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Registry * FindRegistry(string key) const
static AlgConfigPool * Instance()
The GENIE Algorithm Factory.
const Algorithm * GetAlgorithm(const AlgId &algid)
static AlgFactory * Instance()
Algorithm * AdoptAlgorithm(const AlgId &algid) const
Algorithm ID (algorithm name + configuration set name)
string Config(void) const
Registry * GetOwnedConfig(void)
static string BuildParamMatKey(const std::string &comm_name, unsigned int i, unsigned int j)
int GetParamMatKeys(const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
void AdoptSubstructure(void)
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.
static string BuildParamMatColSizeKey(const std::string &comm_name)
bool fOwnsSubstruc
true if it owns its substructure (sub-algs,...)
Registry * ExtractLocalConfig(const Registry &in) const
int AddLowRegistry(Registry *rp, bool owns=true)
add registry with lowest priority, also update ownership
virtual AlgCmp_t Compare(const Algorithm *alg) const
Compare with input algorithm.
virtual const Registry & GetConfig(void) const
static string BuildParamVectSizeKey(const std::string &comm_name)
static string BuildParamMatRowSizeKey(const std::string &comm_name)
Registry * fConfig
Summary configuration derived from fConvVect, not necessarily allocated.
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
vector< bool > fOwnerships
ownership for every registry in fConfVect
virtual void FindConfig(void)
int GetParamVectKeys(const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
virtual void SetId(const AlgId &id)
Set algorithm ID.
void DeleteSubstructure(void)
int MergeTopRegistry(const Registry &r)
vector< Registry * > fConfVect
AlgId fID
algorithm name and configuration set
virtual void Configure(const Registry &config)
const Algorithm * SubAlg(const RgKey ®istry_key) const
virtual void Print(ostream &stream) const
Print algorithm info.
int AddTopRegisties(const vector< Registry * > &rs, bool owns=false)
Add registries with top priority, also udated Ownerships.
AlgMap * fOwnedSubAlgMp
local pool for owned sub-algs (taken out of the factory pool)
int AddTopRegistry(Registry *rp, bool owns=true)
add registry with top priority, also update ownership
virtual const AlgId & Id(void) const
Get algorithm ID.
static string BuildParamVectKey(const std::string &comm_name, unsigned int i)
virtual RegistryItemI * Clone(void) const =0
virtual RgType_t TypeInfo(void) const =0
A registry. Provides the container for algorithm configuration parameters.
const RgIMap & GetItemMap(void) const
string Name(void) const
get the registry name
RgStr GetString(RgKey key) const
bool ItemIsLocal(RgKey key) const
local or global?
Simple functions for loading and reading nucleus dependent keys from config files.
vector< string > Split(string input, string delim)
Root of GENIE utility namespaces.
THE MAIN GENIE PROJECT NAMESPACE
map< string, Algorithm * >::iterator AlgMapIter
map< RgKey, RegistryItemI * > RgIMap
pair< RgKey, RegistryItemI * > RgIMapPair
map< RgKey, RegistryItemI * >::const_iterator RgIMapConstIter
pair< string, Algorithm * > AlgMapPair
map< string, Algorithm * >::const_iterator AlgMapConstIter
enum genie::EAlgCmp AlgCmp_t
map< string, Algorithm * > AlgMap
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)