Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4UIcommandTree Class Reference

#include <G4UIcommandTree.hh>

Public Member Functions

 G4UIcommandTree ()
 
 G4UIcommandTree (const char *thePathName)
 
 ~G4UIcommandTree ()
 
G4int operator== (const G4UIcommandTree &right) const
 
G4int 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 CompleteCommandPath (const G4String &commandPath)
 
void List () const
 
void ListCurrent () const
 
void ListCurrentWithNum () const
 
void CreateHTML ()
 
const G4UIcommandGetGuidance () const
 
const G4String GetPathName () 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::G4UIcommandTree ( )

Definition at line 35 of file G4UIcommandTree.cc.

Referenced by AddNewCommand().

36 :guidance(NULL),broadcastCommands(true)
37 { }
G4UIcommandTree::G4UIcommandTree ( const char *  thePathName)

Definition at line 39 of file G4UIcommandTree.cc.

40 :guidance(NULL),broadcastCommands(true)
41 {
42  pathName = thePathName;
43 }
G4UIcommandTree::~G4UIcommandTree ( )

Definition at line 45 of file G4UIcommandTree.cc.

46 {
47  G4int i;
48  G4int n_treeEntry = tree.size();
49  for( i=0; i < n_treeEntry; i++ )
50  { delete tree[i]; }
51 }
int G4int
Definition: G4Types.hh:78

Member Function Documentation

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

Definition at line 63 of file G4UIcommandTree.cc.

References AddNewCommand(), G4String::append(), G4String::first(), G4UIcommandTree(), G4UIcommand::GetCommandPath(), GetPathName(), G4String::isNull(), G4String::remove(), G4UIcommand::SetToBeBroadcasted(), G4UIcommand::SetWorkerThreadOnly(), and G4UIcommand::ToBeBroadcasted().

Referenced by AddNewCommand(), and G4UImanager::AddNewCommand().

64 {
65  G4String commandPath = newCommand->GetCommandPath();
66  G4String remainingPath = commandPath;
67  remainingPath.remove(0,pathName.length());
68  if( remainingPath.isNull() )
69  {
70  if(!guidance)
71  {
72  guidance = newCommand;
73  if(!(newCommand->ToBeBroadcasted())) broadcastCommands = false;
74  if(workerThreadOnly) newCommand->SetWorkerThreadOnly();
75  }
76  return;
77  }
78  G4int i = remainingPath.first('/');
79  if( i == G4int(std::string::npos) )
80  {
81  // Find command
82  G4int n_commandEntry = command.size();
83  for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
84  {
85  if( remainingPath == command[i_thCommand]->GetCommandName() )
86  { return; }
87  }
88  if(!broadcastCommands) newCommand->SetToBeBroadcasted(false);
89  if(workerThreadOnly) newCommand->SetWorkerThreadOnly();
90  command.push_back( newCommand );
91  return;
92  }
93  else
94  {
95  // Find path
96  G4String nextPath = pathName;
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++ )
100  {
101  if( nextPath == tree[i_thTree]->GetPathName() )
102  {
103  if(!broadcastCommands) newCommand->SetToBeBroadcasted(false);
104  tree[i_thTree]->AddNewCommand( newCommand, workerThreadOnly );
105  return;
106  }
107  }
108  G4UIcommandTree * newTree = new G4UIcommandTree( nextPath );
109  tree.push_back( newTree );
110  if(!broadcastCommands) newCommand->SetToBeBroadcasted(false);
111  newTree->AddNewCommand( newCommand, workerThreadOnly );
112  return;
113  }
114 }
G4String & remove(str_size)
G4int first(char) const
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:184
int G4int
Definition: G4Types.hh:78
G4bool ToBeBroadcasted() const
Definition: G4UIcommand.hh:186
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:139
const G4String GetPathName() const
void SetWorkerThreadOnly(G4bool val=true)
Definition: G4UIcommand.hh:192
void AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly=false)
G4String & append(const G4String &)
G4bool isNull() const
G4String G4UIcommandTree::CompleteCommandPath ( const G4String commandPath)

