Geant4  10.02.p03
G4PersistencyCenterMessenger Class Reference

#include <G4PersistencyCenterMessenger.hh>

Inheritance diagram for G4PersistencyCenterMessenger:
Collaboration diagram for G4PersistencyCenterMessenger:

Public Member Functions

 G4PersistencyCenterMessenger (G4PersistencyCenter *p)
 
 ~G4PersistencyCenterMessenger ()
 
void SetNewValue (G4UIcommand *command, G4String newValues)
 
G4String GetCurrentValue (G4UIcommand *command)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Private Member Functions

std::string PopWord (std::string text, int n, std::string delim)
 

Private Attributes

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

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 
G4bool commandsShouldBeInMaster
 

Detailed Description

Definition at line 47 of file G4PersistencyCenterMessenger.hh.

Constructor & Destructor Documentation

◆ G4PersistencyCenterMessenger()

G4PersistencyCenterMessenger::G4PersistencyCenterMessenger ( G4PersistencyCenter p)

Definition at line 34 of file G4PersistencyCenterMessenger.cc.

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

◆ ~G4PersistencyCenterMessenger()

G4PersistencyCenterMessenger::~G4PersistencyCenterMessenger ( )

Definition at line 131 of file G4PersistencyCenterMessenger.cc.

132 {
133  delete directory;
134  delete subdir1;
135  delete subdir2;
136  delete subdir3;
137  delete subdir4;
138  delete subdir5;
139  delete verboseCmd;
140  delete select;
141  delete regHitIO;
142  for ( int i = 0; i < 3; i++ )
143  {
144  delete storeObj[i];
145  delete setWrFile[i];
146  }
147  delete setRdFile[0];
148  delete printAll;
149 }
std::vector< G4UIcmdWithAString * > setRdFile
std::vector< G4UIcmdWithAString * > storeObj
std::vector< G4UIcmdWithAString * > setWrFile

Member Function Documentation

◆ GetCurrentValue()

G4String G4PersistencyCenterMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 203 of file G4PersistencyCenterMessenger.cc.

204 {
205  G4String ustr="Undefined";
206 
207  if (command==verboseCmd)
208  {
209  return pc->VerboseLevel();
210  }
211  else if (command==select)
212  {
213  return pc->CurrentSystem();
214  }
215  else if (command==regHitIO)
216  {
217  return pc->CurrentHCIOmanager();
218  }
219  else if (command==setRdFile[0])
220  {
221  return pc->CurrentReadFile(rdObj[0]);
222  }
223  else
224  {
225  for( int i=0; i<3; i++ ) {
226  if( command==storeObj[i] )
227  {
228  switch (pc->CurrentStoreMode(wrObj[i])) {
229  case kOn:
230  return "on";
231  break;
232  case kOff:
233  return "off";
234  break;
235  case kRecycle:
236  return "recycle";
237  break;
238  default:
239  return "?????";
240  break;
241  };
242  }
243  else if( command==setWrFile[i] )
244  {
245  return pc->CurrentWriteFile(wrObj[i]);
246  }
247  }
248  }
249 
250  return ustr;
251 }
std::string CurrentReadFile(std::string objName)
std::vector< G4UIcmdWithAString * > setRdFile
std::vector< G4UIcmdWithAString * > storeObj
StoreMode CurrentStoreMode(std::string objName)
std::string CurrentHCIOmanager()
std::vector< G4UIcmdWithAString * > setWrFile
const std::string CurrentSystem()
std::string CurrentWriteFile(std::string objName)
Here is the call graph for this function:

◆ PopWord()

std::string G4PersistencyCenterMessenger::PopWord ( std::string  text,
int  n,
std::string  delim 
)
private

Definition at line 254 of file G4PersistencyCenterMessenger.cc.

255 {
256  if ( text.length() <= 0 ) return "";
257  int p = 0, p0 = 0;
258  int p1 = 0;
259  for ( int i = 0; i < n; i++ ) {
260  p1 = text.find_first_of(delim,p0+1);
261  while( p1 == p0+1 ) {
262  p0 = p1;
263  p1 = text.find_first_of(delim,p0+1);
264  }
265  p = p0;
266  if ( p1 < 0 ) {
267  if ( i+1 < n ) return "";
268  p1 = text.length();
269  break;
270  }
271  p0 = p1;
272  }
273  if (p > 0) p++;
274  return text.substr(p,p1-p);
275 }
Char_t n[5]
Here is the caller graph for this function:

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 152 of file G4PersistencyCenterMessenger.cc.

