Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UIcommandTree Class Reference

#include <G4UIcommandTree.hh>

Public Member Functions

 G4UIcommandTree ()=default
 
 G4UIcommandTree (const char *thePathName)
 
 ~G4UIcommandTree ()
 
G4bool operator== (const G4UIcommandTree &right) const
 
G4bool operator!= (const G4UIcommandTree &right) const
 
void AddNewCommand (G4UIcommand *newCommand, G4bool workerThreadOnly=false)
 
void RemoveCommand (G4UIcommand *aCommand, G4bool workerThreadOnly=false)
 
G4UIcommandFindPath (const char *commandPath) const
 
G4UIcommandTreeFindCommandTree (const char *commandPath)
 
G4String GetFirstMatchedString (const G4String &, const G4String &) const
 
G4String CompleteCommandPath (const G4String &commandPath)
 
void List () const
 
void ListCurrent () const
 
void ListCurrentWithNum () const
 
void CreateHTML (const G4String &="")
 
const G4UIcommandGetGuidance () const
 
const G4StringGetPathName () const
 
G4int GetTreeEntry () const
 
G4int GetCommandEntry () const
 
G4UIcommandTreeGetTree (G4int i)
 
G4UIcommandTreeGetTree (const char *comNameC)
 
G4UIcommandGetCommand (G4int i)
 
const G4String GetTitle () const
 

Detailed Description

Definition at line 44 of file G4UIcommandTree.hh.

Constructor & Destructor Documentation

◆ G4UIcommandTree() [1/2]

G4UIcommandTree::G4UIcommandTree ( )
default

Referenced by AddNewCommand().

◆ G4UIcommandTree() [2/2]

G4UIcommandTree::G4UIcommandTree ( const char * thePathName)

Definition at line 43 of file G4UIcommandTree.cc.

44{
45 pathName = thePathName;
46}

◆ ~G4UIcommandTree()

G4UIcommandTree::~G4UIcommandTree ( )

Definition at line 49 of file G4UIcommandTree.cc.

50{
51 for (auto& i : tree) {
52 delete i;
53 }
54}

Member Function Documentation

◆ AddNewCommand()

void G4UIcommandTree::AddNewCommand ( G4UIcommand * newCommand,
G4bool workerThreadOnly = false )

Definition at line 69 of file G4UIcommandTree.cc.