Definition at line 237 of file G4UIcommandTree.cc.

References FindCommandTree(), G4cout, G4endl, GetCommand(), GetCommandEntry(), GetPathName(), GetTree(), GetTreeEntry(), G4String::index(), G4String::last(), and G4String::remove().

238 {
239  G4String pName = aCommandPath;
240  G4String remainingPath = aCommandPath;
241  G4String empty = "";
242  G4String matchingPath = empty;
243 
244  // find the tree
245  G4int jpre= pName.last('/');
246  if(jpre != G4int(G4String::npos)) pName.remove(jpre+1);
247  G4UIcommandTree* aTree = FindCommandTree(pName);
248 
249  if (!aTree) {
250  return empty;
251  }
252 
253  if( pName.index( pName ) == std::string::npos ) return empty;
254 
255  std::vector<G4String> paths;
256 
257  // list matched directories/commands
258  G4String strtmp;
259  G4int nMatch= 0;
260 
261  int Ndir= aTree-> GetTreeEntry();
262  int Ncmd= aTree-> GetCommandEntry();
263 
264  // directory ...
265  for(G4int idir=1; idir<=Ndir; idir++) {
266  G4String fpdir= aTree-> GetTree(idir)-> GetPathName();
267  // matching test
268  if( fpdir.index(remainingPath, 0) == 0) {
269  if(nMatch==0) {
270  matchingPath = fpdir;
271  } else {
272  matchingPath = GetFirstMatchedString(fpdir,matchingPath);
273  }
274  nMatch++;
275  paths.push_back(fpdir);
276  }
277  }
278 
279  if (paths.size()>=2) {
280  G4cout << "Matching directories :" << G4endl;
281  for( unsigned int i_thCommand = 0; i_thCommand < paths.size(); i_thCommand++ ) {
282  G4cout << paths[i_thCommand] << G4endl;
283  }
284  }
285 
286  // command ...
287  std::vector<G4String> commands;
288 
289  for(G4int icmd=1; icmd<=Ncmd; icmd++){
290  G4String fpcmd= aTree-> GetPathName() +
291  aTree-> GetCommand(icmd) -> GetCommandName();
292  // matching test
293  if( fpcmd.index(remainingPath, 0) ==0) {
294  if(nMatch==0) {
295  matchingPath= fpcmd + " ";
296  } else {
297  strtmp= fpcmd + " ";
298  matchingPath= GetFirstMatchedString(matchingPath, strtmp);
299  }
300  nMatch++;
301  commands.push_back(fpcmd+" ");
302  }
303  }
304 
305  if (commands.size()>=2) {
306  G4cout << "Matching commands :" << G4endl;
307  for( unsigned int i_thCommand = 0; i_thCommand < commands.size(); i_thCommand++ ) {
308  G4cout << commands[i_thCommand] << G4endl;
309  }
310  }
311 
312  return matchingPath;
313 }
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4String & remove(str_size)
G4int GetCommandEntry() const
G4UIcommand * GetCommand(G4int i)
G4int GetTreeEntry() const
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4UIcommandTree * GetTree(G4int i)
const G4String GetPathName() const
G4int last(char) const
#define G4endl
Definition: G4ios.hh:61
void G4UIcommandTree::CreateHTML ( )

Definition at line 437 of file G4UIcommandTree.cc.

References cmd, G4endl, G4UIcommand::GetCommandName(), G4UIparameter::GetCurrentAsDefault(), G4UIparameter::GetDefaultValue(), G4UIcommand::GetGuidanceEntries(), G4UIcommand::GetGuidanceLine(), G4UIcommand::GetParameter(), G4UIparameter::GetParameterCandidates(), G4UIcommand::GetParameterEntries(), G4UIparameter::GetParameterName(), G4UIparameter::GetParameterRange(), G4UIparameter::GetParameterType(), GetPathName(), G4UIcommand::GetRange(), G4UIcommand::GetStateList(), G4StateManager::GetStateManager(), G4StateManager::GetStateString(), GetTitle(), and G4UIparameter::IsOmittable().

