15 #include <TDirectory.h>
17 #include <TObjString.h>
23 using std::ostringstream;
49 map<string, CacheBranchI * >::iterator citer;
82 map<string, CacheBranchI *>::const_iterator map_iter =
fCacheMap->find(key);
84 if (map_iter ==
fCacheMap->end())
return 0;
85 return map_iter->second;
90 fCacheMap->insert( map<string, CacheBranchI *>::value_type(key,branch) );
98 if(k1.size()>0) key <<
"/" << k1;
99 if(k2.size()>0) key <<
"/" << k2;
106 LOG(
"Cache",
pNOTICE) <<
"Removing cache branch: " << key;
112 LOG(
"Cache",
pNOTICE) <<
"Removing cache branches";
115 map<string, CacheBranchI * >::iterator citer;
129 LOG(
"Cache",
pNOTICE) <<
"Removing cache branches: *"<< key_substring<<
"*";
138 TList * keys = (TList*)
fCacheFile->Get(
"key_list");
140 TObjString * keyobj = 0;
142 while ((keyobj = (TObjString *)kiter.Next())) {
143 string key = string(keyobj->GetString().Data());
145 bname <<
"buffer_" << ib++;
148 fCacheMap->insert( map<string, CacheBranchI *>::value_type(key,buffer) );
163 TList * keys =
new TList;
164 keys->SetOwner(
true);
166 map<string, CacheBranchI * >::iterator citer;
168 string key = citer->first;
172 bname <<
"buffer_" << ib++;
173 keys->Add(
new TObjString(key.c_str()));
174 branch->Write(bname.str().c_str(), TObject::kOverwrite);
177 keys->Write(
"key_list", TObject::kSingleKey | TObject::kOverwrite );
185 if(filename.size() == 0)
return;
194 LOG(
"Cache",
pNOTICE) <<
"Using cache file: " << filename;
196 fCacheFile =
new TFile(filename.c_str(),
"update");
200 LOG(
"Cache",
pWARN) <<
"Could not open cache file: " << filename;
208 stream <<
"\n [-] GENIE Cache Buffers:";
210 map<string, CacheBranchI * >::iterator citer;
212 string key = citer->first;
214 stream <<
"\n |--o " << key;
216 stream <<
" *** NULL *** ";
map< string, CacheBranchI * > * fCacheMap
map of cache buffers & cache file
void RmAllCacheBranches(void)
void AddCacheBranch(string key, CacheBranchI *branch)
void DummyMethodAndSilentCompiler()
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
void OpenCacheFile(string filename)
cache file
void Print(ostream &stream) const
print cache buffers
string CacheBranchKey(string k0, string k1="", string k2="") const
CacheBranchI * FindCacheBranch(string key)
finding/adding cache branches
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
static Cache * fInstance
singleton instance
Cache()
singleton class: constructors are private
proper de-allocation of the singleton object
void RmMatchedCacheBranches(string key_substring)
static Cache * Instance(void)
The TObject at the root of concrete cache branches.
void RmCacheBranch(string key)
removing cache branches