44 pathName = thePathName;
51 G4int n_treeEntry = tree.size();
52 for(i = 0; i < n_treeEntry; ++i)
75 G4String remainingPath = commandPath;
76 remainingPath.
remove(0, pathName.length());
81 guidance = newCommand;
83 broadcastCommands =
false;
90 if(i ==
G4int(std::string::npos))
93 G4int n_commandEntry = command.size();
94 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
96 if(remainingPath == command[i_thCommand]->GetCommandName())
101 if(!broadcastCommands)
105 command.push_back(newCommand);
112 nextPath.
append(remainingPath(0, i + 1));
113 G4int n_treeEntry = tree.size();
114 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
118 if(!broadcastCommands)
120 tree[i_thTree]->AddNewCommand(newCommand, workerThreadOnly);
125 tree.push_back(newTree);
126 if(!broadcastCommands)
140 G4String remainingPath = commandPath;
141 remainingPath.
remove(0, pathName.length());
142 if(remainingPath.
isNull())
149 if(i ==
G4int(std::string::npos))
152 G4int n_commandEntry = command.size();
153 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
155 if(remainingPath == command[i_thCommand]->GetCommandName())
157 command.erase(command.begin() + i_thCommand);
166 nextPath.
append(remainingPath(0, i + 1));
167 G4int n_treeEntry = tree.size();
168 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
172 tree[i_thTree]->RemoveCommand(aCommand);
173 G4int n_commandRemain = tree[i_thTree]->GetCommandEntry();
174 G4int n_treeRemain = tree[i_thTree]->GetTreeEntry();
175 if(n_commandRemain == 0 && n_treeRemain == 0)
178 tree.erase(tree.begin() + i_thTree);
193 G4String remainingPath = commandPath;
194 if(remainingPath.
index(pathName) == std::string::npos)
198 remainingPath.
remove(0, pathName.length());
200 if(i ==
G4int(std::string::npos))
203 G4int n_commandEntry = command.size();
204 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
206 if(remainingPath == command[i_thCommand]->GetCommandName())
208 return command[i_thCommand];
216 nextPath.
append(remainingPath(0, i + 1));
217 G4int n_treeEntry = tree.size();
218 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
222 return tree[i_thTree]->FindPath(commandPath);
236 G4String remainingPath = commandPath;
237 if(remainingPath.
index(pathName) == std::string::npos)
241 remainingPath.
remove(0, pathName.length());
243 if(i !=
G4int(std::string::npos))
247 nextPath.
append(remainingPath(0, i + 1));
248 G4int n_treeEntry = tree.size();
249 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
253 return tree[i_thTree];
257 return tree[i_thTree]->FindCommandTree(commandPath);
272 G4String remainingPath = aCommandPath;
278 if(jpre !=
G4int(G4String::npos))
287 if(pName.
index(pName) == std::string::npos)
290 std::vector<G4String> paths;
300 for(
G4int idir = 1; idir <= Ndir; ++idir)
304 if(fpdir.
index(remainingPath, 0) == 0)
308 matchingPath = fpdir;
315 paths.push_back(fpdir);
319 if(paths.size() >= 2)
322 for(
unsigned int i_thCommand = 0; i_thCommand < paths.size(); ++i_thCommand)
329 std::vector<G4String> commands;
331 for(
G4int icmd = 1; icmd <= Ncmd; ++icmd)
336 if(fpcmd.
index(remainingPath, 0) == 0)
340 matchingPath = fpcmd +
" ";
344 strtmp = fpcmd +
" ";
348 commands.push_back(fpcmd +
" ");
352 if(commands.size() >= 2)
355 for(
unsigned int i_thCommand = 0; i_thCommand < commands.size();
369 G4int nlen1 = str1.length();
370 G4int nlen2 = str2.length();
372 G4int nmin = nlen1 < nlen2 ? nlen1 : nlen2;
375 for(
size_t i = 0;
G4int(i) < nmin; ++i)
377 if(str1[i] == str2[i])
379 strMatched += str1[i];
393 G4cout <<
"Command directory path : " << pathName <<
G4endl;
394 if(guidance !=
nullptr)
397 G4int n_treeEntry = tree.size();
398 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
400 G4cout <<
" " << tree[i_thTree]->GetPathName();
402 tree[i_thTree]->
GetGuidance()->IsWorkerThreadOnly())
413 G4int n_commandEntry = command.size();
414 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
416 G4cout <<
" " << command[i_thCommand]->GetCommandName();
417 if(command[i_thCommand]->IsWorkerThreadOnly())
432 G4cout <<
"Command directory path : " << pathName <<
G4endl;
433 if(guidance !=
nullptr)
437 G4int n_treeEntry = tree.size();
438 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
441 G4cout <<
" " << i <<
") " << tree[i_thTree]->GetPathName() <<
" "
442 << tree[i_thTree]->GetTitle() <<
G4endl;
445 G4int n_commandEntry = command.size();
446 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
449 G4cout <<
" " << i <<
") " << command[i_thCommand]->GetCommandName()
450 <<
" * " << command[i_thCommand]->GetTitle() <<
G4endl;
458 G4int n_commandEntry = command.size();
459 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
461 command[i_thCommand]->List();
463 G4int n_treeEntry = tree.size();
464 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
466 tree[i_thTree]->List();
471G4String G4UIcommandTree::CreateFileName(
const char* pName)
475 while((idxs = fn.
index(
"/")) !=
G4int(std::string::npos))
484G4String G4UIcommandTree::ModStr(
const char* strS)
488 for(
G4int i = 0; i <
G4int(str.length()); ++i)
512 G4String ofileName = CreateFileName(pathName);
513 std::ofstream oF(ofileName, std::ios::out);
515 oF <<
"<html><head><title>Commands in " << ModStr(pathName)
516 <<
"</title></head>" <<
G4endl;
517 oF <<
"<body bgcolor=\"#ffffff\"><h2>" << ModStr(pathName) <<
"</h2><p>"
520 if(guidance !=
nullptr)
528 oF <<
"<p><hr><p>" <<
G4endl;
530 oF <<
"<h2>Sub-directories : </h2><dl>" <<
G4endl;
531 for(std::size_t i_thTree = 0; i_thTree < tree.size(); ++i_thTree)
533 oF <<
"<p><br><p><dt><a href=\""
534 << CreateFileName(tree[i_thTree]->
GetPathName()) <<
"\">"
537 tree[i_thTree]->CreateHTML();
540 oF <<
"</dl><p><hr><p>" <<
G4endl;
542 oF <<
"<h2>Commands : </h2><dl>" <<
G4endl;
543 for(std::size_t i_thCommand = 0; i_thCommand < command.size(); ++i_thCommand)
558 oF <<
"<p><dd>" <<
G4endl;
567 std::vector<G4ApplicationState>* availabelStateList = cmd->
GetStateList();
568 if(availabelStateList->size() == 6)
570 oF <<
"<p><dd>Available at all Geant4 states." <<
G4endl;
574 oF <<
"<p><dd>Available Geant4 state(s) : ";
575 for(std::size_t ias = 0; ias < availabelStateList->size(); ++ias)
578 (*availabelStateList)[ias])
584 oF <<
"<p><dd>Parameters<table border=1>" <<
G4endl;
594 oF <<
"Omittable : ";
597 oF <<
"current value is used as the default value." <<
G4endl;
612 oF <<
"Parameter candidates : "
616 oF <<
"</table>" <<
G4endl;
620 oF <<
"</dl></body></html>" <<
G4endl;
628 for(std::size_t i = 0; i < tree.size(); ++i)
G4GLOB_DLL std::ostream G4cout
G4String GetStateString(const G4ApplicationState &aState) const
static G4StateManager * GetStateManager()
G4String & remove(str_size)
G4String & append(const G4String &)
str_size index(const char *, G4int pos=0) const
std::size_t last(char) const
std::size_t first(char) const
G4bool operator!=(const G4UIcommandTree &right) const
G4int GetCommandEntry() const
const G4UIcommand * GetGuidance() const
G4UIcommand * GetCommand(G4int i)
const G4String & GetPathName() const
G4int GetTreeEntry() const
G4UIcommandTree * GetTree(G4int i)
G4bool operator==(const G4UIcommandTree &right) const
void AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly=false)
G4UIcommandTree * FindCommandTree(const char *commandPath)
void ListCurrentWithNum() const
const G4String GetTitle() const
G4String CompleteCommandPath(const G4String &commandPath)
G4String GetFirstMatchedString(const G4String &, const G4String &) const
G4UIcommand * FindPath(const char *commandPath) const
void RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly=false)
void SetToBeBroadcasted(G4bool val)
G4bool IsWorkerThreadOnly() const
std::size_t GetParameterEntries() const
const G4String & GetGuidanceLine(G4int i) const
G4UIparameter * GetParameter(G4int i) const
G4bool ToBeBroadcasted() const
const G4String & GetCommandPath() const
std::size_t GetGuidanceEntries() const
std::vector< G4ApplicationState > * GetStateList()
void SetWorkerThreadOnly(G4bool val=true)
const G4String & GetCommandName() const
const G4String & GetRange() const
const G4String & GetParameterCandidates() const
G4bool IsOmittable() const
const G4String & GetParameterRange() const
G4bool GetCurrentAsDefault() const
char GetParameterType() const
const G4String & GetParameterName() const
const G4String & GetDefaultValue() const