Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4PersistencyCenterMessenger Class Reference

#include <G4PersistencyCenterMessenger.hh>

Inheritance diagram for G4PersistencyCenterMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4PersistencyCenterMessenger (G4PersistencyCenter *p)
 
G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool operator== (const G4UImessenger &messenger) const
 
void SetNewValue (G4UIcommand *command, G4String newValues)
 
 ~G4PersistencyCenterMessenger ()
 

Protected Member Functions

void AddUIcommand (G4UIcommand *newCommand)
 
G4String BtoS (G4bool b)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
G4String DtoS (G4double a)
 
G4String ItoS (G4int i)
 
G4bool StoB (G4String s)
 
G4double StoD (G4String s)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 

Protected Attributes

G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Private Member Functions

G4String PopWord (const G4String &text, G4int n, const G4String &delim)
 

Private Attributes

G4UIdirectorydirectory = nullptr
 
G4PersistencyCenterpc = nullptr
 
G4UIcmdWithoutParameterprintAll = nullptr
 
std::vector< std::string > rdObj
 
G4UIcmdWithAStringregHitIO = nullptr
 
G4UIcmdWithAStringselect = nullptr
 
std::vector< G4UIcmdWithAString * > setRdFile
 
std::vector< G4UIcmdWithAString * > setWrFile
 
std::vector< G4UIcmdWithAString * > storeObj
 
G4UIdirectorysubdir1 = nullptr
 
G4UIdirectorysubdir2 = nullptr
 
G4UIdirectorysubdir3 = nullptr
 
G4UIdirectorysubdir4 = nullptr
 
G4UIdirectorysubdir5 = nullptr
 
G4UIcmdWithAnIntegerverboseCmd = nullptr
 
std::vector< std::string > wrObj
 

Detailed Description

Definition at line 45 of file G4PersistencyCenterMessenger.hh.

Constructor & Destructor Documentation

◆ G4PersistencyCenterMessenger()

G4PersistencyCenterMessenger::G4PersistencyCenterMessenger ( G4PersistencyCenter p)

Definition at line 34 of file G4PersistencyCenterMessenger.cc.

36 : pc(p)
37{
38 G4String name = "/persistency/";
39 directory = new G4UIdirectory(name.c_str());
40 directory->SetGuidance("Control commands for Persistency package");
41
42 G4String cmd = name + "verbose";
43
44 verboseCmd = new G4UIcmdWithAnInteger(cmd.c_str(), this);
45 verboseCmd->SetGuidance("Set the verbose level of G4PersistencyManager.");
46 verboseCmd->SetGuidance(" 0 : Silent (default)");
47 verboseCmd->SetGuidance(" 1 : Display main topics");
48 verboseCmd->SetGuidance(" 2 : Display event-level topics");
49 verboseCmd->SetGuidance(" 3 : Display debug information");
50 verboseCmd->SetParameterName("level", true);
52 verboseCmd->SetRange("level >=0 && level <=3");
53
54 G4String vname = name + "select";
55
56 cmd = vname;
57 select = new G4UIcmdWithAString(cmd.c_str(), this);
58 select->SetGuidance("Selection of a persistency package");
59 select->SetParameterName("Persistency package name", true, true);
60 select->SetCandidates("ODBMS ROOT None");
61
62 vname = name + "store/";
63
64 subdir1 = new G4UIdirectory(vname.c_str());
65 subdir1->SetGuidance("Specifiy object types for store");
66
67 wrObj.push_back("HepMC");
68 wrObj.push_back("MCTruth");
69 wrObj.push_back("Hits");
70
71 G4String guidance;
72 G4int i;
73
74 for(i = 0; i < 3; ++i)
75 {
76 cmd = vname + wrObj[i];
77 guidance = "Store " + wrObj[i] + " objects for output";
78 storeObj.push_back(new G4UIcmdWithAString(cmd.c_str(), this));
79 storeObj[i]->SetGuidance(guidance.c_str());
80 if(wrObj[i] == "HepMC")
81 {
82 storeObj[i]->SetCandidates("on off recycle");
83 }
84 else
85 {
86 storeObj[i]->SetCandidates("on off");
87 }
88 }
89
90 vname += "using/";
91 subdir2 = new G4UIdirectory(vname.c_str());
92 subdir2->SetGuidance("Select I/O manager for store");
93
94 cmd = vname + "hitIO";
95 regHitIO = new G4UIcmdWithAString(cmd.c_str(), this);
96 regHitIO->SetGuidance("Resiter Hits I/O Manager");
97 regHitIO->SetParameterName("Name of Hits I/O Manager", true, true);
98
99 vname = name + "set/";
100 subdir3 = new G4UIdirectory(vname.c_str());
101 subdir3->SetGuidance("Set various parameters");
102
103 vname += "writeFile/";
104 subdir4 = new G4UIdirectory(vname.c_str());
105 subdir4->SetGuidance("Set output file names for object types");
106
107 for(i = 0; i < 3; ++i)
108 {
109 cmd = vname + wrObj[i];
110 guidance = "Set an output file name for " + wrObj[i] + ".";
111 setWrFile.push_back(new G4UIcmdWithAString(cmd.c_str(), this));
112 setWrFile[i]->SetGuidance(guidance.c_str());
113 setWrFile[i]->SetParameterName("file name", true, true);
114 }
115
116 vname = name + "set/ReadFile/";
117 subdir5 = new G4UIdirectory(vname.c_str());
118 subdir5->SetGuidance("Set input file names for object types");
119
120 rdObj.push_back("Hits");
121
122 cmd = vname + rdObj[0];
123 guidance = "Set an input file name for " + rdObj[0] + ".";
124 setRdFile.push_back(new G4UIcmdWithAString(cmd.c_str(), this));
125 setRdFile[0]->SetGuidance(guidance.c_str());
126 setRdFile[0]->SetParameterName("file name", true, true);
127
128 cmd = name + "printall";
129 printAll = new G4UIcmdWithoutParameter(cmd.c_str(), this);
130 printAll->SetGuidance("Print all parameters.");
131}
int G4int
Definition: G4Types.hh:85
std::vector< G4UIcmdWithAString * > setWrFile
std::vector< G4UIcmdWithAString * > storeObj
std::vector< G4UIcmdWithAString * > setRdFile
void SetCandidates(const char *candidateList)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4int defVal)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
const char * name(G4int ptype)

