Skip to content

Commit

Permalink
Add -v (version) option
Browse files Browse the repository at this point in the history
  • Loading branch information
dsarrut committed Jul 19, 2013
1 parent 0f96725 commit 0041e23
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions Gate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,24 @@
#include "G4UIExecutive.hh"
#endif

//-----------------------------------------------------------------------------
void printHelpAndQuit( G4String msg )
{
GateMessage( "Core", 0, msg << G4endl );
GateMessage( "Core", 0, "Usage: Gate [OPTION]... MACRO_FILE" << G4endl );
GateMessage( "Core", 0, G4endl);
GateMessage( "Core", 0, "Mandatory arguments to long options are mandatory for short options too." << G4endl );
GateMessage( "Core", 0, " -h, --help print the help" << G4endl );
GateMessage( "Core", 0, " -v, --version print the version" << G4endl );
GateMessage( "Core", 0, " -a, --param set alias. format is '[alias1,value1] [alias2,value2] ...'" << G4endl );
GateMessage( "Core", 0, " --d use the DigiMode" << G4endl );
GateMessage( "Core", 0, " --qt use the Qt visualization mode" << G4endl );
exit( EXIT_FAILURE );
}
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
std::queue < G4String > decodeParameters( G4String listOfParameters )
{
// Command queue storing the '/control/alias ALIAS VALUE' command line
Expand Down Expand Up @@ -94,7 +99,10 @@ std::queue < G4String > decodeParameters( G4String listOfParameters )

return commandQueue;
}
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
#ifndef G4ANALYSIS_USE_ROOT
void abortIfRootNotFound()
{
Expand All @@ -118,7 +126,10 @@ void abortIfRootNotFound()
G4Exception( "Gate.cc AbortIfRootNotFound", "AbortIfRootNotFound", FatalException, "Correct problem then try again... Sorry!" );
}
#endif
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
void executeCommandQueue( std::queue< G4String > commandQueue, G4UImanager* UImanager )
{
while( commandQueue.size() )
Expand All @@ -128,23 +139,29 @@ void executeCommandQueue( std::queue< G4String > commandQueue, G4UImanager* UIma
commandQueue.pop();
}
}
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
void welcome()
{
GateMessage( "Core", 0, G4endl );
GateMessage( "Core", 0, "**********************************************************************" << G4endl );
GateMessage( "Core", 0, " GATE version name: gate_v6.2 " << G4endl );
GateMessage( "Core", 0, " Copyright : OpenGATE Collaboration " << G4endl );
GateMessage( "Core", 0, " Reference : Phys. Med. Biol. 49 (2004) 4543-4561 " << G4endl );
GateMessage( "Core", 0, " Reference : Phys. Med. Biol. 56 (2011) 881-901 " << G4endl );
GateMessage( "Core", 0, " WWW : http://www.opengatecollaboration.org " << G4endl );
GateMessage( "Core", 0, "**********************************************************************" << G4endl );
GateMessage("Core", 0, G4endl);
GateMessage("Core", 0, "**********************************************************************" << G4endl);
GateMessage("Core", 0, " GATE version name: beta_gate_v7.0 " << G4endl);
GateMessage("Core", 0, " Copyright : OpenGATE Collaboration " << G4endl);
GateMessage("Core", 0, " Reference : Phys. Med. Biol. 49 (2004) 4543-4561 " << G4endl);
GateMessage("Core", 0, " Reference : Phys. Med. Biol. 56 (2011) 881-901 " << G4endl);
GateMessage("Core", 0, " WWW : http://www.opengatecollaboration.org " << G4endl);
GateMessage("Core", 0, "**********************************************************************" << G4endl);
#ifdef GATE_USE_GPU
GateMessage( "Core", 0, "GPU support activated" << G4endl );
GateMessage("Core", 0, "GPU support activated" << G4endl );
#endif
GateMessage( "Core", 0, G4endl );
GateMessage("Core", 0, G4endl);
}
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
// First of all, set the G4cout to our message manager
Expand Down Expand Up @@ -180,13 +197,14 @@ int main( int argc, char* argv[] )
G4int optionIndex = 0;
static struct option longOptions[] = {
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'v' },
{ "d", no_argument, &isDigiMode, 1 },
{ "qt", no_argument, &isQt, 1 },
{ "param", required_argument, 0, 'a' }
};

// Getting the option
c = getopt_long( argc, argv, "ha:", longOptions, &optionIndex );
c = getopt_long( argc, argv, "hva:", longOptions, &optionIndex );

// Exit the loop if -1
if( c == -1 ) break;
Expand All @@ -199,7 +217,11 @@ int main( int argc, char* argv[] )
if( longOptions[ optionIndex ].flag != 0 ) break;
break;
case 'h':
printHelpAndQuit( "Printing help!!!" );
printHelpAndQuit("Gate command line help" );
break;
case 'v':
std::cout << "Gate version is pre-7.0 (beta)" << std::endl;
exit(0);
break;
case 'a':
listOfParameters = optarg;
Expand Down Expand Up @@ -368,3 +390,4 @@ int main( int argc, char* argv[] )

return 0;
}
//-----------------------------------------------------------------------------

0 comments on commit 0041e23

Please sign in to comment.