MCPcopy Create free account
hub / github.com/Geant4/geant4 / RemoveCommand

Method RemoveCommand

source/intercoms/src/G4UIcommandTree.cc:167–209  ·  view source on GitHub ↗

--------------------------------------------------------------------

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

IsWorkerThreadOnlyMethod · 0.80
substrMethod · 0.80
GetCommandEntryMethod · 0.80
GetTreeEntryMethod · 0.80
lengthMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected