GENIEGenerator
Loading...
Searching...
No Matches
Cache.h
Go to the documentation of this file.
1//____________________________________________________________________________
2/*!
3
4\class genie::Cache
5
6\brief GENIE Cache Memory
7
8\author Costas Andreopoulos <c.andreopoulos \at cern.ch>
9 University of Liverpool
10
11\created November 26, 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 _CACHE_H_
19#define _CACHE_H_
20
21#include <map>
22#include <string>
23#include <ostream>
24
25#include <TFile.h>
26
27using std::map;
28using std::string;
29using std::ostream;
30
31namespace genie {
32
33class Cache;
34class CacheBranchI;
35
36ostream & operator << (ostream & stream, const Cache & cache);
37
38class Cache
39{
40public:
41
42 static Cache * Instance(void);
43
44 //! cache file
45 void OpenCacheFile (string filename);
46
47 //! finding/adding cache branches
48 CacheBranchI * FindCacheBranch (string key);
49 void AddCacheBranch (string key, CacheBranchI * branch);
50 string CacheBranchKey (string k0, string k1="", string k2="") const;
51
52 //! removing cache branches
53 void RmCacheBranch (string key);
54 void RmAllCacheBranches (void);
55 void RmMatchedCacheBranches(string key_substring);
56
57 //! print cache buffers
58 void Print (ostream & stream) const;
59 friend ostream & operator << (ostream & stream, const Cache & cache);
60
61private:
62
63 //! load/save
64 void Load (void);
65 void Save (void);
66
67 //! singleton instance
68 static Cache * fInstance;
69
70 //! map of cache buffers & cache file
71 map<string, CacheBranchI * > * fCacheMap;
72 TFile * fCacheFile;
73
74 //! singleton class: constructors are private
75 Cache();
76 Cache(const Cache & cache);
77 virtual ~Cache();
78
79 //! proper de-allocation of the singleton object
80 struct Cleaner {
83 if (Cache::fInstance !=0) {
84 delete Cache::fInstance;
86 }
87 }
88 };
89 friend struct Cleaner;
90};
91
92} // genie namespace
93#endif // _CACHE_H_
The TObject at the root of concrete cache branches.
GENIE Cache Memory.
Definition Cache.h:39
void OpenCacheFile(string filename)
cache file
Definition Cache.cxx:183
string CacheBranchKey(string k0, string k1="", string k2="") const
Definition Cache.cxx:93
Cache(const Cache &cache)
static Cache * fInstance
singleton instance
Definition Cache.h:68
void AddCacheBranch(string key, CacheBranchI *branch)
Definition Cache.cxx:88
Cache()
singleton class: constructors are private
Definition Cache.cxx:37
void Load(void)
load/save
Definition Cache.cxx:133
static Cache * Instance(void)
Definition Cache.cxx:67
friend ostream & operator<<(ostream &stream, const Cache &cache)
Definition Cache.cxx:29
map< string, CacheBranchI * > * fCacheMap
map of cache buffers & cache file
Definition Cache.h:71
virtual ~Cache()
Definition Cache.cxx:44
void RmAllCacheBranches(void)
Definition Cache.cxx:110
void RmCacheBranch(string key)
removing cache branches
Definition Cache.cxx:104
void Save(void)
Definition Cache.cxx:155
CacheBranchI * FindCacheBranch(string key)
finding/adding cache branches
Definition Cache.cxx:80
void RmMatchedCacheBranches(string key_substring)
Definition Cache.cxx:127
void Print(ostream &stream) const
print cache buffers
Definition Cache.cxx:206
TFile * fCacheFile
Definition Cache.h:72
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
proper de-allocation of the singleton object
Definition Cache.h:80
void DummyMethodAndSilentCompiler()
Definition Cache.h:81