From 08f87d545c508803cf3bb76458d0bf57fcff7b4b Mon Sep 17 00:00:00 2001 From: PBerger Date: Mon, 17 Dec 2012 02:56:15 +0100 Subject: [PATCH] Some more refactoring, renaming, adding #ifndef guards... Fixed a warning in SquareSparseMatrix.h regarding a conversion from uint64 to uint --- src/exceptions/BaseException.h | 6 +++--- src/exceptions/InvalidSettings.h | 16 ---------------- src/exceptions/InvalidSettingsException.h | 16 ++++++++++++++++ ...oConvergence.h => NoConvergenceException.h} | 18 +++++++++--------- src/modelChecker/EigenDtmcPrctlModelChecker.h | 4 ++-- src/modelChecker/GmmxxDtmcPrctlModelChecker.h | 4 ++-- src/mrmc.cpp | 13 ++++++------- src/parser/{readLabFile.cpp => LabParser.cpp} | 4 ++-- src/parser/{readLabFile.h => LabParser.h} | 6 +++--- .../{readPrctlFile.cpp => PrctlParser.cpp} | 4 ++-- src/parser/{readPrctlFile.h => PrctlParser.h} | 10 +++++----- src/parser/{readTraFile.cpp => TraParser.cpp} | 4 ++-- src/parser/{readTraFile.h => TraParser.h} | 6 +++--- src/storage/SquareSparseMatrix.h | 2 +- src/utility/IoUtility.cpp | 4 ++-- src/utility/Settings.cpp | 8 ++++---- src/utility/Settings.h | 4 ++-- test/parser/ReadLabFileTest.cpp | 2 +- test/parser/ReadTraFileTest.cpp | 2 +- 19 files changed, 66 insertions(+), 67 deletions(-) delete mode 100644 src/exceptions/InvalidSettings.h create mode 100644 src/exceptions/InvalidSettingsException.h rename src/exceptions/{NoConvergence.h => NoConvergenceException.h} (63%) rename src/parser/{readLabFile.cpp => LabParser.cpp} (98%) rename src/parser/{readLabFile.h => LabParser.h} (88%) rename src/parser/{readPrctlFile.cpp => PrctlParser.cpp} (97%) rename src/parser/{readPrctlFile.h => PrctlParser.h} (70%) rename src/parser/{readTraFile.cpp => TraParser.cpp} (98%) rename src/parser/{readTraFile.h => TraParser.h} (87%) diff --git a/src/exceptions/BaseException.h b/src/exceptions/BaseException.h index cfba4218e..fcf92ee2c 100644 --- a/src/exceptions/BaseException.h +++ b/src/exceptions/BaseException.h @@ -1,5 +1,5 @@ -#ifndef BASEEXCEPTION_H_ -#define BASEEXCEPTION_H_ +#ifndef MRMC_EXCEPTIONS_BASEEXCEPTION_H_ +#define MRMC_EXCEPTIONS_BASEEXCEPTION_H_ #include #include @@ -38,4 +38,4 @@ class BaseException : public std::exception } // namespace exceptions } // namespace mrmc -#endif // BASEEXCEPTION_H_ +#endif // MRMC_EXCEPTIONS_BASEEXCEPTION_H_ diff --git a/src/exceptions/InvalidSettings.h b/src/exceptions/InvalidSettings.h deleted file mode 100644 index 0ac7b14b8..000000000 --- a/src/exceptions/InvalidSettings.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef INVALIDSETTINGS_H_ -#define INVALIDSETTINGS_H_ - -#include "src/exceptions/BaseException.h" - -namespace mrmc { -namespace exceptions { - -class InvalidSettings : public BaseException -{ -}; - -} // namespace exceptions -} // namespace mrmc - -#endif // INVALIDSETTINGS_H_ diff --git a/src/exceptions/InvalidSettingsException.h b/src/exceptions/InvalidSettingsException.h new file mode 100644 index 000000000..315ec64e7 --- /dev/null +++ b/src/exceptions/InvalidSettingsException.h @@ -0,0 +1,16 @@ +#ifndef MRMC_EXCEPTIONS_INVALIDSETTINGSEXCEPTION_H_ +#define MRMC_EXCEPTIONS_INVALIDSETTINGSEXCEPTION_H_ + +#include "src/exceptions/BaseException.h" + +namespace mrmc { +namespace exceptions { + +class InvalidSettingsException : public BaseException +{ +}; + +} // namespace exceptions +} // namespace mrmc + +#endif // MRMC_EXCEPTIONS_INVALIDSETTINGSEXCEPTION_H_ diff --git a/src/exceptions/NoConvergence.h b/src/exceptions/NoConvergenceException.h similarity index 63% rename from src/exceptions/NoConvergence.h rename to src/exceptions/NoConvergenceException.h index bd5b71af9..1ea6bd655 100644 --- a/src/exceptions/NoConvergence.h +++ b/src/exceptions/NoConvergenceException.h @@ -1,5 +1,5 @@ -#ifndef MRMC_EXCEPTIONS_NO_CONVERGENCE_H_ -#define MRMC_EXCEPTIONS_NO_CONVERGENCE_H_ +#ifndef MRMC_EXCEPTIONS_NOCONVERGENCEEXCEPTION_H_ +#define MRMC_EXCEPTIONS_NOCONVERGENCEEXCEPTION_H_ #include @@ -7,7 +7,7 @@ namespace mrmc { namespace exceptions { //!This exception is thrown when an iterative solver failed to converge with the given maxIterations -class NoConvergence : public std::exception +class NoConvergenceException : public std::exception { public: /* The Visual C++-Version of the exception class has constructors accepting @@ -17,27 +17,27 @@ class NoConvergence : public std::exception * constructor is used under linux (which will ignore the parameter) */ #ifdef _WIN32 - NoConvergence() : exception("::mrmc::NoConvergence"){ + NoConvergenceException() : exception("::mrmc::exceptions::NoConvergenceException"){ iterations = -1; maxIterations = -1; } - NoConvergence(const char * const s, int iterations, int maxIterations): exception(s) { + NoConvergenceException(const char * const s, int iterations, int maxIterations): exception(s) { this->iterations = iterations; this->maxIterations = maxIterations; } #else - NoConvergence() : exception() { + NoConvergenceException() : exception() { iterations = -1; maxIterations = -1; } - NoConvergence(const char * const s, int iterations, int maxIterations): exception() { + NoConvergenceException(const char * const s, int iterations, int maxIterations): exception() { this->iterations = iterations; this->maxIterations = maxIterations; } #endif virtual const char* what() const throw() - { return "mrmc::NoConvergence"; } + { return "mrmc::exceptions::NoConvergenceException"; } int getIterationCount() const { return iterations; @@ -53,4 +53,4 @@ class NoConvergence : public std::exception } // namespace exceptions } // namespace mrmc -#endif // MRMC_EXCEPTIONS_NO_CONVERGENCE_H_ +#endif // MRMC_EXCEPTIONS_NOCONVERGENCEEXCEPTION_H_ diff --git a/src/modelChecker/EigenDtmcPrctlModelChecker.h b/src/modelChecker/EigenDtmcPrctlModelChecker.h index 084c576f4..a11efe4ae 100644 --- a/src/modelChecker/EigenDtmcPrctlModelChecker.h +++ b/src/modelChecker/EigenDtmcPrctlModelChecker.h @@ -14,7 +14,7 @@ #include "src/modelChecker/DtmcPrctlModelChecker.h" #include "src/solver/GraphAnalyzer.h" #include "src/utility/ConstTemplates.h" -#include "src/exceptions/NoConvergence.h" +#include "src/exceptions/NoConvergenceException.h" #include "Eigen/Sparse" #include "Eigen/src/IterativeLinearSolvers/BiCGSTAB.h" @@ -197,7 +197,7 @@ public: LOG4CPLUS_ERROR(logger, "Solving of Submatrix failed: InvalidInput"); } else if(solver.info() == Eigen::ComputationInfo::NoConvergence) { // NoConvergence - throw mrmc::exceptions::NoConvergence("Solving of Submatrix with Eigen failed", solver.iterations(), solver.maxIterations()); + throw mrmc::exceptions::NoConvergenceException("Solving of Submatrix with Eigen failed", solver.iterations(), solver.maxIterations()); } else if(solver.info() == Eigen::ComputationInfo::NumericalIssue) { // NumericalIssue LOG4CPLUS_ERROR(logger, "Solving of Submatrix failed: NumericalIssue"); diff --git a/src/modelChecker/GmmxxDtmcPrctlModelChecker.h b/src/modelChecker/GmmxxDtmcPrctlModelChecker.h index a3b1a57c4..1ebcfb574 100644 --- a/src/modelChecker/GmmxxDtmcPrctlModelChecker.h +++ b/src/modelChecker/GmmxxDtmcPrctlModelChecker.h @@ -250,7 +250,7 @@ public: */ static void validateLeMethod(const std::string& lemethod) { if (lemethod.compare("bicgstab") != 0 && lemethod.compare("qmr") != 0) { - throw exceptions::InvalidSettings() << "Argument " << lemethod << " for option 'lemethod' is invalid."; + throw exceptions::InvalidSettingsException() << "Argument " << lemethod << " for option 'lemethod' is invalid."; } } @@ -260,7 +260,7 @@ public: */ static void validatePreconditioner(const std::string& preconditioner) { if (preconditioner.compare("ilu") != 0 && preconditioner.compare("diagonal") != 0 && preconditioner.compare("ildlt") && preconditioner.compare("none") != 0) { - throw exceptions::InvalidSettings() << "Argument " << preconditioner << " for option 'precond' is invalid."; + throw exceptions::InvalidSettingsException() << "Argument " << preconditioner << " for option 'precond' is invalid."; } } }; diff --git a/src/mrmc.cpp b/src/mrmc.cpp index 882c096a8..9bb62172a 100644 --- a/src/mrmc.cpp +++ b/src/mrmc.cpp @@ -24,20 +24,19 @@ #include "src/models/AtomicPropositionsLabeling.h" #include "src/modelChecker/EigenDtmcPrctlModelChecker.h" #include "src/modelChecker/GmmxxDtmcPrctlModelChecker.h" -#include "src/parser/readLabFile.h" -#include "src/parser/readTraFile.h" -#include "src/parser/readPrctlFile.h" +#include "src/parser/LabParser.h" +#include "src/parser/TraParser.h" +#include "src/parser/PrctlParser.h" #include "src/solver/GraphAnalyzer.h" #include "src/utility/Settings.h" #include "src/formula/Formulas.h" -#include "src/exceptions/NoConvergence.h" #include "log4cplus/logger.h" #include "log4cplus/loggingmacros.h" #include "log4cplus/consoleappender.h" #include "log4cplus/fileappender.h" -#include "src/exceptions/InvalidSettings.h" +#include "src/exceptions/InvalidSettingsException.h" log4cplus::Logger logger; @@ -76,7 +75,7 @@ int main(const int argc, const char* argv[]) { try { mrmc::settings::Settings::registerModule >(); s = mrmc::settings::newInstance(argc, argv, nullptr); - } catch (mrmc::exceptions::InvalidSettings& e) { + } catch (mrmc::exceptions::InvalidSettingsException& e) { LOG4CPLUS_FATAL(logger, "InvalidSettings error: " << e.what() << "."); LOG4CPLUS_FATAL(logger, "Could not recover from settings error, terminating."); std::cout << "Could not recover from settings error: " << e.what() << "." << std::endl; @@ -91,7 +90,7 @@ int main(const int argc, const char* argv[]) { return 0; } if (s->isSet("test-prctl")) { - mrmc::parser::PRCTLParser parser(s->getString("test-prctl").c_str()); + mrmc::parser::PrctlParser parser(s->getString("test-prctl").c_str()); delete s; return 0; } diff --git a/src/parser/readLabFile.cpp b/src/parser/LabParser.cpp similarity index 98% rename from src/parser/readLabFile.cpp rename to src/parser/LabParser.cpp index 17a47a5db..8f0b18117 100644 --- a/src/parser/readLabFile.cpp +++ b/src/parser/LabParser.cpp @@ -1,11 +1,11 @@ /*! - * readLabFile.cpp + * LabParser.cpp * * Created on: 21.11.2012 * Author: Gereon Kremer */ -#include "readLabFile.h" +#include "src/parser/LabParser.h" #include "src/exceptions/WrongFileFormatException.h" #include "src/exceptions/FileIoException.h" diff --git a/src/parser/readLabFile.h b/src/parser/LabParser.h similarity index 88% rename from src/parser/readLabFile.h rename to src/parser/LabParser.h index 6884226e5..bb1e2d992 100644 --- a/src/parser/readLabFile.h +++ b/src/parser/LabParser.h @@ -1,5 +1,5 @@ -#ifndef READLABFILE_H_ -#define READLABFILE_H_ +#ifndef MRMC_PARSER_LABPARSER_H_ +#define MRMC_PARSER_LABPARSER_H_ #include "src/models/AtomicPropositionsLabeling.h" #include "boost/integer/integer_mask.hpp" @@ -32,4 +32,4 @@ class LabParser : Parser { } // namespace parser } // namespace mrmc -#endif /* READLABFILE_H_ */ +#endif /* MRMC_PARSER_LABPARSER_H_ */ diff --git a/src/parser/readPrctlFile.cpp b/src/parser/PrctlParser.cpp similarity index 97% rename from src/parser/readPrctlFile.cpp rename to src/parser/PrctlParser.cpp index f0b669d34..695d64a78 100644 --- a/src/parser/readPrctlFile.cpp +++ b/src/parser/PrctlParser.cpp @@ -1,4 +1,4 @@ -#include "src/parser/readPrctlFile.h" +#include "src/parser/PrctlParser.h" #include #include @@ -130,7 +130,7 @@ namespace }; } -mrmc::parser::PRCTLParser::PRCTLParser(const char* filename) +mrmc::parser::PrctlParser::PrctlParser(const char* filename) { SpiritParser p; mrmc::parser::MappedFile file(filename); diff --git a/src/parser/readPrctlFile.h b/src/parser/PrctlParser.h similarity index 70% rename from src/parser/readPrctlFile.h rename to src/parser/PrctlParser.h index e6ec06fdc..0cd5ee7cf 100644 --- a/src/parser/readPrctlFile.h +++ b/src/parser/PrctlParser.h @@ -1,5 +1,5 @@ -#ifndef READPRCTLFILE_H_ -#define READPRCTLFILE_H_ +#ifndef MRMC_PARSER_PRCTLPARSER_H_ +#define MRMC_PARSER_PRCTLPARSER_H_ #include "src/formula/PCTLformula.h" #include "src/parser/Parser.h" @@ -10,10 +10,10 @@ namespace parser { /*! * @brief Load PRCTL file */ -class PRCTLParser : Parser +class PrctlParser : Parser { public: - PRCTLParser(const char * filename); + PrctlParser(const char * filename); /*! * @brief return formula object parsed from file. @@ -30,4 +30,4 @@ class PRCTLParser : Parser } // namespace parser } // namespace mrmc -#endif /* READPRCTLFILE_H_ */ +#endif /* MRMC_PARSER_PRCTLPARSER_H_ */ diff --git a/src/parser/readTraFile.cpp b/src/parser/TraParser.cpp similarity index 98% rename from src/parser/readTraFile.cpp rename to src/parser/TraParser.cpp index 484c7d3cf..5b98a9dda 100644 --- a/src/parser/readTraFile.cpp +++ b/src/parser/TraParser.cpp @@ -1,11 +1,11 @@ /*! - * readTraFile.cpp + * TraParser.cpp * * Created on: 20.11.2012 * Author: Gereon Kremer */ -#include "src/parser/readTraFile.h" +#include "src/parser/TraParser.h" #include "src/exceptions/FileIoException.h" #include "src/exceptions/WrongFileFormatException.h" #include "boost/integer/integer_mask.hpp" diff --git a/src/parser/readTraFile.h b/src/parser/TraParser.h similarity index 87% rename from src/parser/readTraFile.h rename to src/parser/TraParser.h index 2b72583f9..4626fab72 100644 --- a/src/parser/readTraFile.h +++ b/src/parser/TraParser.h @@ -1,5 +1,5 @@ -#ifndef READTRAFILE_H_ -#define READTRAFILE_H_ +#ifndef MRMC_PARSER_TRAPARSER_H_ +#define MRMC_PARSER_TRAPARSER_H_ #include "src/storage/SquareSparseMatrix.h" @@ -35,4 +35,4 @@ class TraParser : Parser { } // namespace parser } // namespace mrmc -#endif /* READTRAFILE_H_ */ +#endif /* MRMC_PARSER_TRAPARSER_H_ */ diff --git a/src/storage/SquareSparseMatrix.h b/src/storage/SquareSparseMatrix.h index 9fb363d42..d8cf24760 100644 --- a/src/storage/SquareSparseMatrix.h +++ b/src/storage/SquareSparseMatrix.h @@ -670,7 +670,7 @@ public: } } // Fill in sentinel element at the end. - result->jc[rowCount] = realNonZeros; + result->jc[rowCount] = static_cast(realNonZeros); // Now, we can copy the temporary array to the GMMXX format. result->ir.resize(realNonZeros); diff --git a/src/utility/IoUtility.cpp b/src/utility/IoUtility.cpp index 2beddb5cd..299527044 100644 --- a/src/utility/IoUtility.cpp +++ b/src/utility/IoUtility.cpp @@ -6,8 +6,8 @@ */ #include "src/utility/IoUtility.h" -#include "src/parser/readTraFile.h" -#include "src/parser/readLabFile.h" +#include "src/parser/TraParser.h" +#include "src/parser/LabParser.h" #include diff --git a/src/utility/Settings.cpp b/src/utility/Settings.cpp index e6fea77c7..bf79a0441 100644 --- a/src/utility/Settings.cpp +++ b/src/utility/Settings.cpp @@ -102,16 +102,16 @@ Settings::Settings(const int argc, const char* argv[], const char* filename) { LOG4CPLUS_ERROR(logger, "Could not read config file"); } catch (bpo::required_option e) { - throw mrmc::exceptions::InvalidSettings() << "Required option missing"; + throw mrmc::exceptions::InvalidSettingsException() << "Required option missing"; } catch (bpo::validation_error e) { - throw mrmc::exceptions::InvalidSettings() << "Validation failed: " << e.what(); + throw mrmc::exceptions::InvalidSettingsException() << "Validation failed: " << e.what(); } catch (bpo::invalid_command_line_syntax e) { - throw mrmc::exceptions::InvalidSettings() << e.what(); + throw mrmc::exceptions::InvalidSettingsException() << e.what(); } catch (bpo::error e) { - throw mrmc::exceptions::InvalidSettings() << e.what(); + throw mrmc::exceptions::InvalidSettingsException() << e.what(); } } diff --git a/src/utility/Settings.h b/src/utility/Settings.h index 66b63890f..5b76d839e 100644 --- a/src/utility/Settings.h +++ b/src/utility/Settings.h @@ -14,7 +14,7 @@ #include #include #include -#include "src/exceptions/InvalidSettings.h" +#include "src/exceptions/InvalidSettingsException.h" namespace mrmc { @@ -52,7 +52,7 @@ namespace settings { */ template const T& get(const std::string &name) const { - if (this->vm.count(name) == 0) throw mrmc::exceptions::InvalidSettings() << "Could not read option " << name << "."; + if (this->vm.count(name) == 0) throw mrmc::exceptions::InvalidSettingsException() << "Could not read option " << name << "."; return this->vm[name].as(); } diff --git a/test/parser/ReadLabFileTest.cpp b/test/parser/ReadLabFileTest.cpp index 658076490..97e201151 100644 --- a/test/parser/ReadLabFileTest.cpp +++ b/test/parser/ReadLabFileTest.cpp @@ -8,7 +8,7 @@ #include "gtest/gtest.h" #include "mrmc-config.h" #include "src/models/AtomicPropositionsLabeling.h" -#include "src/parser/readLabFile.h" +#include "src/parser/LabParser.h" #include "src/exceptions/FileIoException.h" #include "src/exceptions/WrongFileFormatException.h" diff --git a/test/parser/ReadTraFileTest.cpp b/test/parser/ReadTraFileTest.cpp index bac78d971..99c374a6b 100644 --- a/test/parser/ReadTraFileTest.cpp +++ b/test/parser/ReadTraFileTest.cpp @@ -8,7 +8,7 @@ #include "gtest/gtest.h" #include "mrmc-config.h" #include "src/storage/SquareSparseMatrix.h" -#include "src/parser/readTraFile.h" +#include "src/parser/TraParser.h" #include "src/exceptions/FileIoException.h" #include "src/exceptions/WrongFileFormatException.h"