00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <iostream>
00021 #include <string>
00022
00023 #include "anyoption.h"
00024
00025
00026 #include <QApplication>
00027
00028
00029 #include "MainWindow.h"
00030 #include "ThreadManager.h"
00031
00032
00033 #include "../doc/referenceManual/mainPage.h"
00034
00035 using namespace std;
00036
00037 int main(int argc, char *argv[]){
00038
00039 cout << endl;
00040 cout << "*******************************************************************" << endl;
00041 cout << "*** !! Welcome to RegMAS - Regional Multi Agent Simulator !! ***" << endl;
00042 cout << "*** For info & doc: http://www.regmas.org/doc ***" << endl;
00043 cout << "*** Compiled on: " << __DATE__ << " - " << __TIME__ << " ***" << endl;
00044 cout << "*******************************************************************" << endl<<endl;
00045
00046 QDir dir;
00047 QString currentDir = dir.currentPath();
00048 QString inputFileName = "";
00049 QString scenarioName = "";
00050
00051
00052 AnyOption *opt = new AnyOption();
00053
00054
00055
00056
00057
00058
00059 opt->addUsage( "*** RegMAS - Regional Multi Agent Simulator ***" );
00060 opt->addUsage( "Usage: " );
00061 opt->addUsage( "" );
00062 opt->addUsage( " -h --help Prints this help " );
00063 opt->addUsage( " -c --console Run in console mode (no gui, default: false) " );
00064 opt->addUsage( " -i --input_file [input_file_name] Input file (relative path, default: 'data/regmasInput.ods') " );
00065 opt->addUsage( " -s --scenario [scenario_name] Scenario name (default: the first defined in the input file) " );
00066 opt->addUsage( "" );
00067 opt->addUsage( "Notes:");
00068 opt->addUsage( " - input_file and scenario options have no effect in GUI mode;" );
00069 opt->addUsage( " - the working directory is the base path relative to the input file." );
00070 opt->addUsage( "" );
00071 opt->addUsage( "Read installed documentation or browse it at http://www.regmas.org/doc." );
00072 opt->addUsage( "" );
00073
00074
00075 opt->setFlag( "help", 'h' );
00076 opt->setFlag( "console", 'c' );
00077 opt->setOption( "input_file", 'i' );
00078 opt->setOption( "scenario", 's' );
00079
00080
00081 opt->processCommandArgs( argc, argv );
00082
00083
00084 if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) || opt->getArgc() >0 ) {
00085 opt->printUsage();
00086 delete opt;
00087 return EXIT_FAILURE;
00088 }
00089
00090 if( opt->getValue( 'i' ) != NULL || opt->getValue( "input_file" ) != NULL ){
00091 QString tempdata(opt->getValue( 'i' ));
00092 inputFileName = currentDir + "/" + tempdata;
00093 }
00094 else {
00095 inputFileName = currentDir + "/data/regmasInput.ods";
00096 }
00097
00098 if( opt->getValue( 's' ) != NULL || opt->getValue( "scenario" ) != NULL ){
00099 scenarioName = opt->getValue( 's' );
00100 }
00101
00102 if( opt->getFlag( 'c' ) || opt->getFlag( "console" ) ){
00103 ThreadManager modelMainThread;
00104 modelMainThread.runFromConsole(inputFileName,scenarioName);
00105 }
00106 else {
00107 QApplication app(argc, argv);
00108 MainWindow mainWin;
00109 mainWin.show();
00110 return app.exec();
00111 }
00112 delete opt;
00113 }