move command line processing into class openEMS

pull/1/head
Sebastian Held 2010-03-26 11:57:53 +01:00
parent 686cb3f4cb
commit 79574aa3e6
3 changed files with 33 additions and 16 deletions

View File

@ -42,22 +42,7 @@ int main(int argc, char *argv[])
{ {
for (int n=2;n<argc;++n) for (int n=2;n<argc;++n)
{ {
if (strcmp(argv[n],"--disable-dumps")==0) if (!FDTD.parseCommandLineArgument(argv[n]))
{
cout << "openEMS - disabling all field dumps" << endl;
FDTD.SetEnableDumps(false);
}
else if (strcmp(argv[n],"--debug-material")==0)
{
cout << "openEMS - dumping material to 'material_dump.vtk'" << endl;
FDTD.DebugMaterial();
}
else if (strcmp(argv[n],"--debug-operator")==0)
{
cout << "openEMS - dumping operator to 'operator_dump.vtk'" << endl;
FDTD.DebugOperator();
}
else
cout << "openEMS - unknown argument: " << argv[n] << endl; cout << "openEMS - unknown argument: " << argv[n] << endl;
} }
} }

View File

@ -69,6 +69,36 @@ void openEMS::Reset()
PA=NULL; PA=NULL;
} }
//! \brief processes a command line argument
//! returns true if argument is known
//! returns false if argument is unknown
bool openEMS::parseCommandLineArgument( const char *argv )
{
if (!argv)
return false;
if (strcmp(argv,"--disable-dumps")==0)
{
cout << "openEMS - disabling all field dumps" << endl;
SetEnableDumps(false);
return true;
}
else if (strcmp(argv,"--debug-material")==0)
{
cout << "openEMS - dumping material to 'material_dump.vtk'" << endl;
DebugMaterial();
return true;
}
else if (strcmp(argv,"--debug-operator")==0)
{
cout << "openEMS - dumping operator to 'operator_dump.vtk'" << endl;
DebugOperator();
return true;
}
return false;
}
int openEMS::SetupFDTD(const char* file) int openEMS::SetupFDTD(const char* file)
{ {
if (file==NULL) return -1; if (file==NULL) return -1;

View File

@ -28,6 +28,8 @@ public:
openEMS(); openEMS();
~openEMS(); ~openEMS();
bool parseCommandLineArgument( const char *argv );
int SetupFDTD(const char* file); int SetupFDTD(const char* file);
void RunFDTD(); void RunFDTD();