36 :guidance(NULL),broadcastCommands(true)
40 :guidance(NULL),broadcastCommands(true)
42 pathName = thePathName;
48 G4int n_treeEntry = tree.size();
49 for( i=0; i < n_treeEntry; i++ )
66 G4String remainingPath = commandPath;
67 remainingPath.
remove(0,pathName.length());
68 if( remainingPath.
isNull() )
72 guidance = newCommand;
79 if( i ==
G4int(std::string::npos) )
82 G4int n_commandEntry = command.size();
83 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
85 if( remainingPath == command[i_thCommand]->GetCommandName() )
90 command.push_back( newCommand );
97 nextPath.
append(remainingPath(0,i+1));
98 G4int n_treeEntry = tree.size();
99 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
104 tree[i_thTree]->AddNewCommand( newCommand, workerThreadOnly );
109 tree.push_back( newTree );
120 G4String remainingPath = commandPath;
121 remainingPath.
remove(0,pathName.length());
122 if( remainingPath.
isNull() )
129 if( i ==
G4int(std::string::npos) )
132 G4int n_commandEntry = command.size();
133 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
135 if( remainingPath == command[i_thCommand]->GetCommandName() )
137 command.erase(command.begin()+i_thCommand);
146 nextPath.
append(remainingPath(0,i+1));
147 G4int n_treeEntry = tree.size();
148 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
152 tree[i_thTree]->RemoveCommand( aCommand );
153 G4int n_commandRemain = tree[i_thTree]->GetCommandEntry();
155 if(n_commandRemain == 0 && n_treeRemain == 0)
158 tree.erase(tree.begin()+i_thTree);
173 G4String remainingPath = commandPath;
174 if( remainingPath.
index( pathName ) == std::string::npos )
176 remainingPath.
remove(0,pathName.length());
178 if( i ==
G4int(std::string::npos) )
181 G4int n_commandEntry = command.size();
182 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
184 if( remainingPath == command[i_thCommand]->GetCommandName() )
185 {
return command[i_thCommand]; }
192 nextPath.
append(remainingPath(0,i+1));
193 G4int n_treeEntry = tree.size();
194 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
197 {
return tree[i_thTree]->FindPath( commandPath ); }
211 G4String remainingPath = commandPath;
212 if( remainingPath.
index( pathName ) == std::string::npos )
214 remainingPath.
remove(0,pathName.length());
216 if( i !=
G4int(std::string::npos) )
220 nextPath.
append(remainingPath(0,i+1));
221 G4int n_treeEntry = tree.size();
222 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
224 if (tree[i_thTree]->
GetPathName() == commandPath) {
225 return tree[i_thTree];
227 else if( nextPath == tree[i_thTree]->
GetPathName() ) {
228 return tree[i_thTree]->FindCommandTree( commandPath );
240 G4String remainingPath = aCommandPath;
246 if(jpre !=
G4int(G4String::npos)) pName.
remove(jpre+1);
253 if( pName.
index( pName ) == std::string::npos )
return empty;
255 std::vector<G4String> paths;
265 for(
G4int idir=1; idir<=Ndir; idir++) {
268 if( fpdir.
index(remainingPath, 0) == 0) {
270 matchingPath = fpdir;
272 matchingPath = GetFirstMatchedString(fpdir,matchingPath);
275 paths.push_back(fpdir);
279 if (paths.size()>=2) {
281 for(
unsigned int i_thCommand = 0; i_thCommand < paths.size(); i_thCommand++ ) {
287 std::vector<G4String> commands;
289 for(
G4int icmd=1; icmd<=Ncmd; icmd++){
293 if( fpcmd.
index(remainingPath, 0) ==0) {
295 matchingPath= fpcmd +
" ";
298 matchingPath= GetFirstMatchedString(matchingPath, strtmp);
301 commands.push_back(fpcmd+
" ");
305 if (commands.size()>=2) {
307 for(
unsigned int i_thCommand = 0; i_thCommand < commands.size(); i_thCommand++ ) {
321 int nlen1= str1.length();
322 int nlen2= str2.length();
324 int nmin = nlen1<nlen2 ? nlen1 : nlen2;
327 for(
size_t i=0;
G4int(i)<nmin; i++){
328 if(str1[i]==str2[i]) {
329 strMatched+= str1[i];
340 G4cout <<
"Command directory path : " << pathName <<
G4endl;
341 if( guidance != NULL ) guidance->
List();
343 G4int n_treeEntry = tree.size();
344 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
346 G4cout <<
" " << tree[i_thTree]->GetPathName();
348 tree[i_thTree]->
GetGuidance()->IsWorkerThreadOnly())
355 G4int n_commandEntry = command.size();
356 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
358 G4cout <<
" " << command[i_thCommand]->GetCommandName();
359 if(command[i_thCommand]->IsWorkerThreadOnly())
369 G4cout <<
"Command directory path : " << pathName <<
G4endl;
370 if( guidance != NULL ) guidance->
List();
373 G4int n_treeEntry = tree.size();
374 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
377 G4cout <<
" " << i <<
") " << tree[i_thTree]->GetPathName()
378 <<
" " << tree[i_thTree]->GetTitle() <<
G4endl;
381 G4int n_commandEntry = command.size();
382 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
385 G4cout <<
" " << i <<
") " << command[i_thCommand]->GetCommandName()
386 <<
" * " << command[i_thCommand]->GetTitle() <<
G4endl;
393 G4int n_commandEntry = command.size();
394 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
396 command[i_thCommand]->List();
398 G4int n_treeEntry = tree.size();
399 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
401 tree[i_thTree]->List();
405 G4String G4UIcommandTree::CreateFileName(
const char* pName)
409 while((idxs=fn.
index(
"/"))!=
G4int(std::string::npos))
415 G4String G4UIcommandTree::ModStr(
const char* strS)
429 sx +=
"&";
break;
439 G4String ofileName = CreateFileName(pathName);
440 std::ofstream oF(ofileName, std::ios::out);
442 oF <<
"<html><head><title>Commands in " << ModStr(pathName) <<
"</title></head>" <<
G4endl;
443 oF <<
"<body bgcolor=\"#ffffff\"><h2>" << ModStr(pathName) <<
"</h2><p>" <<
G4endl;
445 if( guidance != NULL )
451 oF <<
"<p><hr><p>" <<
G4endl;
453 oF <<
"<h2>Sub-directories : </h2><dl>" <<
G4endl;
454 for(
G4int i_thTree = 0; i_thTree <
G4int(tree.size()); i_thTree++ )
456 oF <<
"<p><br><p><dt><a href=\"" << CreateFileName(tree[i_thTree]->
GetPathName())
459 tree[i_thTree]->CreateHTML();
462 oF <<
"</dl><p><hr><p>" <<
G4endl;
464 oF <<
"<h2>Commands : </h2><dl>" <<
G4endl;
465 for(
G4int i_thCommand = 0; i_thCommand <
G4int(command.size()); i_thCommand++ )
475 oF <<
"<p><dd>" <<
G4endl;
479 { oF <<
"<p><dd>Range : " << ModStr(cmd->
GetRange()) << G4endl; }
480 std::vector<G4ApplicationState>* availabelStateList = cmd->
GetStateList();
481 if(availabelStateList->size()==6)
482 { oF <<
"<p><dd>Available at all Geant4 states." <<
G4endl; }
485 oF <<
"<p><dd>Available Geant4 state(s) : ";
486 for(
G4int ias=0;ias<
G4int(availabelStateList->size());ias++)
491 oF <<
"<p><dd>Parameters<table border=1>" <<
G4endl;
500 oF <<
"Omittable : ";
502 { oF <<
"current value is used as the default value." <<
G4endl; }
512 oF <<
"</table>" <<
G4endl;
517 oF <<
"</dl></body></html>" <<
G4endl;
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4String GetParameterCandidates() const
const G4String & GetRange() const
G4bool IsWorkerThreadOnly() const
G4String & remove(str_size)
G4UIcommand * FindPath(const char *commandPath) const
G4int GetCommandEntry() const
G4int operator==(const G4UIcommandTree &right) const
G4String GetParameterName() const
G4UIcommand * GetCommand(G4int i)
void SetToBeBroadcasted(G4bool val)
G4int GetTreeEntry() const
G4int operator!=(const G4UIcommandTree &right) const
const G4String & GetGuidanceLine(G4int i) const
G4bool IsOmittable() const
static G4StateManager * GetStateManager()
G4bool ToBeBroadcasted() const
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4UIcommandTree * GetTree(G4int i)
G4UIparameter * GetParameter(G4int i) const
void ListCurrentWithNum() const
void RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly=false)
const G4String & GetCommandPath() const
const G4String GetPathName() const
const G4String & GetCommandName() const
void SetWorkerThreadOnly(G4bool val=true)
const G4String GetTitle() const
void AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly=false)
G4String & append(const G4String &)
G4String GetDefaultValue() const
std::vector< G4ApplicationState > * GetStateList()
const G4UIcommand * GetGuidance() const
char GetParameterType() const
G4String GetParameterRange() const
G4int GetGuidanceEntries() const
G4int GetParameterEntries() const
G4bool GetCurrentAsDefault() const
G4String CompleteCommandPath(const G4String &commandPath)
G4String GetStateString(G4ApplicationState aState) const