153 {
154  if (command==verboseCmd)
155  {
157  }
158  else if (command==select)
159  {
160  pc->SelectSystem(newValues);
161  }
162  else if (command==regHitIO)
163  {
164  pc->AddHCIOmanager(PopWord(newValues,1," "),PopWord(newValues,2," "));
165  }
166  else if (command==setRdFile[0])
167  {
168  pc -> SetReadFile ( rdObj[0],newValues);
169  }
170  else if (command==printAll)
171  {
172  pc->PrintAll();
173  }
174  else
175  {
176  for( int i=0; i<3; i++ ) {
177  if( command==storeObj[i] )
178  {
179  StoreMode mode = kOff;
180  if( newValues == "on" ) {
181  mode = kOn;
182  } else if ( newValues == "off" ) {
183  mode = kOff;
184  } else if ( newValues == "recycle" ) {
185  mode = kRecycle;
186  } else {
187  G4cerr << "Unrecognized keyword - \"" << newValues << "\"."
188  << G4endl;
189  }
190  pc->SetStoreMode(wrObj[i],mode);
191  break;
192  }
193  else if( command==setWrFile[i] )
194  {
195  pc->SetWriteFile(wrObj[i],newValues);
196  break;
197  }
198  }
199  }
200 }
void AddHCIOmanager(std::string detName, std::string colName)
static G4int GetNewIntValue(const char *paramString)
std::vector< G4UIcmdWithAString * > setRdFile
std::vector< G4UIcmdWithAString * > storeObj
std::string PopWord(std::string text, int n, std::string delim)
void SelectSystem(std::string systemName)
std::vector< G4UIcmdWithAString * > setWrFile
G4bool SetWriteFile(std::string objName, std::string writeFileName)
void SetStoreMode(std::string objName, StoreMode mode)
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:

Member Data Documentation

◆ directory

G4UIdirectory* G4PersistencyCenterMessenger::directory
private

Definition at line 70 of file G4PersistencyCenterMessenger.hh.

◆ pc

G4PersistencyCenter* G4PersistencyCenterMessenger::pc
private

Definition at line 69 of file G4PersistencyCenterMessenger.hh.

◆ printAll

G4UIcmdWithoutParameter* G4PersistencyCenterMessenger::printAll
private

Definition at line 80 of file G4PersistencyCenterMessenger.hh.

◆ rdObj

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

Definition at line 76 of file G4PersistencyCenterMessenger.hh.

◆ regHitIO

G4UIcmdWithAString* G4PersistencyCenterMessenger::regHitIO
private

Definition at line 74 of file G4PersistencyCenterMessenger.hh.

◆ select

G4UIcmdWithAString* G4PersistencyCenterMessenger::select
private

Definition at line 73 of file G4PersistencyCenterMessenger.hh.

◆ setRdFile

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

Definition at line 79 of file G4PersistencyCenterMessenger.hh.

◆ setWrFile

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

Definition at line 78 of file G4PersistencyCenterMessenger.hh.

◆ storeObj

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

Definition at line 77 of file G4PersistencyCenterMessenger.hh.

◆ subdir1

G4UIdirectory * G4PersistencyCenterMessenger::subdir1
private

Definition at line 70 of file G4PersistencyCenterMessenger.hh.

◆ subdir2

G4UIdirectory * G4PersistencyCenterMessenger::subdir2
private

Definition at line 70 of file G4PersistencyCenterMessenger.hh.

◆ subdir3

G4UIdirectory * G4PersistencyCenterMessenger::subdir3
private

Definition at line 70 of file G4PersistencyCenterMessenger.hh.

◆ subdir4

G4UIdirectory * G4PersistencyCenterMessenger::subdir4
private

Definition at line 70 of file G4PersistencyCenterMessenger.hh.

◆ subdir5

G4UIdirectory * G4PersistencyCenterMessenger::subdir5
private

Definition at line 70 of file G4PersistencyCenterMessenger.hh.

◆ verboseCmd

G4UIcmdWithAnInteger* G4PersistencyCenterMessenger::verboseCmd
private

Definition at line 72 of file G4PersistencyCenterMessenger.hh.

◆ wrObj

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

Definition at line 75 of file G4PersistencyCenterMessenger.hh.


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