]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliFiles.cxx
added copy constructor and assignement operator (giving exception only); comment...
[u/mrichter/AliRoot.git] / AliGeant4 / AliFiles.cxx
1 // $Id$
2 // Category: global
3 //
4 // See the class description in the header file.
5
6 #include "AliFiles.h"
7 #include "AliGlobals.h"
8
9 #include <stdlib.h>
10
11 // static data members
12
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
22 //_____________________________________________________________________________
23 AliFiles::AliFiles()
24   : fMacroName(fgkDefaultMacroName),
25     fG3CallsName(fgkDefaultG3CallsName)
26 {
27 //    
28   if (fgInstance) {
29     AliGlobals::Exception(
30       "AliFiles: attempt to create two instances of singleton.");
31   };
32       
33   fgInstance = this;      
34 }
35   
36 //_____________________________________________________________________________
37 AliFiles::AliFiles(const G4String& config)  
38   : fMacroName(config),
39     fG3CallsName(fgkDefaultG3CallsName)
40 {
41 //
42   if (fgInstance) {
43     AliGlobals::Exception(
44       "AliFiles: attempt to create two instances of singleton.");
45   };
46       
47   fgInstance = this;      
48 }
49   
50 //_____________________________________________________________________________
51 AliFiles::AliFiles(const G4String& config, const G4String& g3calls)  
52   : fMacroName(config),
53     fG3CallsName(g3calls)
54 {
55 //
56   if (fgInstance) {
57     AliGlobals::Exception(
58       "AliFiles: attempt to create two instances of singleton.");
59   };
60       
61   fgInstance = this;      
62 }
63   
64 //_____________________________________________________________________________
65 AliFiles::AliFiles(const AliFiles& right) {
66 // 
67   AliGlobals::Exception("Attempt to copy AliFiles singleton.");
68 }
69
70
71 //_____________________________________________________________________________
72 AliFiles::~AliFiles() {
73 //
74 }
75
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           
90 // private methods 
91
92 //_____________________________________________________________________________
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/";
103   
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
114 //_____________________________________________________________________________
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                               
127 //_____________________________________________________________________________
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                               
142 //_____________________________________________________________________________
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                                                                                           
157 //_____________________________________________________________________________
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                               
181 //_____________________________________________________________________________
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 }