70{
71 G4String commandPath = newCommand->GetCommandPath();
72 G4String remainingPath = commandPath;
73 remainingPath.erase(0, pathName.length());
74 if (remainingPath.empty()) {
75 if (guidance == nullptr) {
76 guidance = newCommand;
77 if (!(newCommand->ToBeBroadcasted())) {
78 broadcastCommands = false;
79 }
80 if (workerThreadOnly) {
81 newCommand->SetWorkerThreadOnly();
82 }
83 }
84 return;
85 }
86
87 if (guidance != nullptr) {
88 auto* dir = static_cast<G4UIdirectory*>(guidance);
89 ifSort = dir->IfSort();
90 }
91 std::size_t i = remainingPath.find('/');
92 if (i == std::string::npos) {
93 // Adding a new command to this directory
94 std::size_t n_commandEntry = command.size();
95 for (std::size_t i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand) {
96 if (remainingPath == command[i_thCommand]->GetCommandName()) {
97 // a command of same name has already defined. do nothing and return.
98 if (G4UImanager::GetUIpointer()->GetVerboseLevel() > 8) {
100 ed << "Command <" << commandPath << "> already exist. New command is not added.";
101 G4Exception("G4UIcommandTree::AddNewCommand", "UI_ComTree_001",
102 // FatalException,
103 JustWarning, ed);
104 }
105 return;
106 }
107 }
108 if (!broadcastCommands) {
109 newCommand->SetToBeBroadcasted(false);
110 }
111 if (workerThreadOnly) {
112 newCommand->SetWorkerThreadOnly();
113 }
114 if (ifSort) {
115 auto j = command.cbegin();
116 for (; j != command.cend(); ++j) {
117 if (newCommand->GetCommandPath() < (*j)->GetCommandPath()) {
118 break;
119 }
120 }
121 command.insert(j, newCommand);
122 }
123 else {
124 command.push_back(newCommand);
125 }
126 return;
127 }
128
129 // Adding a new command to a sub-directory
130 G4String nextPath = pathName;
131 nextPath.append(remainingPath.substr(0, i + 1));
132 std::size_t n_treeEntry = tree.size();
133 for (std::size_t i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree) {
134 if (nextPath == tree[i_thTree]->GetPathName()) {
135 if (!broadcastCommands) {
136 newCommand->SetToBeBroadcasted(false);
137 }
138 tree[i_thTree]->AddNewCommand(newCommand, workerThreadOnly);
139 return;
140 }
141 }
142 // Creating a new sub-directory
143 auto* newTree = new G4UIcommandTree(nextPath);
144 if (ifSort) {
145 auto j = tree.cbegin();
146 for (; j != tree.cend(); ++j) {
147 if (newTree->GetPathName() < (*j)->GetPathName()) {
148 break;
149 }
150 }
151 tree.insert(j, newTree);
152 }
153 else {
154 tree.push_back(newTree);
155 }
156 if (!broadcastCommands) {
157 newCommand->SetToBeBroadcasted(false);
158 }
159 // In case a new sub-directry is created with a new G4UIdirectory
160 // (most-likely this is the case), inherit the sort flag
161 newCommand->SetDefaultSortFlag(ifSort);
162 newTree->AddNewCommand(newCommand, workerThreadOnly);
163 return;
164}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4UIcommandTree()=default
const G4String & GetPathName() const
void SetToBeBroadcasted(G4bool val)
G4bool ToBeBroadcasted() const
const G4String & GetCommandPath() const
void SetWorkerThreadOnly(G4bool val=true)
void SetDefaultSortFlag(G4bool val)
static G4UImanager * GetUIpointer()

Referenced by G4UImanager::AddNewCommand().

◆ CompleteCommandPath()

G4String G4UIcommandTree::CompleteCommandPath ( const G4String & commandPath)

Definition at line 280 of file G4UIcommandTree.cc.

281{
282 G4String pName = aCommandPath;
283 G4String remainingPath = aCommandPath;
284 G4String empty = "";
285 G4String matchingPath = empty;
286
287 // find the tree
288 auto jpre = pName.rfind('/');
289 if (jpre != G4String::npos) {
290 pName.erase(jpre + 1);
291 }
292 G4UIcommandTree* aTree = FindCommandTree(pName);
293
294 if (aTree == nullptr) {
295 return empty;
296 }
297
298 if (pName.find(pName) == std::string::npos) {
299 return empty;
300 }
301
302 std::vector<G4String> paths;
303
304 // list matched directories/commands
305 G4String strtmp;
306 G4int nMatch = 0;
307
308 G4int Ndir = aTree->GetTreeEntry();
309 G4int Ncmd = aTree->GetCommandEntry();
310
311 // directory ...
312 for (G4int idir = 1; idir <= Ndir; ++idir) {
313 G4String fpdir = aTree->GetTree(idir)->GetPathName();
314 // matching test
315 if (fpdir.find(remainingPath, 0) == 0) {
316 if (nMatch == 0) {
317 matchingPath = fpdir;
318 }
319 else {
320 matchingPath = GetFirstMatchedString(fpdir, matchingPath);
321 }
322 ++nMatch;
323 paths.push_back(fpdir);
324 }
325 }
326
327 if (paths.size() >= 2) {
328 G4cout << "Matching directories :" << G4endl;
329 for (const auto& path : paths) {
330 G4cout << path << G4endl;
331 }
332 }
333
334 // command ...
335 std::vector<G4String> commands;
336
337 for (G4int icmd = 1; icmd <= Ncmd; ++icmd) {
338 G4String fpcmd = aTree->GetPathName() + aTree->GetCommand(icmd)->GetCommandName();
339 // matching test
340 if (fpcmd.find(remainingPath, 0) == 0) {
341 if (nMatch == 0) {
342 matchingPath = fpcmd + " ";
343 }
344 else {
345 strtmp = fpcmd + " ";
346 matchingPath = GetFirstMatchedString(matchingPath, strtmp);
347 }
348 nMatch++;
349 commands.emplace_back(fpcmd + " ");
350 }
351 }
352
353 if (commands.size() >= 2) {
354 G4cout << "Matching commands :" << G4endl;
355 for (const auto& matched : commands) {
356 G4cout << matched << G4endl;
357 }
358 }
359
360 return matchingPath;
361}
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4int GetCommandEntry() const
G4UIcommand * GetCommand(G4int i)
G4int GetTreeEntry() const
G4UIcommandTree * GetTree(G4int i)
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4String GetFirstMatchedString(const G4String &, const G4String &) const
const G4String & GetCommandName() const

Referenced by G4VBasicShell::FindMatchingPath().

◆ CreateHTML()

void G4UIcommandTree::CreateHTML ( const G4String & sideBar = "")

Definition at line 494 of file G4UIcommandTree.cc.

495{
496 G4String ofileName = CreateFileName(pathName);
497 std::ofstream oF(ofileName, std::ios::out);
498
499 oF << "<html><head><title>Commands in " << ModStr(pathName) << "</title></head>" << G4endl;
500 oF << "<style> \
501 table,table td,table th { \
502 border:1px solid #eee \
503 } \
504 table td,table th { \
505 padding:5px 20px; \
506 line-height:1.3; \
507 text-align:inherit \
508 } \
509 a { \
510 color:#17a81a; \
511 text-decoration:none; \
512 transition-duration:0.3s \
513 } \
514 a:hover { \
515 color:#17a81a \
516 } \
517 table { \
518 border-collapse:collapse; \
519 border-spacing:0; \
520 margin-bottom:5px; \
521 } \
522 h1 { \
523 font-size:2.25em; \
524 font-weight:300; \
525 letter-spacing:-1px; \
526 line-height:1.15em; \
527 margin-bottom:0.5em; \
528 word-wrap:break-word \
529 } \
530 h2 { \
531 font-size:1.5em; \
532 font-weight:300; \
533 letter-spacing:-1px; \
534 line-height:1.15em; \
535 margin-bottom:0.5em; \
536 word-wrap:break-word \
537 } \
538 h3 { \
539 color:#26282a; \
540 font-weight:300; \
541 font-size:1.3em; \
542 padding:15px 0 15px 0; \
543 border-bottom:2px #eee solid; \
544 word-wrap:break-word \
545 } \
546 .sidebar { \
547 display:block; \
548 position:relative; \
549 position:sticky; \
550 float:left; \
551 -webkit-box-sizing:border-box; \
552 -moz-box-sizing:border-box; \
553 -ms-box-sizing:border-box; \
554 box-sizing:border-box; \
555 width:20%; \
556 padding-right:20px \
557 } \
558 .context { \
559 width:80%; \
560 display:inline-block; \
561 background-color:#fff; \
562 padding: 25px 35px 20px 30px; \
563 -webkit-box-sizing:border-box; \
564 -moz-box-sizing:border-box; \
565 -ms-box-sizing:border-box; \
566 box-sizing:border-box \
567 } \
568 </style>"
569 << G4endl;
570 oF << "<body bgcolor=\"#ffffff\">" << G4endl;
571
572 // Left Panel
573 if (createHTMLTreeLevel == 0) {
574 oF << "<div class=\"sidebar\">" << sideBar << "</div>" << G4endl;
575 }
576 // Right Panel
577 oF << "<div class=\"context\">";
578 oF << "<h1>" << ModStr(pathName) << "</h1>" << G4endl;
579
580 if (guidance != nullptr) {
581 for (G4int i = 0; i < (G4int)guidance->GetGuidanceEntries(); ++i) {
582 oF << ModStr(guidance->GetGuidanceLine(i)) << "<br>" << G4endl;
583 }
584 }
585 if (!tree.empty()) {
586 G4String menu = "";
587 G4String newSideBar = "";
588 menu += "<h2>Sub-directories </h2><table>";
589 newSideBar += "<h2><a href=\"" + ofileName + "\">Top level </a></h2><table>";
590 // Build menu short version
591 for (auto& i_thTree : tree) {
592 newSideBar += "<tr><td><a href=\"" + CreateFileName(i_thTree->GetPathName()) + "\">"
593 + ModStr(i_thTree->GetPathName()) + "</a>";
594 }
595 // Build menu
596 for (auto& i_thTree : tree) {
597 menu += "<tr><td><a href=\"" + CreateFileName(i_thTree->GetPathName()) + "\">"
598 + ModStr(i_thTree->GetPathName()) + "</a>";
599 menu += "</td><td>" + ModStr(i_thTree->GetTitle()) + "</tr>";
600 }
601 menu += "</table>";
602 newSideBar += "</table>";
603 for (auto& i_thTree : tree) {
604 createHTMLTreeLevel++;
605 i_thTree->CreateHTML(newSideBar);
606 createHTMLTreeLevel--;
607 }
608 oF << menu << G4endl;
609 }
610
611 if (!command.empty()) {
612 oF << "<h2>Commands </h2>" << G4endl;
613
614 // resume
615 oF << "<table>" << G4endl;
616 for (std::size_t i_thCommand = 0; i_thCommand < command.size(); ++i_thCommand) {
617 G4UIcommand* cmd = command[i_thCommand];
618 oF << "<tr><td><a href=\"#c" << i_thCommand << "\">" << ModStr(cmd->GetCommandName());
619 oF << "</a></td></tr>" << G4endl;
620 }
621 oF << "</table>" << G4endl;
622 for (std::size_t i_thCommand = 0; i_thCommand < command.size(); ++i_thCommand) {
623 G4UIcommand* cmd = command[i_thCommand];
624 oF << "<h3 id=\"c" << i_thCommand << "\">" << ModStr(cmd->GetCommandName());
625 if (cmd->GetParameterEntries() > 0) {
626 for (G4int i_thParam = 0; i_thParam < (G4int)cmd->GetParameterEntries(); ++i_thParam) {
627 oF << " [<i>" << ModStr(cmd->GetParameter(i_thParam)->GetParameterName()) << "</i>]";
628 }
629 }
630 oF << "</h3>" << G4endl;
631 oF << "<p>" << G4endl;
632 for (G4int i = 0; i < (G4int)cmd->GetGuidanceEntries(); ++i) {
633 oF << ModStr(cmd->GetGuidanceLine(i)) << "<br>" << G4endl;
634 }
635 if (!(cmd->GetRange()).empty()) {
636 oF << "<p>Range : " << ModStr(cmd->GetRange()) << G4endl;
637 }
638 std::vector<G4ApplicationState>* availabelStateList = cmd->GetStateList();
639 if (availabelStateList->size() == 6) {
640 oF << "<p>Available at all Geant4 states." << G4endl;
641 }
642 else {
643 oF << "<p>Available Geant4 state(s) : ";
644 for (auto& ias : *availabelStateList) {
646 }
647 }
648 if (cmd->GetParameterEntries() > 0) {
649 oF << "<p>Parameters<table border=1>" << G4endl;
650 for (G4int i_thParam = 0; i_thParam < (G4int)cmd->GetParameterEntries(); ++i_thParam) {
651 G4UIparameter* prm = cmd->GetParameter(i_thParam);
652 oF << "<tr><td>" << ModStr(prm->GetParameterName()) << G4endl;
653 oF << "<td>type " << prm->GetParameterType() << G4endl;
654 oF << "<td>";
655 if (prm->IsOmittable()) {
656 oF << "Omittable : ";
657 if (prm->GetCurrentAsDefault()) {
658 oF << "current value is used as the default value." << G4endl;
659 }
660 else {
661 oF << "default value = " << prm->GetDefaultValue() << G4endl;
662 }
663 }
664 oF << "<td>";
665 if (!(prm->GetParameterRange()).empty()) {
666 oF << "Parameter range : " << ModStr(prm->GetParameterRange()) << G4endl;
667 }
668 else if (!(prm->GetParameterCandidates()).empty()) {
669 oF << "Parameter candidates : " << ModStr(prm->GetParameterCandidates()) << G4endl;
670 }
671 }
672 oF << "</table>" << G4endl;
673 }
674 }
675 }
676 oF << "</div></body></html>" << G4endl;
677 oF.close();
678}
G4String GetStateString(const G4ApplicationState &aState) const
static G4StateManager * GetStateManager()
std::size_t GetParameterEntries() const
const G4String & GetGuidanceLine(G4int i) const
G4UIparameter * GetParameter(G4int i) const
std::size_t GetGuidanceEntries() const
std::vector< G4ApplicationState > * GetStateList()
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

Referenced by G4UImanager::CreateHTML().

◆ FindCommandTree()

G4UIcommandTree * G4UIcommandTree::FindCommandTree ( const char * commandPath)

Definition at line 247 of file G4UIcommandTree.cc.

248{
249 // Try to match a command or a path with the one given.
250 // @commandPath : command or path to match
251 // @return the commandTree found or nullptr if not
252
253 G4String remainingPath = commandPath;
254 if (remainingPath.find(pathName) == std::string::npos) {
255 return nullptr;
256 }
257 remainingPath.erase(0, pathName.length());
258 std::size_t i = remainingPath.find('/');
259 if (i != std::string::npos) {
260 // Find path
261 G4String nextPath = pathName;
262 nextPath.append(remainingPath.substr(0, i + 1));
263 std::size_t n_treeEntry = tree.size();
264 for (std::size_t i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree) {
265 if (tree[i_thTree]->GetPathName() == commandPath) {
266 return tree[i_thTree];
267 }
268 if (nextPath == tree[i_thTree]->GetPathName()) {
269 return tree[i_thTree]->FindCommandTree(commandPath);
270 }
271 }
272 }
273 else {
274 return this;
275 }
276 return nullptr;
277}

Referenced by CompleteCommandPath(), G4UImessenger::CreateDirectory(), and G4OpenGLQtViewer::updateViewerPropertiesTableWidget().