Referenced by G4UImanager::CreateHTML(), and export_G4UIcommandTree().

438 {
439  G4String ofileName = CreateFileName(pathName);
440  std::ofstream oF(ofileName, std::ios::out);
441 
442  oF << "<html><head><title>Commands in " << ModStr(pathName) << "</title></head>" << G4endl;
443  oF << "<body bgcolor=\"#ffffff\"><h2>" << ModStr(pathName) << "</h2><p>" << G4endl;
444 
445  if( guidance != NULL )
446  {
447  for(G4int i=0;i<guidance->GetGuidanceEntries();i++)
448  { oF << ModStr(guidance->GetGuidanceLine(i)) << "<br>" << G4endl; }
449  }
450 
451  oF << "<p><hr><p>" << G4endl;
452 
453  oF << "<h2>Sub-directories : </h2><dl>" << G4endl;
454  for( G4int i_thTree = 0; i_thTree < G4int(tree.size()); i_thTree++ )
455  {
456  oF << "<p><br><p><dt><a href=\"" << CreateFileName(tree[i_thTree]->GetPathName())
457  << "\">" << ModStr(tree[i_thTree]->GetPathName()) << "</a>" << G4endl;
458  oF << "<p><dd>" << ModStr(tree[i_thTree]->GetTitle()) << G4endl;
459  tree[i_thTree]->CreateHTML();
460  }
461 
462  oF << "</dl><p><hr><p>" << G4endl;
463 
464  oF << "<h2>Commands : </h2><dl>" << G4endl;
465  for( G4int i_thCommand = 0; i_thCommand < G4int(command.size()); i_thCommand++ )
466  {
467  G4UIcommand* cmd = command[i_thCommand];
468  oF << "<p><br><p><dt><b>" << ModStr(cmd->GetCommandName());
469  if(cmd->GetParameterEntries()>0)
470  {
471  for(G4int i_thParam=0;i_thParam<cmd->GetParameterEntries();i_thParam++)
472  { oF << " [<i>" << ModStr(cmd->GetParameter(i_thParam)->GetParameterName()) << "</i>]"; }
473  }
474  oF << "</b>" << G4endl;
475  oF << "<p><dd>" << G4endl;
476  for(G4int i=0;i<cmd->GetGuidanceEntries();i++)
477  { oF << ModStr(cmd->GetGuidanceLine(i)) << "<br>" << G4endl; }
478  if(!(cmd->GetRange()).isNull())
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; }
483  else
484  {
485  oF << "<p><dd>Available Geant4 state(s) : ";
486  for(G4int ias=0;ias<G4int(availabelStateList->size());ias++)
487  { oF << G4StateManager::GetStateManager()->GetStateString((*availabelStateList)[ias]) << " " << G4endl; }
488  }
489  if(cmd->GetParameterEntries()>0)
490  {
491  oF << "<p><dd>Parameters<table border=1>" << G4endl;
492  for(G4int i_thParam=0;i_thParam<cmd->GetParameterEntries();i_thParam++)
493  {
494  G4UIparameter* prm = cmd->GetParameter(i_thParam);
495  oF << "<tr><td>" << ModStr(prm->GetParameterName()) << G4endl;
496  oF << "<td>type " << prm->GetParameterType() << G4endl;
497  oF << "<td>";
498  if(prm->IsOmittable())
499  {
500  oF << "Omittable : ";
501  if(prm->GetCurrentAsDefault())
502  { oF << "current value is used as the default value." << G4endl; }
503  else
504  { oF << "default value = " << prm->GetDefaultValue() << G4endl; }
505  }
506  oF << "<td>";
507  if(!(prm->GetParameterRange()).isNull())
508  { oF << "Parameter range : " << ModStr(prm->GetParameterRange()) << G4endl; }
509  else if(!(prm->GetParameterCandidates()).isNull())
510  { oF << "Parameter candidates : " << ModStr(prm->GetParameterCandidates()) << G4endl; }
511  }
512  oF << "</table>" << G4endl;
513  }
514 
515  }
516 
517  oF << "</dl></body></html>" << G4endl;
518  oF.close();
519 }
G4String GetParameterCandidates() const
char cmd[1024]
Definition: tracer.cxx:25
const G4String & GetRange() const
Definition: G4UIcommand.hh:133
G4String GetParameterName() const
int G4int
Definition: G4Types.hh:78
const G4String & GetGuidanceLine(G4int i) const
Definition: G4UIcommand.hh:137
G4bool IsOmittable() const
static G4StateManager * GetStateManager()
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
const G4String GetPathName() const
const G4String & GetCommandName() const
Definition: G4UIcommand.hh:141
const G4String GetTitle() const
G4String GetDefaultValue() const
std::vector< G4ApplicationState > * GetStateList()
Definition: G4UIcommand.hh:147
char GetParameterType() const
#define G4endl
Definition: G4ios.hh:61
G4String GetParameterRange() const
G4int GetGuidanceEntries() const
Definition: G4UIcommand.hh:135
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
G4bool GetCurrentAsDefault() const
G4String GetStateString(G4ApplicationState aState) const
G4UIcommandTree * G4UIcommandTree::FindCommandTree ( const char *  commandPath)

