Browse Source

Some more refactoring, renaming, adding #ifndef guards...

Fixed a warning in SquareSparseMatrix.h regarding a conversion from uint64 to uint
tempestpy_adaptions
PBerger 12 years ago
parent
commit
08f87d545c
  1. 6
      src/exceptions/BaseException.h
  2. 16
      src/exceptions/InvalidSettings.h
  3. 16
      src/exceptions/InvalidSettingsException.h
  4. 18
      src/exceptions/NoConvergenceException.h
  5. 4
      src/modelChecker/EigenDtmcPrctlModelChecker.h
  6. 4
      src/modelChecker/GmmxxDtmcPrctlModelChecker.h
  7. 13
      src/mrmc.cpp
  8. 4
      src/parser/LabParser.cpp
  9. 6
      src/parser/LabParser.h
  10. 4
      src/parser/PrctlParser.cpp
  11. 10
      src/parser/PrctlParser.h
  12. 4
      src/parser/TraParser.cpp
  13. 6
      src/parser/TraParser.h
  14. 2
      src/storage/SquareSparseMatrix.h
  15. 4
      src/utility/IoUtility.cpp
  16. 8
      src/utility/Settings.cpp
  17. 4
      src/utility/Settings.h
  18. 2
      test/parser/ReadLabFileTest.cpp
  19. 2
      test/parser/ReadTraFileTest.cpp

6
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 <exception>
#include <sstream>
@ -38,4 +38,4 @@ class BaseException : public std::exception
} // namespace exceptions
} // namespace mrmc
#endif // BASEEXCEPTION_H_
#endif // MRMC_EXCEPTIONS_BASEEXCEPTION_H_

16
src/exceptions/InvalidSettings.h

@ -1,16 +0,0 @@
#ifndef INVALIDSETTINGS_H_
#define INVALIDSETTINGS_H_
#include "src/exceptions/BaseException.h"
namespace mrmc {
namespace exceptions {
class InvalidSettings : public BaseException<InvalidSettings>
{
};
} // namespace exceptions
} // namespace mrmc
#endif // INVALIDSETTINGS_H_

16
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<InvalidSettingsException>
{
};
} // namespace exceptions
} // namespace mrmc
#endif // MRMC_EXCEPTIONS_INVALIDSETTINGSEXCEPTION_H_

18
src/exceptions/NoConvergence.h → 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 <exception>
@ -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_

4
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");

4
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.";
}
}
};

13
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<mrmc::modelChecker::GmmxxDtmcPrctlModelChecker<double> >();
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;
}

4
src/parser/readLabFile.cpp → 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"

6
src/parser/readLabFile.h → 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_ */

4
src/parser/readPrctlFile.cpp → src/parser/PrctlParser.cpp

@ -1,4 +1,4 @@
#include "src/parser/readPrctlFile.h"
#include "src/parser/PrctlParser.h"
#include <iostream>
#include <map>
@ -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);

10
src/parser/readPrctlFile.h → 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_ */

4
src/parser/readTraFile.cpp → 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"

6
src/parser/readTraFile.h → 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_ */

2
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<unsigned int>(realNonZeros);
// Now, we can copy the temporary array to the GMMXX format.
result->ir.resize(realNonZeros);

4
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 <fstream>

8
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();
}
}

4
src/utility/Settings.h

@ -14,7 +14,7 @@
#include <utility>
#include <memory>
#include <boost/program_options.hpp>
#include "src/exceptions/InvalidSettings.h"
#include "src/exceptions/InvalidSettingsException.h"
namespace mrmc {
@ -52,7 +52,7 @@ namespace settings {
*/
template <typename T>
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<T>();
}

2
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"

2
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"

Loading…
Cancel
Save