References directory, G4InuclParticleNames::name(), printAll, rdObj, regHitIO, select, G4UIcmdWithAString::SetCandidates(), G4UIcmdWithAnInteger::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcmdWithAString::SetParameterName(), G4UIcommand::SetRange(), setRdFile, setWrFile, storeObj, subdir1, subdir2, subdir3, subdir4, subdir5, verboseCmd, and wrObj.

◆ ~G4PersistencyCenterMessenger()

G4PersistencyCenterMessenger::~G4PersistencyCenterMessenger ( )

Definition at line 134 of file G4PersistencyCenterMessenger.cc.

135{
136 delete directory;
137 delete subdir1;
138 delete subdir2;
139 delete subdir3;
140 delete subdir4;
141 delete subdir5;
142 delete verboseCmd;
143 delete select;
144 delete regHitIO;
145 for(G4int i = 0; i < 3; ++i)
146 {
147 delete storeObj[i];
148 delete setWrFile[i];
149 }
150 delete setRdFile[0];
151 delete printAll;
152}

References directory, printAll, regHitIO, select, setRdFile, setWrFile, storeObj, subdir1, subdir2, subdir3, subdir4, subdir5, and verboseCmd.

Member Function Documentation

◆ AddUIcommand()

void G4UImessenger::AddUIcommand ( G4UIcommand newCommand)
protectedinherited

Definition at line 149 of file G4UImessenger.cc.

150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References G4cerr, G4endl, and G4UIcommand::GetCommandPath().

◆ BtoS()

G4String G4UImessenger::BtoS ( G4bool  b)
protectedinherited

Definition at line 98 of file G4UImessenger.cc.

99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}

◆ CommandsShouldBeInMaster()

G4bool G4UImessenger::CommandsShouldBeInMaster ( ) const
inlineinherited

Definition at line 77 of file G4UImessenger.hh.

78 {
80 }
G4bool commandsShouldBeInMaster

References G4UImessenger::commandsShouldBeInMaster.

Referenced by G4UIcommand::G4UIcommandCommonConstructorCode().

◆ CreateCommand()

template<typename T >
T * G4UImessenger::CreateCommand ( const G4String cname,
const G4String dsc 
)
protectedinherited

Definition at line 110 of file G4UImessenger.hh.

111{
112 G4String path;
113 if(cname[0] != '/')
114 {
115 path = baseDirName + cname;
116 if(path[0] != '/')
117 path = "/" + path;
118 }
119
120 T* command = new T(path.c_str(), this);
121 command->SetGuidance(dsc.c_str());
122
123 return command;
124}
G4String baseDirName

References G4UImessenger::baseDirName.

◆ CreateDirectory()

void G4UImessenger::CreateDirectory ( const G4String path,
const G4String dsc,
G4bool  commandsToBeBroadcasted = true 
)
protectedinherited

Definition at line 156 of file G4UImessenger.cc.

158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4UIdirectory * baseDir

References G4UImessenger::baseDir, G4UImessenger::baseDirName, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::GetPathName(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), and G4UIcommand::SetGuidance().

