Public Member Functions | |
BLCMDdemo () | |
G4String | commandName () |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
void | defineNamedArgs () |
void | display () |
Private Attributes | |
G4String | s1 |
G4String | s2 |
G4double | d1 |
G4double | d2 |
BLCMDdemo::BLCMDdemo | ( | ) |
References BLCMDTYPE_OTHER, BLCommand::registerCommand(), BLCommand::setDescription(), and BLCommand::setSynopsis().
Referenced by command().
00048 { 00049 registerCommand(BLCMDTYPE_OTHER); 00050 setSynopsis("demo command."); 00051 setDescription("This demo command takes both positional and named args,\n" 00052 "and is the prototype class for all commands.\n" 00053 "All argument values are merely displayed.\n" 00054 "'demo default name=value...' sets default values."); 00055 }
G4String BLCMDdemo::commandName | ( | ) | [inline, virtual] |
int BLCMDdemo::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
Implements BLCommand.
References BLCMDdemo(), display(), BLCommand::handleNamedArgs(), BLTime::sleepms(), and BLTime::time().
00058 { 00059 // handle setting default argument values 00060 if(argv.size() > 0 && argv[0] == "default") { 00061 handleNamedArgs(namedArgs); 00062 return 0; 00063 } 00064 00065 // test the time() function (problem on Windows?) 00066 if(argv.size() > 0 && argv[0] == "time") { 00067 time_t start = BLTime::time(); 00068 for(;;) { 00069 BLTime::sleepms(200); 00070 printf("time=%ld\r",BLTime::time()-start); 00071 fflush(stdout); 00072 } 00073 } 00074 00075 BLCMDdemo *p = new BLCMDdemo(defaultDemoCommand); 00076 p->handleNamedArgs(namedArgs); 00077 for(unsigned int i=0; i<argv.size(); ++i) 00078 printf("arg%d='%s' ",i,argv[i].c_str()); 00079 p->display(); 00080 delete p; 00081 00082 G4NistManager *m = G4NistManager::Instance(); 00083 const std::vector<G4String> *v=&m->GetNistMaterialNames(); 00084 for(unsigned i=0; i<v->size(); ++i) 00085 printf("%s\n",(*v)[i].c_str()); 00086 00087 m->FindOrBuildMaterial("G4_lH2"); 00088 m->FindOrBuildMaterial("G4_Be"); 00089 m->FindOrBuildMaterial("G4_Al"); 00090 m->FindOrBuildMaterial("G4_Fe"); 00091 m->FindOrBuildMaterial("G4_Cu"); 00092 m->FindOrBuildMaterial("G4_W"); 00093 m->FindOrBuildMaterial("G4_Pb"); 00094 m->FindOrBuildMaterial("G4_AIR"); 00095 m->FindOrBuildMaterial("G4_Galactic"); 00096 m->FindOrBuildMaterial("G4_WATER"); 00097 00098 return 0; 00099 }
void BLCMDdemo::defineNamedArgs | ( | ) | [virtual] |
Reimplemented from BLCommand.
References BLCommand::argDouble(), BLCommand::argString(), d1, d2, s1, and s2.
00102 { 00103 argString(s1,"s1","a demo string argument."); 00104 argString(s2,"s2","a demo string argument."); 00105 argDouble(d1,"d1","a demo double argument."); 00106 argDouble(d2,"d2","a demo double argument."); 00107 }
void BLCMDdemo::display | ( | ) | [inline] |
G4String BLCMDdemo::s1 [private] |
Referenced by defineNamedArgs(), and display().
G4String BLCMDdemo::s2 [private] |
Referenced by defineNamedArgs(), and display().
G4double BLCMDdemo::d1 [private] |
Referenced by defineNamedArgs(), and display().
G4double BLCMDdemo::d2 [private] |
Referenced by defineNamedArgs(), and display().