]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: global | |
3 | // | |
4 | // See the class description in the header file. | |
5 | ||
6 | #include "AliFiles.h" | |
ec3a86b4 | 7 | #include "AliGlobals.h" |
676fb573 | 8 | |
9 | #include <stdlib.h> | |
10 | ||
11 | // static data members | |
12 | ||
ec3a86b4 | 13 | AliFiles* AliFiles::fgInstance = 0; |
14 | const G4String AliFiles::fgkTop = getenv("AG4_INSTALL"); | |
15 | const G4String AliFiles::fgkDefaultMacroName = "Config"; | |
16 | const G4String AliFiles::fgkDefaultG3CallsName = "g3calls"; | |
17 | const G4String AliFiles::fgkRootMacroExtension = ".C"; | |
18 | const G4String AliFiles::fgkG4MacroExtension = ".in"; | |
19 | const G4String AliFiles::fgkG3CallsExtension = ".dat"; | |
20 | const G4String AliFiles::fgkXMLFileExtension = ".xml"; | |
21 | ||
e699fd2f | 22 | //_____________________________________________________________________________ |
ec3a86b4 | 23 | AliFiles::AliFiles() |
24 | : fMacroName(fgkDefaultMacroName), | |
25 | fG3CallsName(fgkDefaultG3CallsName) | |
26 | { | |
3809435c | 27 | // |
ec3a86b4 | 28 | if (fgInstance) { |
29 | AliGlobals::Exception( | |
30 | "AliFiles: attempt to create two instances of singleton."); | |
31 | }; | |
32 | ||
33 | fgInstance = this; | |
34 | } | |
35 | ||
e699fd2f | 36 | //_____________________________________________________________________________ |
ec3a86b4 | 37 | AliFiles::AliFiles(const G4String& config) |
38 | : fMacroName(config), | |
39 | fG3CallsName(fgkDefaultG3CallsName) | |
40 | { | |
3809435c | 41 | // |
ec3a86b4 | 42 | if (fgInstance) { |
43 | AliGlobals::Exception( | |
44 | "AliFiles: attempt to create two instances of singleton."); | |
45 | }; | |
46 | ||
47 | fgInstance = this; | |
48 | } | |
49 | ||
e699fd2f | 50 | //_____________________________________________________________________________ |
ec3a86b4 | 51 | AliFiles::AliFiles(const G4String& config, const G4String& g3calls) |
52 | : fMacroName(config), | |
53 | fG3CallsName(g3calls) | |
54 | { | |
3809435c | 55 | // |
ec3a86b4 | 56 | if (fgInstance) { |
57 | AliGlobals::Exception( | |
58 | "AliFiles: attempt to create two instances of singleton."); | |
59 | }; | |
60 | ||
61 | fgInstance = this; | |
676fb573 | 62 | } |
63 | ||
e699fd2f | 64 | //_____________________________________________________________________________ |
65 | AliFiles::AliFiles(const AliFiles& right) { | |
66 | // | |
67 | AliGlobals::Exception("Attempt to copy AliFiles singleton."); | |
68 | } | |
69 | ||
70 | ||
71 | //_____________________________________________________________________________ | |
676fb573 | 72 | AliFiles::~AliFiles() { |
73 | // | |
74 | } | |
ec3a86b4 | 75 | |
e699fd2f | 76 | // operators |
77 | ||
78 | //_____________________________________________________________________________ | |
79 | AliFiles& | |
80 | AliFiles::operator=(const AliFiles& right) | |
81 | { | |
82 | // check assignement to self | |
83 | if (this == &right) return *this; | |
84 | ||
85 | AliGlobals::Exception("Attempt to assign AliFiles singleton."); | |
86 | ||
87 | return *this; | |
88 | } | |
89 | ||
ec3a86b4 | 90 | // private methods |
91 | ||
e699fd2f | 92 | //_____________________________________________________________________________ |
ec3a86b4 | 93 | G4String AliFiles::GetMacroPath(const G4String& macroName, |
94 | const G4String& moduleName, | |
95 | G4bool isStructure) const | |
96 | { | |
97 | // Returns the filepath to Config.C/in with filename extension: | |
98 | // $AG4_INSTALL/macro/XXX/Config | |
99 | // $AG4_INSTALL/macro/STRUCT/XXXConfig | |
100 | // --- | |
101 | ||
102 | G4String name = fgkTop + "/macro/"; | |
676fb573 | 103 | |
ec3a86b4 | 104 | if (!isStructure) |
105 | name = name + moduleName + "/" + macroName; | |
106 | else | |
107 | name = name + "STRUCT/"+ fgkDefaultMacroName + moduleName; | |
108 | ||
109 | return name; | |
110 | } | |
111 | ||
112 | // public methods | |
113 | ||
e699fd2f | 114 | //_____________________________________________________________________________ |
ec3a86b4 | 115 | G4String AliFiles::GetRootMacroPath() const |
116 | { | |
117 | // Returns the filepath: | |
118 | // $ALICE_ROOT/macros/Config.C | |
119 | // --- | |
120 | ||
121 | G4String name | |
122 | = fgkTop + "/../macros/" + fMacroName + fgkRootMacroExtension; | |
123 | ||
124 | return name; | |
125 | } | |
126 | ||
e699fd2f | 127 | //_____________________________________________________________________________ |
ec3a86b4 | 128 | G4String AliFiles::GetRootMacroPath(const G4String& moduleName, |
129 | G4bool isStructure) const | |
130 | { | |
131 | // Returns the filepath: | |
132 | // $AG4_INSTALL/macro/XXX/Config.C | |
133 | // $AG4_INSTALL/macro/STRUCT/XXXConfig.C | |
134 | // --- | |
135 | ||
136 | G4String name = GetMacroPath(fMacroName, moduleName, isStructure); | |
137 | name = name + fgkRootMacroExtension; | |
138 | ||
139 | return name; | |
140 | } | |
141 | ||
e699fd2f | 142 | //_____________________________________________________________________________ |
ec3a86b4 | 143 | G4String AliFiles::GetG4MacroPath(const G4String& moduleName, |
144 | G4bool isStructure) const | |
145 | { | |
146 | // Returns the filepath: | |
147 | // $AG4_INSTALL/macro/XXX/Config.in | |
148 | // $AG4_INSTALL/macro/STRUCT/XXXConfig.in | |
149 | // --- | |
150 | ||
151 | G4String name = GetMacroPath(fgkDefaultMacroName, moduleName, isStructure); | |
152 | name = name + fgkG4MacroExtension; | |
153 | ||
154 | return name; | |
155 | } | |
156 | ||
e699fd2f | 157 | //_____________________________________________________________________________ |
ec3a86b4 | 158 | G4String AliFiles::GetG3CallsDatPath(const G4String& moduleName, |
159 | G4int moduleVersion, G4bool isStructure) const | |
160 | { | |
161 | // Returns the filepath: | |
162 | // $AG4_INSTALL/macro/XXX/g3calls_vN.dat | |
163 | // $AG4_INSTALL/macro/STRUCT/g3calls_XXXvN.dat | |
164 | // --- | |
165 | ||
166 | G4String version("v"); | |
167 | AliGlobals::AppendNumberToString(version, moduleVersion); | |
168 | ||
169 | G4String name = fgkTop + "/macro/"; | |
170 | ||
171 | if (!isStructure) | |
172 | name = name + moduleName + "/" + fG3CallsName + "_"; | |
173 | else | |
174 | name = name + "STRUCT/" + fG3CallsName + "_" + moduleName; | |
175 | ||
176 | name = name + version + fgkG3CallsExtension; | |
177 | ||
178 | return name; | |
179 | } | |
180 | ||
e699fd2f | 181 | //_____________________________________________________________________________ |
ec3a86b4 | 182 | G4String AliFiles::GetXMLFilePath(const G4String& moduleName, |
183 | G4int moduleVersion) const | |
184 | { | |
185 | // Returns the filepath: | |
186 | // $AG4_INSTALL/xml/XXXvN.xml | |
187 | // --- | |
188 | ||
189 | G4String version = "v"; | |
190 | AliGlobals::AppendNumberToString(version, moduleVersion); | |
191 | ||
192 | G4String name | |
193 | = fgkTop + "/xml/" + moduleName + version + fgkXMLFileExtension; | |
194 | ||
195 | return name; | |
196 | } |