Referenced by G4MoleculeShootMessenger::G4MoleculeShootMessenger(), and G4UImessenger::G4UImessenger().

◆ DtoS()

G4String G4UImessenger::DtoS ( G4double  a)
protectedinherited

Definition at line 90 of file G4UImessenger.cc.

91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}

Referenced by G4ScoreQuantityMessenger::FilterCommands(), and G4UIcontrolMessenger::SetNewValue().

◆ GetCurrentValue()

G4String G4PersistencyCenterMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 214 of file G4PersistencyCenterMessenger.cc.

215{
216 G4String ustr = "Undefined";
217
218 if(command == verboseCmd)
219 {
221 }
222 else if(command == select)
223 {
224 return pc->CurrentSystem();
225 }
226 else if(command == regHitIO)
227 {
228 return pc->CurrentHCIOmanager();
229 }
230 else if(command == setRdFile[0])
231 {
232 return pc->CurrentReadFile(rdObj[0]);
233 }
234 else
235 {
236 for(G4int i = 0; i < 3; ++i)
237 {
238 if(command == storeObj[i])
239 {
240 switch(pc->CurrentStoreMode(wrObj[i]))
241 {
242 case kOn:
243 return "on";
244 break;
245 case kOff:
246 return "off";
247 break;
248 case kRecycle:
249 return "recycle";
250 break;
251 default:
252 return "?????";
253 break;
254 };
255 }
256 else if(command == setWrFile[i])
257 {
258 return pc->CurrentWriteFile(wrObj[i]);
259 }
260 }
261 }
262
263 return ustr;
264}
@ kRecycle
G4String CurrentReadFile(const G4String &objName)
StoreMode CurrentStoreMode(const G4String &objName)
const G4String & CurrentSystem()
G4String CurrentWriteFile(const G4String &objName)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445

References G4UIcommand::ConvertToString(), G4PersistencyCenter::CurrentHCIOmanager(), G4PersistencyCenter::CurrentReadFile(), G4PersistencyCenter::CurrentStoreMode(), G4PersistencyCenter::CurrentSystem(), G4PersistencyCenter::CurrentWriteFile(), kOff, kOn, kRecycle, pc, rdObj, regHitIO, select, setRdFile, setWrFile, storeObj, verboseCmd, G4PersistencyCenter::VerboseLevel(), and wrObj.

◆ ItoS()

G4String G4UImessenger::ItoS ( G4int  i)
protectedinherited

Definition at line 82 of file G4UImessenger.cc.

83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}

Referenced by G4GenericMessenger::DeclareMethod(), and G4ParticleGunMessenger::GetCurrentValue().

◆ operator!=()

G4bool G4UImessenger::operator!= ( const G4UImessenger messenger) const
inherited

Definition at line 76 of file G4UImessenger.cc.

77{
78 return this != &messenger;
79}

◆ operator==()

G4bool G4UImessenger::operator== ( const G4UImessenger messenger) const
inherited

Definition at line 70 of file G4UImessenger.cc.

71{
72 return this == &messenger;
73}

◆ PopWord()

G4String G4PersistencyCenterMessenger::PopWord ( const G4String text,
G4int  n,
const G4String delim 
)
private

Definition at line 267 of file G4PersistencyCenterMessenger.cc.

269{
270 if(text.length() <= 0)
271 return "";
272 G4int p = 0, p0 = 0;
273 G4int p1 = 0;
274 for(G4int i = 0; i < n; ++i)
275 {
276 p1 = text.find_first_of(delim, p0 + 1);
277 while(p1 == p0 + 1)
278 {
279 p0 = p1;
280 p1 = text.find_first_of(delim, p0 + 1);
281 }
282 p = p0;
283 if(p1 < 0)
284 {
285 if(i + 1 < n)
286 return "";
287 p1 = text.length();
288 break;
289 }
290 p0 = p1;
291 }
292 if(p > 0)
293 ++p;
294 return text.substr(p, p1 - p);
295}

References CLHEP::detail::n.

Referenced by SetNewValue().

◆ SetNewValue()

void G4PersistencyCenterMessenger::SetNewValue ( G4UIcommand command,
G4String  newValues 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 155 of file G4PersistencyCenterMessenger.cc.

157{
158 if(command == verboseCmd)
159 {
161 }
162 else if(command == select)
163 {
164 pc->SelectSystem(newValues);
165 }
166 else if(command == regHitIO)
167 {
168 pc->AddHCIOmanager(PopWord(newValues, 1, " "), PopWord(newValues, 2, " "));
169 }
170 else if(command == setRdFile[0])
171 {
172 pc->SetReadFile(rdObj[0], newValues);
173 }
174 else if(command == printAll)
175 {
176 pc->PrintAll();
177 }
178 else
179 {
180 for(G4int i = 0; i < 3; ++i)
181 {
182 if(command == storeObj[i])
183 {
184 StoreMode mode = kOff;
185 if(newValues == "on")
186 {
187 mode = kOn;
188 }
189 else if(newValues == "off")
190 {
191 mode = kOff;
192 }
193 else if(newValues == "recycle")
194 {
195 mode = kRecycle;
196 }
197 else
198 {
199 G4cerr << "Unrecognized keyword - \"" << newValues << "\"." << G4endl;
200 }
201 pc->SetStoreMode(wrObj[i], mode);
202 break;
203 }
204 else if(command == setWrFile[i])
205 {
206 pc->SetWriteFile(wrObj[i], newValues);
207 break;
208 }
209 }
210 }
211}
G4String PopWord(const G4String &text, G4int n, const G4String &delim)
G4bool SetWriteFile(const G4String &objName, const G4String &writeFileName)
G4bool SetReadFile(const G4String &objName, const G4String &readFileName)
void SetStoreMode(const G4String &objName, StoreMode mode)
void AddHCIOmanager(const G4String &detName, const G4String &colName)
void SelectSystem(const G4String &systemName)
static G4int GetNewIntValue(const char *paramString)

References G4PersistencyCenter::AddHCIOmanager(), G4cerr, G4endl, G4UIcmdWithAnInteger::GetNewIntValue(), kOff, kOn, kRecycle, pc, PopWord(), G4PersistencyCenter::PrintAll(), printAll, rdObj, regHitIO, select, G4PersistencyCenter::SelectSystem(), setRdFile, G4PersistencyCenter::SetReadFile(), G4PersistencyCenter::SetStoreMode(), G4PersistencyCenter::SetVerboseLevel(), setWrFile, G4PersistencyCenter::SetWriteFile(), storeObj, verboseCmd, and wrObj.

◆ StoB()

G4bool G4UImessenger::StoB ( G4String  s)
protectedinherited

Definition at line 137 of file G4UImessenger.cc.

138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
bool G4bool
Definition: G4Types.hh:86
G4String to_upper_copy(G4String str)
Return uppercase copy of string.

References G4StrUtil::to_upper_copy().

Referenced by G4LocalThreadCoutMessenger::SetNewValue(), G4CascadeParamMessenger::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ StoD()

G4double G4UImessenger::StoD ( G4String  s)
protectedinherited

◆ StoI()

G4int G4UImessenger::StoI ( G4String  s)
protectedinherited

◆ StoL()

G4long G4UImessenger::StoL ( G4String  s)
protectedinherited

Definition at line 117 of file G4UImessenger.cc.

118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
long G4long
Definition: G4Types.hh:87

Referenced by G4RunMessenger::SetNewValue().

Field Documentation

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ directory

G4UIdirectory* G4PersistencyCenterMessenger::directory = nullptr
private

◆ pc

G4PersistencyCenter* G4PersistencyCenterMessenger::pc = nullptr
private

Definition at line 68 of file G4PersistencyCenterMessenger.hh.

Referenced by GetCurrentValue(), and SetNewValue().

◆ printAll

G4UIcmdWithoutParameter* G4PersistencyCenterMessenger::printAll = nullptr
private

◆ rdObj

std::vector<std::string> G4PersistencyCenterMessenger::rdObj
private

◆ regHitIO

G4UIcmdWithAString* G4PersistencyCenterMessenger::regHitIO = nullptr
private

◆ select

G4UIcmdWithAString* G4PersistencyCenterMessenger::select = nullptr
private

◆ setRdFile

std::vector<G4UIcmdWithAString*> G4PersistencyCenterMessenger::setRdFile
private

◆ setWrFile

std::vector<G4UIcmdWithAString*> G4PersistencyCenterMessenger::setWrFile
private

◆ storeObj

std::vector<G4UIcmdWithAString*> G4PersistencyCenterMessenger::storeObj
private

◆ subdir1

G4UIdirectory * G4PersistencyCenterMessenger::subdir1 = nullptr
private

◆ subdir2

G4UIdirectory * G4PersistencyCenterMessenger::subdir2 = nullptr
private

◆ subdir3

G4UIdirectory * G4PersistencyCenterMessenger::subdir3 = nullptr
private

◆ subdir4

G4UIdirectory * G4PersistencyCenterMessenger::subdir4 = nullptr
private

◆ subdir5

G4UIdirectory * G4PersistencyCenterMessenger::subdir5 = nullptr
private

◆ verboseCmd

G4UIcmdWithAnInteger* G4PersistencyCenterMessenger::verboseCmd = nullptr
private

◆ wrObj

std::vector<std::string> G4PersistencyCenterMessenger::wrObj
private

The documentation for this class was generated from the following files: