BLCMDdemo Class Reference

Inheritance diagram for BLCMDdemo:

BLCommand

List of all members.

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


Constructor & Destructor Documentation

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 }


Member Function Documentation

G4String BLCMDdemo::commandName (  )  [inline, virtual]

Implements BLCommand.

00034 { return "demo"; }

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]

References d1, d2, s1, and s2.

Referenced by command().

00040                        { printf("s1='%s' s2='%s' d1=%g d2=%g\n",
00041                                 s1.c_str(),s2.c_str(),d1,d2); }


Member Data Documentation

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().


The documentation for this class was generated from the following file:
g4beamline