◆ FindPath()

G4UIcommand * G4UIcommandTree::FindPath ( const char * commandPath) const

Definition at line 213 of file G4UIcommandTree.cc.

214{
215 // This function tries to match a command name
216
217 G4String remainingPath = commandPath;
218 if (remainingPath.find(pathName) == std::string::npos) {
219 return nullptr;
220 }
221 remainingPath.erase(0, pathName.length());
222 std::size_t i = remainingPath.find('/');
223 if (i == std::string::npos) {
224 // Find command
225 std::size_t n_commandEntry = command.size();
226 for (std::size_t i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand) {
227 if (remainingPath == command[i_thCommand]->GetCommandName()) {
228 return command[i_thCommand];
229 }
230 }
231 }
232 else {
233 // Find path
234 G4String nextPath = pathName;
235 nextPath.append(remainingPath.substr(0, i + 1));
236 std::size_t n_treeEntry = tree.size();
237 for (std::size_t i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree) {
238 if (nextPath == tree[i_thTree]->GetPathName()) {
239 return tree[i_thTree]->FindPath(commandPath);
240 }
241 }
242 }
243 return nullptr;
244}

Referenced by G4UIQt::AddButton(), G4UIQt::AddIcon(), G4UImanager::ApplyCommand(), G4UImanager::FindCommand(), G4VBasicShell::FindCommand(), G4VisCommandDrawLogicalVolume::G4VisCommandDrawLogicalVolume(), G4VisCommandDrawVolume::G4VisCommandDrawVolume(), G4VisCommandOpen::G4VisCommandOpen(), G4VisCommandSceneAddMagneticField::G4VisCommandSceneAddMagneticField(), G4UImanager::GetCurrentValues(), and G4VBasicShell::TerminalHelp().