Try to match a command or a path with the one given. : command or path to match

Returns
the commandTree found or NULL if not

Definition at line 209 of file G4UIcommandTree.cc.

References G4String::append(), G4String::first(), GetPathName(), G4String::index(), and G4String::remove().

Referenced by CompleteCommandPath().

210 {
211  G4String remainingPath = commandPath;
212  if( remainingPath.index( pathName ) == std::string::npos )
213  { return NULL; }
214  remainingPath.remove(0,pathName.length());
215  G4int i = remainingPath.first('/');
216  if( i != G4int(std::string::npos) )
217  {
218  // Find path
219  G4String nextPath = pathName;
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++ )
223  {
224  if (tree[i_thTree]->GetPathName() == commandPath) {
225  return tree[i_thTree];
226  }
227  else if( nextPath == tree[i_thTree]->GetPathName() ) {
228  return tree[i_thTree]->FindCommandTree( commandPath );
229  }
230  }
231  } else {
232  return this;
233  }
234  return NULL;
235 }
G4String & remove(str_size)
G4int first(char) const
int G4int
Definition: G4Types.hh:78
str_size index(const char *, G4int pos=0) const
const G4String GetPathName() const
G4String & append(const G4String &)
G4UIcommand * G4UIcommandTree::FindPath ( const char *  commandPath) const

Definition at line 171 of file G4UIcommandTree.cc.

References G4String::append(), G4String::first(), GetPathName(), G4String::index(), and G4String::remove().

Referenced by G4UImanager::ApplyCommand(), G4CascadeParamMessenger::CreateDirectory(), export_G4UIcommandTree(), G4VBasicShell::FindCommand(), G4UImanager::GetCurrentValues(), and G4VBasicShell::TerminalHelp().

172 {
173  G4String remainingPath = commandPath;
174  if( remainingPath.index( pathName ) == std::string::npos )
175  { return NULL; }
176  remainingPath.remove(0,pathName.length());
177  G4int i = remainingPath.first('/');
178  if( i == G4int(std::string::npos) )
179  {
180  // Find command
181  G4int n_commandEntry = command.size();
182  for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
183  {
184  if( remainingPath == command[i_thCommand]->GetCommandName() )
185  { return command[i_thCommand]; }
186  }
187  }
188  else
189  {
190  // Find path
191  G4String nextPath = pathName;
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++ )
195  {
196  if( nextPath == tree[i_thTree]->GetPathName() )
197  { return tree[i_thTree]->FindPath( commandPath ); }
198  }
199  }
200  return NULL;
201 }
G4String & remove(str_size)
G4int first(char) const
int G4int
Definition: G4Types.hh:78
str_size index(const char *, G4int pos=0) const
const G4String GetPathName() const
G4String & append(const G4String &)
G4UIcommand* G4UIcommandTree::GetCommand ( G4int  i)
inline

Definition at line 99 of file G4UIcommandTree.hh.

