Browse Source

Merge branch 'master' of https://sselab.de/lab9/private/git/MRMC

tempestpy_adaptions
dehnert 12 years ago
parent
commit
b4e9580d96
  1. 9
      CMakeLists.txt
  2. 35
      src/exceptions/InvalidSettings.h
  3. 28
      src/mrmc-cpp.cpp
  4. 63
      src/utility/settings.h

9
CMakeLists.txt

@ -6,6 +6,12 @@ project (MRMC-cpp CXX C)
set (MRMC_CPP_VERSION_MAJOR 1) set (MRMC_CPP_VERSION_MAJOR 1)
set (MRMC_CPP_VERSION_MINOR 0) set (MRMC_CPP_VERSION_MINOR 0)
set (GTEST_INCLUDE_DIR resources/3rdparty/gtest-1.6.0/include)
set (GTEST_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/libgtest.a)
set (GTEST_MAIN_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/libgtest_main.a)
set (STLSOFT_INCLUDE_DIR resources/3rdparty/stlsoft-1.9.116/include)
set (PANTHEIOS_INCLUDE_DIR resources/3rdparty/pantheios-1.0.1-beta214/include)
option(DEBUG "Sets whether the DEBUG mode is used" ON) option(DEBUG "Sets whether the DEBUG mode is used" ON)
option(DEFINE_UNIX "Defines the UNIX flag for compilation." OFF) option(DEFINE_UNIX "Defines the UNIX flag for compilation." OFF)
option(USE_POPCNT "Sets whether the popcnt instruction is going to be used." OFF) option(USE_POPCNT "Sets whether the popcnt instruction is going to be used." OFF)
@ -155,7 +161,7 @@ string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc ALL
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMENT "Generating API documentation with Doxygen" VERBATIM COMMENT "Generating API documentation with Doxygen" VERBATIM
@ -189,3 +195,4 @@ endif(THREADS_FOUND)
if (DEFINE_UNIX) if (DEFINE_UNIX)
add_definitions(-DUNIX) add_definitions(-DUNIX)
endif(DEFINE_UNIX) endif(DEFINE_UNIX)

35
src/exceptions/InvalidSettings.h

@ -0,0 +1,35 @@
#ifndef MRMC_EXCEPTIONS_INVALID_SETTINGS_H_
#define MRMC_EXCEPTIONS_INVALID_SETTINGS_H_
#include <exception>
namespace mrmc {
namespace exceptions {
//!This exception is thrown when a memory request can't be
//!fulfilled.
class InvalidSettings : public std::exception
{
public:
/* The Visual C++-Version of the exception class has constructors accepting
* a char*-constant; The GCC version does not have these
*
* As the "extended" constructor is used in the sparse matrix code, a dummy
* constructor is used under linux (which will ignore the parameter)
*/
#ifdef _WIN32
InvalidSettings() : exception("::mrmc::InvalidSettings"){}
InvalidSettings(const char * const s): exception(s) {}
#else
InvalidSettings() : exception() {}
InvalidSettings(const char * const s): exception() {}
#endif
virtual const char* what() const throw()
{ return "mrmc::InvalidSettings"; }
};
} // namespace exceptions
} // namespace mrmc
#endif // MRMC_EXCEPTIONS_INVALID_SETTINGS_H_

28
src/mrmc-cpp.cpp

@ -30,27 +30,39 @@ PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = "mrmc-cpp"
#include "src/parser/read_tra_file.h" #include "src/parser/read_tra_file.h"
#include "src/utility/settings.h" #include "src/utility/settings.h"
#include "Eigen/Sparse" #include "Eigen/Sparse"
#include "src/exceptions/InvalidSettings.h"
int main(const int argc, const char* argv[]) { int main(const int argc, const char* argv[]) {
// Logging init // Logging init
pantheios_be_file_setFilePath("log.all"); pantheios_be_file_setFilePath("log.all");
pantheios::log_INFORMATIONAL("MRMC-Cpp started."); pantheios::log_INFORMATIONAL("MRMC-Cpp started.");
mrmc::settings::Settings s(argc, argv, NULL);
if (s.isSet("help"))
mrmc::settings::Settings* s = NULL;
try
{
s = new mrmc::settings::Settings(argc, argv, NULL);
}
catch (mrmc::exceptions::InvalidSettings)
{
std::cout << "Could not recover from settings error, terminating." << std::endl;
return 1;
}
if (s->isSet("help"))
{ {
std::cout << s.getHelpForCommandline() << std::endl;
std::cout << s->getHelpForCommandline() << std::endl;
return 0; return 0;
} }
if (s.isSet("help-config"))
if (s->isSet("help-config"))
{ {
std::cout << s.getHelpForConfigfile() << std::endl;
std::cout << s->getHelpForConfigfile() << std::endl;
return 0; return 0;
} }
mrmc::sparse::StaticSparseMatrix<double>* probMatrix = mrmc::parser::read_tra_file(s.getString("trafile").c_str());
mrmc::models::AtomicPropositionsLabeling* labeling = mrmc::parser::read_lab_file(probMatrix->getRowCount(), s.getString("labfile").c_str());
mrmc::sparse::StaticSparseMatrix<double>* probMatrix = mrmc::parser::read_tra_file(s->getString("trafile").c_str());
mrmc::models::AtomicPropositionsLabeling* labeling = mrmc::parser::read_lab_file(probMatrix->getRowCount(), s->getString("labfile").c_str());
mrmc::models::Dtmc<double> dtmc(probMatrix, labeling); mrmc::models::Dtmc<double> dtmc(probMatrix, labeling);

63
src/utility/settings.h

@ -5,10 +5,12 @@
* Author: Gereon Kremer * Author: Gereon Kremer
*/ */
#pragma once
#ifndef SETTINGS_H_
#define SETTINGS_H_
#include <iostream> #include <iostream>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include "src/exceptions/InvalidSettings.h"
namespace mrmc { namespace mrmc {
namespace settings { namespace settings {
@ -22,29 +24,6 @@ namespace settings {
*/ */
class Settings class Settings
{ {
private:
/*!
* @brief option descriptions
*/
bpo::options_description configfile;
bpo::options_description generic;
bpo::options_description commandline;
bpo::positional_options_description positional;
/*!
* @brief collecing option descriptions
*
* The options for command line and config file are collected
* here
*/
bpo::options_description cli;
bpo::options_description conf;
/*!
* @brief option mapping
*/
bpo::variables_map vm;
public: public:
/*! /*!
@ -117,7 +96,11 @@ namespace settings {
} }
catch (bpo::required_option e) catch (bpo::required_option e)
{ {
std::cout << e.what() << std::endl;
if (! (this->vm.count("help") || this->vm.count("help-config")))
{
std::cout << e.what() << std::endl;
throw mrmc::exceptions::InvalidSettings();
}
} }
catch (bpo::error e) catch (bpo::error e)
{ {
@ -151,9 +134,35 @@ namespace settings {
const bool isSet(const std::string &name) const const bool isSet(const std::string &name) const
{ {
return this->vm.count(name);
return this->vm.count(name) > 0;
} }
private:
/*!
* @brief option descriptions
*/
bpo::options_description configfile;
bpo::options_description generic;
bpo::options_description commandline;
bpo::positional_options_description positional;
/*!
* @brief collecing option descriptions
*
* The options for command line and config file are collected
* here
*/
bpo::options_description cli;
bpo::options_description conf;
/*!
* @brief option mapping
*/
bpo::variables_map vm;
}; };
} // namespace parser } // namespace parser
} // namespace mrmc
} // namespace mrmc
#endif // SETTINGS_H_
Loading…
Cancel
Save