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

readArgv method for Initfile-class

parent d71df77e
......@@ -41,7 +41,7 @@ find_library(_AMDIS_LIB amdis PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/
if(_AMDIS_LIB)
get_filename_component(AMDIS_LIBRARY_DIR ${_AMDIS_LIB} PATH CACHE)
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()
message(ERROR "could not detect the AMDiS library directory. Please set the variable AMDIS_LIBRARY_DIR to the directory containg the AMDiS library")
endif()
......
......@@ -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
void Initfile::getInternalParameters()
{
int val= 10;
int val= 0;
get("level of information", val, 0);
msgInfo= val;
......@@ -113,6 +123,10 @@ void Initfile::getInternalParameters()
get("parameter information", val, 0);
paramInfo= val;
val= 0;
get("break on missing tag", val, 0);
breakOnMissingTag= val;
if (msgInfo==0)
paramInfo= 0;
};
......
......@@ -240,6 +240,9 @@ struct Initfile : public std::map< std::string, std::string > {
struct TagNotFound : std::invalid_argument {
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
* @param in: filename string
......@@ -313,6 +316,9 @@ struct Initfile : public std::map< std::string, std::string > {
set(tag, value, debug_info);
}
/// rescheduling parameter
static void readArgv(int argc, char **argv);
/// Returns specified info level
static int getMsgInfo()
{
......@@ -355,7 +361,7 @@ struct Initfile : public std::map< std::string, std::string > {
}
protected:
Initfile() : msgInfo(10), msgWait(1), paramInfo(1) {}
Initfile() : msgInfo(0), msgWait(1), paramInfo(1), breakOnMissingTag(0) {}
static void initIntern() {
if (singlett == NULL)
......@@ -371,8 +377,12 @@ protected:
/// 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 {
super::const_iterator it= find(tag);
if (it==end())
throw TagNotFound("there is no tag '"+ tag + "'");
if (it==end()) {
if(breakOnMissingTag==0 || msgInfo<=2)
throw TagNotFound("there is no tag '"+ tag + "'");
else
throw TagNotFoundBreak("required tag '"+ tag + "' not found");
}
return it->second;
}
......@@ -398,7 +408,7 @@ protected:
/// read parameters for msgInfo, msgWait, paramInfo
void getInternalParameters();
int msgInfo, msgWait, paramInfo;
int msgInfo, msgWait, paramInfo, breakOnMissingTag;
};
......
project("amdis_demo")
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)
......
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