Referenced by CompleteCommandPath(), export_G4UIcommandTree(), and G4VBasicShell::TerminalHelp().

100  { return command[i-1]; };
G4int G4UIcommandTree::GetCommandEntry ( ) const
inline

Definition at line 85 of file G4UIcommandTree.hh.

Referenced by CompleteCommandPath(), and export_G4UIcommandTree().

86  { return command.size(); };
const G4UIcommand* G4UIcommandTree::GetGuidance ( ) const
inline

Definition at line 79 of file G4UIcommandTree.hh.

Referenced by export_G4UIcommandTree(), and ListCurrent().

80  { return guidance; };
const G4String G4UIcommandTree::GetPathName ( ) const
inline
const G4String G4UIcommandTree::GetTitle ( ) const
inline

Definition at line 101 of file G4UIcommandTree.hh.

References G4UIcommand::GetTitle().

Referenced by CreateHTML(), and export_G4UIcommandTree().

102  {
103  if(guidance==NULL)
104  { return G4String("...Title not available..."); }
105  else
106  { return guidance->GetTitle(); }
107  };
const G4String GetTitle() const
Definition: G4UIcommand.hh:170
G4UIcommandTree* G4UIcommandTree::GetTree ( G4int  i)
inline

Definition at line 87 of file G4UIcommandTree.hh.

Referenced by CompleteCommandPath(), G4VBasicShell::FindDirectory(), and G4VBasicShell::TerminalHelp().

88  { return tree[i-1]; };
G4UIcommandTree* G4UIcommandTree::GetTree ( const char *  comNameC)
inline

Definition at line 89 of file G4UIcommandTree.hh.

References GetPathName().

90  {
91  G4String comName = comNameC;
92  for( size_t i=0; i < tree.size(); i++)
93  {
94  if( comName == tree[i]->GetPathName() )
95  { return tree[i]; }
96  }
97  return NULL;
98  };
const G4String GetPathName() const
G4int G4UIcommandTree::GetTreeEntry ( ) const
inline

Definition at line 83 of file G4UIcommandTree.hh.

Referenced by CompleteCommandPath(), export_G4UIcommandTree(), RemoveCommand(), and G4VBasicShell::TerminalHelp().

84  { return tree.size(); };
void G4UIcommandTree::List ( ) const

Definition at line 390 of file G4UIcommandTree.cc.

References ListCurrent().

Referenced by export_G4UIcommandTree(), and G4UImanager::ListCommands().

391 {
392  ListCurrent();
393  G4int n_commandEntry = command.size();
394  for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
395  {
396  command[i_thCommand]->List();
397  }
398  G4int n_treeEntry = tree.size();
399  for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
400  {
401  tree[i_thTree]->List();
402  }
403 }
int G4int
Definition: G4Types.hh:78
void ListCurrent() const
void G4UIcommandTree::ListCurrent ( ) const

Definition at line 338 of file G4UIcommandTree.cc.

References G4cout, G4endl, GetGuidance(), and G4UIcommand::List().

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