◆ GetCommand()

G4UIcommand * G4UIcommandTree::GetCommand ( G4int i)
inline

◆ GetCommandEntry()

G4int G4UIcommandTree::GetCommandEntry ( ) const
inline

◆ GetFirstMatchedString()

G4String G4UIcommandTree::GetFirstMatchedString ( const G4String & str1,
const G4String & str2 ) const

Definition at line 364 of file G4UIcommandTree.cc.

365{
366 std::size_t nlen1 = str1.length();
367 std::size_t nlen2 = str2.length();
368
369 std::size_t nmin = nlen1 < nlen2 ? nlen1 : nlen2;
370
371 G4String strMatched;
372 for (G4int i = 0; i < (G4int)nmin; ++i) {
373 if (str1[i] == str2[i]) {
374 strMatched += str1[i];
375 }
376 else {
377 break;
378 }
379 }
380
381 return strMatched;
382}

Referenced by CompleteCommandPath().

◆ GetGuidance()

const G4UIcommand * G4UIcommandTree::GetGuidance ( ) const
inline

Definition at line 70 of file G4UIcommandTree.hh.

70{ return guidance; }

Referenced by ListCurrent().

◆ GetPathName()

const G4String & G4UIcommandTree::GetPathName ( ) const
inline

◆ GetTitle()

const G4String G4UIcommandTree::GetTitle ( ) const
inline

Definition at line 77 of file G4UIcommandTree.hh.

78 {
79 return (guidance == nullptr) ? G4String("...Title not available...") : guidance->GetTitle();
80 }
const G4String GetTitle() const

◆ GetTree() [1/2]

G4UIcommandTree * G4UIcommandTree::GetTree ( const char * comNameC)

Definition at line 681 of file G4UIcommandTree.cc.

682{
683 G4String comName = comNameC;
684 for (auto& i : tree) {
685 if (comName == i->GetPathName()) {
686 return i;
687 }
688 }
689 return nullptr;
690}

◆ GetTree() [2/2]

◆ GetTreeEntry()

G4int G4UIcommandTree::GetTreeEntry ( ) const
inline

Definition at line 72 of file G4UIcommandTree.hh.

72{ return G4int(tree.size()); }

Referenced by G4UItcsh::CompleteCommand(), CompleteCommandPath(), G4VUIshell::ListCommand(), and G4VBasicShell::TerminalHelp().

◆ List()

void G4UIcommandTree::List ( ) const

Definition at line 444 of file G4UIcommandTree.cc.

445{
446 ListCurrent();
447 std::size_t n_commandEntry = command.size();
448 for (std::size_t i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand) {
449 command[i_thCommand]->List();
450 }
451 std::size_t n_treeEntry = tree.size();
452 for (std::size_t i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree) {
453 tree[i_thTree]->List();
454 }
455}
void ListCurrent() const

Referenced by G4UImanager::ListCommands().

◆ ListCurrent()

void G4UIcommandTree::ListCurrent ( ) const

Definition at line 385 of file G4UIcommandTree.cc.

386{
387 G4cout << "Command directory path : " << pathName << G4endl;
388 if (guidance != nullptr) {
389 guidance->List();
390 }
391 G4cout << " Sub-directories : " << G4endl;
392 std::size_t n_treeEntry = tree.size();
393 for (std::size_t i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree) {
394 G4cout << " " << tree[i_thTree]->GetPathName();
395 if ((tree[i_thTree]->GetGuidance() != nullptr)
396 && tree[i_thTree]->GetGuidance()->IsWorkerThreadOnly())
397 {
398 G4cout << " @ ";
399 }
400 else {
401 G4cout << " ";
402 }
403 G4cout << tree[i_thTree]->GetTitle() << G4endl;
404 }
405 G4cout << " Commands : " << G4endl;
406 std::size_t n_commandEntry = command.size();
407 for (std::size_t i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand) {
408 G4cout << " " << command[i_thCommand]->GetCommandName();
409 if (command[i_thCommand]->IsWorkerThreadOnly()) {
410 G4cout << " @ ";
411 }
412 else {
413 G4cout << " * ";
414 }
415 G4cout << command[i_thCommand]->GetTitle() << G4endl;
416 }
417}
const G4UIcommand * GetGuidance() const
virtual void List()

Referenced by List(), and G4VBasicShell::ListDirectory().

◆ ListCurrentWithNum()

void G4UIcommandTree::ListCurrentWithNum ( ) const

Definition at line 420 of file G4UIcommandTree.cc.

421{
422 G4cout << "Command directory path : " << pathName << G4endl;
423 if (guidance != nullptr) {
424 guidance->List();
425 }
426 G4int i = 0;
427 G4cout << " Sub-directories : " << G4endl;
428 std::size_t n_treeEntry = tree.size();
429 for (std::size_t i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree) {
430 ++i;
431 G4cout << " " << i << ") " << tree[i_thTree]->GetPathName() << " "
432 << tree[i_thTree]->GetTitle() << G4endl;
433 }
434 G4cout << " Commands : " << G4endl;
435 std::size_t n_commandEntry = command.size();
436 for (std::size_t i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand) {
437 ++i;
438 G4cout << " " << i << ") " << command[i_thCommand]->GetCommandName() << " * "
439 << command[i_thCommand]->GetTitle() << G4endl;
440 }
441}

Referenced by G4VBasicShell::TerminalHelp().

◆ operator!=()

G4bool G4UIcommandTree::operator!= ( const G4UIcommandTree & right) const

Definition at line 63 of file G4UIcommandTree.cc.

64{
65 return (pathName != right.GetPathName());
66}

◆ operator==()

G4bool G4UIcommandTree::operator== ( const G4UIcommandTree & right) const

Definition at line 57 of file G4UIcommandTree.cc.

58{
59 return (pathName == right.GetPathName());
60}

◆ RemoveCommand()

void G4UIcommandTree::RemoveCommand ( G4UIcommand * aCommand,
G4bool workerThreadOnly = false )

Definition at line 167 of file G4UIcommandTree.cc.

168{
169 if (workerThreadOnly && !(aCommand->IsWorkerThreadOnly())) {
170 return;
171 }
172 G4String commandPath = aCommand->GetCommandPath();
173 G4String remainingPath = commandPath;
174 remainingPath.erase(0, pathName.length());
175 if (remainingPath.empty()) {
176 guidance = nullptr;
177 }
178 else {
179 std::size_t i = remainingPath.find('/');
180 if (i == std::string::npos) {
181 // Find command
182 std::size_t n_commandEntry = command.size();
183 for (std::size_t i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand) {
184 if (remainingPath == command[i_thCommand]->GetCommandName()) {
185 command.erase(command.begin() + i_thCommand);
186 break;
187 }
188 }
189 }
190 else {
191 // Find path
192 G4String nextPath = pathName;
193 nextPath.append(remainingPath.substr(0, i + 1));
194 std::size_t n_treeEntry = tree.size();
195 for (std::size_t i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree) {
196 if (nextPath == tree[i_thTree]->GetPathName()) {
197 tree[i_thTree]->RemoveCommand(aCommand);
198 G4int n_commandRemain = tree[i_thTree]->GetCommandEntry();
199 G4int n_treeRemain = tree[i_thTree]->GetTreeEntry();
200 if (n_commandRemain == 0 && n_treeRemain == 0) {
201 G4UIcommandTree* emptyTree = tree[i_thTree];
202 tree.erase(tree.begin() + i_thTree);
203 delete emptyTree;
204 }
205 break;
206 }
207 }
208 }
209 }
210}
G4bool IsWorkerThreadOnly() const

Referenced by G4UImanager::RemoveCommand().


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