Ignore:
Timestamp:
May 6, 2009, 5:55:22 PM (15 years ago)
Author:
garnier
Message:

en test before cvs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/interfaces/common/src/G4VBasicShell.cc

    r1027 r1032  
    180180  return value;
    181181}
    182 
    183 
    184 
    185 
    186182G4String G4VBasicShell::FindMatchingPath(
    187183 G4UIcommandTree* aTree
    188184,G4String aCommandPath
    189185)
    190 // From intercoms/src/G4UIcommandTree::FindPath.
    191186{
    192187  return aTree->CompleteCommandPath(aCommandPath);
    193 
    194 #ifdef G4DEBUG
    195   printf("G4VBasicShell::FindMatchingPath %s\n",aCommandPath.c_str());
    196 #endif
    197   G4String empty = "";
    198   if(aTree==NULL) return empty;
    199   G4String pathName = aTree->GetPathName();
    200   if( aCommandPath.index( pathName ) == std::string::npos ) return empty;
    201   G4String remainingPath = aCommandPath;
    202   remainingPath.remove(0,pathName.length());
    203   size_t i = remainingPath.first('/');
    204 #ifdef G4DEBUG
    205   printf("G4VBasicShell::FindMatchingPath remainingPath:%s\n",remainingPath.c_str());
    206 #endif
    207   if( i == std::string::npos ) {
    208 #ifdef G4DEBUG
    209   printf("G4VBasicShell::FindMatchingPath npos \n");
    210 #endif
    211     // Look for number of matching commands :
    212     std::vector<G4UIcommand*> commands;
    213     G4int n_commandEntry = aTree->GetCommandEntry();
    214     for( G4int i_thCommand = 1; i_thCommand <= n_commandEntry; i_thCommand++ ) {
    215       G4UIcommand* cmd = aTree->GetCommand(i_thCommand);
    216       G4String ss = cmd->GetCommandName();
    217       ss.resize(remainingPath.length());
    218       if( remainingPath == ss ) commands.push_back(cmd);
    219 #ifdef G4DEBUG
    220       printf("look for command check %s %s \n",ss.c_str(),remainingPath.c_str());
    221 #endif
    222     }
    223     n_commandEntry = commands.size();
    224 #ifdef G4DEBUG
    225       printf("%d found\n",n_commandEntry);
    226 #endif
    227     if(n_commandEntry==1) {
    228       return (pathName + commands[0]->GetCommandName());
    229     } else if (n_commandEntry>=2) {
    230       G4cout << "Matching commands :" << G4endl;
    231       for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ ) {
    232         G4UIcommand* cmd = commands[i_thCommand];
    233         G4cout << cmd->GetCommandName() << G4endl;
    234 #ifdef G4DEBUG
    235         printf("%s found\n",cmd->GetCommandName().c_str());
    236 #endif
    237       }
    238       return empty;
    239     }
    240     // Look for sub tree :
    241     std::vector<G4UIcommandTree*> trees;
    242     G4String nextPath = pathName;
    243     nextPath.append(remainingPath);
    244     G4int n_treeEntry = aTree->GetTreeEntry();
    245     for( G4int i_thTree = 1; i_thTree <= n_treeEntry; i_thTree++ ) {
    246       G4UIcommandTree* tree = aTree->GetTree(i_thTree);
    247       G4String ss = tree->GetPathName();
    248       ss.resize(nextPath.length());
    249       if( nextPath == ss ) trees.push_back(tree);
    250     }
    251     n_treeEntry = trees.size();
    252     if(n_treeEntry==1) {
    253       return trees[0]->GetPathName();
    254     } else if (n_treeEntry>=2) {
    255       G4cout << "Matching directories :" << G4endl;
    256       for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ ) {
    257         G4UIcommandTree* tree = trees[i_thTree];
    258         G4cout << tree->GetPathName() << G4endl;
    259       }
    260       return empty;
    261     } else {
    262       return empty; // No match.
    263     }
    264   } else {
    265     // Find path
    266     G4String nextPath = pathName;
    267     nextPath.append(remainingPath(0,i+1));
    268     G4int n_treeEntry = aTree->GetTreeEntry();
    269 #ifdef G4DEBUG
    270     printf(" find PATH\n");
    271 #endif
    272     for( G4int i_thTree = 1; i_thTree <= n_treeEntry; i_thTree++ ) {
    273       G4UIcommandTree* tree = aTree->GetTree(i_thTree);
    274 #ifdef G4DEBUG
    275       printf("++++LOOP+++++++++++++%s == %s \n",nextPath.c_str(), tree->GetPathName().c_str());
    276 #endif
    277       if( nextPath == tree->GetPathName() ) {
    278         return FindMatchingPath(tree,aCommandPath );
    279       }
    280     }
    281   }
    282   return empty;
    283188}
    284189////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.