339 {
340  G4cout << "Command directory path : " << pathName << G4endl;
341  if( guidance != NULL ) guidance->List();
342  G4cout << " Sub-directories : " << G4endl;
343  G4int n_treeEntry = tree.size();
344  for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
345  {
346  G4cout << " " << tree[i_thTree]->GetPathName();
347  if(tree[i_thTree]->GetGuidance() &&
348  tree[i_thTree]->GetGuidance()->IsWorkerThreadOnly())
349  { G4cout << " @ "; }
350  else
351  { G4cout << " "; }
352  G4cout << tree[i_thTree]->GetTitle() << G4endl;
353  }
354  G4cout << " Commands : " << G4endl;
355  G4int n_commandEntry = command.size();
356  for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
357  {
358  G4cout << " " << command[i_thCommand]->GetCommandName();
359  if(command[i_thCommand]->IsWorkerThreadOnly())
360  { G4cout << " @ "; }
361  else
362  { G4cout << " * "; }
363  G4cout << command[i_thCommand]->GetTitle() << G4endl;
364  }
365 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
const G4UIcommand * GetGuidance() const
#define G4endl
Definition: G4ios.hh:61
virtual void List()
Definition: G4UIcommand.cc:334
void G4UIcommandTree::ListCurrentWithNum ( ) const

Definition at line 367 of file G4UIcommandTree.cc.

References G4cout, G4endl, and G4UIcommand::List().

Referenced by export_G4UIcommandTree(), and G4VBasicShell::TerminalHelp().

368 {
369  G4cout << "Command directory path : " << pathName << G4endl;
370  if( guidance != NULL ) guidance->List();
371  G4int i = 0;
372  G4cout << " Sub-directories : " << G4endl;
373  G4int n_treeEntry = tree.size();
374  for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
375  {
376  i++;
377  G4cout << " " << i << ") " << tree[i_thTree]->GetPathName()
378  << " " << tree[i_thTree]->GetTitle() << G4endl;
379  }
380  G4cout << " Commands : " << G4endl;
381  G4int n_commandEntry = command.size();
382  for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
383  {
384  i++;
385  G4cout << " " << i << ") " << command[i_thCommand]->GetCommandName()
386  << " * " << command[i_thCommand]->GetTitle() << G4endl;
387  }
388 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
virtual void List()
Definition: G4UIcommand.cc:334
G4int G4UIcommandTree::operator!= ( const G4UIcommandTree right) const

Definition at line 58 of file G4UIcommandTree.cc.

References GetPathName().

59 {
60  return ( pathName != right.GetPathName() );
61 }
const G4String GetPathName() const
G4int G4UIcommandTree::operator== ( const G4UIcommandTree right) const

Definition at line 53 of file G4UIcommandTree.cc.

References GetPathName().

54 {
55  return ( pathName == right.GetPathName() );
56 }
const G4String GetPathName() const
void G4UIcommandTree::RemoveCommand ( G4UIcommand aCommand,
G4bool  workerThreadOnly = false 
)

Definition at line 116 of file G4UIcommandTree.cc.

References G4String::append(), G4String::first(), G4UIcommand::GetCommandPath(), GetPathName(), GetTreeEntry(), G4String::isNull(), G4UIcommand::IsWorkerThreadOnly(), and G4String::remove().

Referenced by G4UImanager::RemoveCommand().

117 {
118  if(workerThreadOnly && !(aCommand->IsWorkerThreadOnly())) return;
119  G4String commandPath = aCommand->GetCommandPath();
120  G4String remainingPath = commandPath;
121  remainingPath.remove(0,pathName.length());
122  if( remainingPath.isNull() )
123  {
124  guidance = NULL;
125  }
126  else
127  {
128  G4int i = remainingPath.first('/');
129  if( i == G4int(std::string::npos) )
130  {
131  // Find command
132  G4int n_commandEntry = command.size();
133  for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
134  {
135  if( remainingPath == command[i_thCommand]->GetCommandName() )
136  {
137  command.erase(command.begin()+i_thCommand);
138  break;
139  }
140  }
141  }
142  else
143  {
144  // Find path
145  G4String nextPath = pathName;
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++ )
149  {
150  if( nextPath == tree[i_thTree]->GetPathName() )
151  {
152  tree[i_thTree]->RemoveCommand( aCommand );
153  G4int n_commandRemain = tree[i_thTree]->GetCommandEntry();
154  G4int n_treeRemain = tree[i_thTree]-> GetTreeEntry();
155  if(n_commandRemain == 0 && n_treeRemain == 0)
156  {
157  G4UIcommandTree * emptyTree = tree[i_thTree];
158  tree.erase(tree.begin()+i_thTree);
159  delete emptyTree;
160  }
161  break;
162  }
163  }
164  }
165  }
166 }
G4bool IsWorkerThreadOnly() const
Definition: G4UIcommand.hh:194
G4String & remove(str_size)
G4int first(char) const
G4int GetTreeEntry() const
int G4int
Definition: G4Types.hh:78
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:139
const G4String GetPathName() const
G4String & append(const G4String &)
G4bool isNull() const

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