Commit bf5b2316 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

readArgv method for Initfile-class

parent d71df77e
...@@ -41,7 +41,7 @@ find_library(_AMDIS_LIB amdis PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/ ...@@ -41,7 +41,7 @@ find_library(_AMDIS_LIB amdis PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/
if(_AMDIS_LIB) if(_AMDIS_LIB)
get_filename_component(AMDIS_LIBRARY_DIR ${_AMDIS_LIB} PATH CACHE) get_filename_component(AMDIS_LIBRARY_DIR ${_AMDIS_LIB} PATH CACHE)
set(AMDIS_LIBRARY_DIRS ${AMDIS_LIBRARY_DIR}) set(AMDIS_LIBRARY_DIRS ${AMDIS_LIBRARY_DIR})
set(AMDIS_LIBRARIES "${_AMDIS_LIB};${AMDIS_LIBRARY_DIR}/libcompositeFEM.so" CACHE STRING "amdis libraries") set(AMDIS_LIBRARIES "${_AMDIS_LIB};${AMDIS_LIBRARY_DIR}/libcompositeFEM.so;${AMDIS_LIBRARY_DIR}/libreinit.so" CACHE STRING "amdis libraries")
else() else()
message(ERROR "could not detect the AMDiS library directory. Please set the variable AMDIS_LIBRARY_DIR to the directory containg the AMDiS library") message(ERROR "could not detect the AMDiS library directory. Please set the variable AMDIS_LIBRARY_DIR to the directory containg the AMDiS library")
endif() endif()
......
...@@ -98,10 +98,20 @@ void Initfile::read(istream& in) { ...@@ -98,10 +98,20 @@ void Initfile::read(istream& in) {
} }
}; };
void Initfile::readArgv(int argc, char **argv)
{
for (int i= 0; i<argc; ++i) {
if (strcmp("-rs", argv[i]) == 0) {
std::string input(argv[i+1]);
add("argv->rs", input, 0);
}
}
}
/// read standard values for output and information of parameter-values /// read standard values for output and information of parameter-values
void Initfile::getInternalParameters() void Initfile::getInternalParameters()
{ {
int val= 10; int val= 0;
get("level of information", val, 0); get("level of information", val, 0);
msgInfo= val; msgInfo= val;
...@@ -113,6 +123,10 @@ void Initfile::getInternalParameters() ...@@ -113,6 +123,10 @@ void Initfile::getInternalParameters()
get("parameter information", val, 0); get("parameter information", val, 0);
paramInfo= val; paramInfo= val;
val= 0;
get("break on missing tag", val, 0);
breakOnMissingTag= val;
if (msgInfo==0) if (msgInfo==0)
paramInfo= 0; paramInfo= 0;
}; };
......
...@@ -240,6 +240,9 @@ struct Initfile : public std::map< std::string, std::string > { ...@@ -240,6 +240,9 @@ struct Initfile : public std::map< std::string, std::string > {
struct TagNotFound : std::invalid_argument { struct TagNotFound : std::invalid_argument {
TagNotFound(std::string m):std::invalid_argument(m) {} TagNotFound(std::string m):std::invalid_argument(m) {}
}; };
struct TagNotFoundBreak : std::invalid_argument { // print 'tag not found' and exit
TagNotFoundBreak(std::string m):std::invalid_argument(m) {}
};
/** initialize init-file from file with filename in, read data and save it to singleton-map /** initialize init-file from file with filename in, read data and save it to singleton-map
* @param in: filename string * @param in: filename string
...@@ -313,6 +316,9 @@ struct Initfile : public std::map< std::string, std::string > { ...@@ -313,6 +316,9 @@ struct Initfile : public std::map< std::string, std::string > {
set(tag, value, debug_info); set(tag, value, debug_info);
} }
/// rescheduling parameter
static void readArgv(int argc, char **argv);
/// Returns specified info level /// Returns specified info level
static int getMsgInfo() static int getMsgInfo()
{ {
...@@ -355,7 +361,7 @@ struct Initfile : public std::map< std::string, std::string > { ...@@ -355,7 +361,7 @@ struct Initfile : public std::map< std::string, std::string > {
} }
protected: protected:
Initfile() : msgInfo(10), msgWait(1), paramInfo(1) {} Initfile() : msgInfo(0), msgWait(1), paramInfo(1), breakOnMissingTag(0) {}
static void initIntern() { static void initIntern() {
if (singlett == NULL) if (singlett == NULL)
...@@ -371,8 +377,12 @@ protected: ...@@ -371,8 +377,12 @@ protected:
/// return the value of the given tag or throws an exception if the tag does not exist /// return the value of the given tag or throws an exception if the tag does not exist
std::string checkedGet(const std::string& tag) const { std::string checkedGet(const std::string& tag) const {
super::const_iterator it= find(tag); super::const_iterator it= find(tag);
if (it==end()) if (it==end()) {
throw TagNotFound("there is no tag '"+ tag + "'"); if(breakOnMissingTag==0 || msgInfo<=2)
throw TagNotFound("there is no tag '"+ tag + "'");
else
throw TagNotFoundBreak("required tag '"+ tag + "' not found");
}
return it->second; return it->second;
} }
...@@ -398,7 +408,7 @@ protected: ...@@ -398,7 +408,7 @@ protected:
/// read parameters for msgInfo, msgWait, paramInfo /// read parameters for msgInfo, msgWait, paramInfo
void getInternalParameters(); void getInternalParameters();
int msgInfo, msgWait, paramInfo; int msgInfo, msgWait, paramInfo, breakOnMissingTag;
}; };
......
project("amdis_demo") project("amdis_demo")
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(AMDIS_DIR /u/spraetor/amdis-trunk/AMDiS_seq/share/amdis)
#find_package(AMDIS REQUIRED COMPONENTS umfpack ) #find_package(AMDIS REQUIRED COMPONENTS umfpack )
find_package(AMDIS REQUIRED) find_package(AMDIS REQUIRED)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment