Browse Source

Renamed TraParser to DeterministicSparseTransitionParser

tempestpy_adaptions
Lanchid 12 years ago
parent
commit
b0b8c98f6b
  1. 4
      src/mrmc.cpp
  2. 6
      src/parser/DeterministicSparseTransitionParser.cpp
  3. 8
      src/parser/DeterministicSparseTransitionParser.h
  4. 4
      src/utility/IoUtility.cpp
  5. 14
      test/parser/ReadTraFileTest.cpp

4
src/mrmc.cpp

@ -25,7 +25,7 @@
#include "src/modelChecker/EigenDtmcPrctlModelChecker.h"
#include "src/modelChecker/GmmxxDtmcPrctlModelChecker.h"
#include "src/parser/LabParser.h"
#include "src/parser/TraParser.h"
#include "src/parser/DeterministicSparseTransitionParser.h"
#include "src/parser/PrctlParser.h"
#include "src/solver/GraphAnalyzer.h"
#include "src/utility/Settings.h"
@ -101,7 +101,7 @@ int main(const int argc, const char* argv[]) {
LOG4CPLUS_INFO(logger, "Enable verbose mode, log output gets printed to console.");
}
mrmc::parser::TraParser traparser(s->getString("trafile").c_str());
mrmc::parser::DeterministicSparseTransitionParser traparser(s->getString("trafile").c_str());
mrmc::parser::LabParser labparser(traparser.getMatrix()->getRowCount(), s->getString("labfile").c_str());
mrmc::models::Dtmc<double> dtmc(traparser.getMatrix(), labparser.getLabeling());

6
src/parser/TraParser.cpp → src/parser/DeterministicSparseTransitionParser.cpp

@ -5,7 +5,7 @@
* Author: Gereon Kremer
*/
#include "src/parser/TraParser.h"
#include "src/parser/DeterministicSparseTransitionParser.h"
#include "src/exceptions/FileIoException.h"
#include "src/exceptions/WrongFileFormatException.h"
#include "boost/integer/integer_mask.hpp"
@ -42,7 +42,7 @@ namespace parser{
* @param buf Data to scan. Is expected to be some char array.
* @param maxnode Is set to highest id of all nodes.
*/
uint_fast64_t TraParser::firstPass(char* buf, uint_fast64_t &maxnode) {
uint_fast64_t DeterministicSparseTransitionParser::firstPass(char* buf, uint_fast64_t &maxnode) {
uint_fast64_t non_zero = 0;
/*
@ -106,7 +106,7 @@ uint_fast64_t TraParser::firstPass(char* buf, uint_fast64_t &maxnode) {
* @return a pointer to the created sparse matrix.
*/
TraParser::TraParser(const char * filename)
DeterministicSparseTransitionParser::DeterministicSparseTransitionParser(const char * filename)
: matrix(nullptr)
{
/*

8
src/parser/TraParser.h → src/parser/DeterministicSparseTransitionParser.h

@ -12,15 +12,15 @@ namespace mrmc {
namespace parser {
/*!
* @brief Load transition system from file and return initialized
* StaticSparseMatrix object.
* @brief Load a deterministic transition system from file and create a
* sparse adjacency matrix whose entries represent the weights of the edges
*
* Note that this class creates a new StaticSparseMatrix object that can be
* accessed via getMatrix(). However, it does not delete this object!
*/
class TraParser : Parser {
class DeterministicSparseTransitionParser : Parser {
public:
TraParser(const char* filename);
DeterministicSparseTransitionParser(const char* filename);
std::shared_ptr<mrmc::storage::SquareSparseMatrix<double>> getMatrix() {
return this->matrix;

4
src/utility/IoUtility.cpp

@ -6,7 +6,7 @@
*/
#include "src/utility/IoUtility.h"
#include "src/parser/TraParser.h"
#include "src/parser/DeterministicSparseTransitionParser.h"
#include "src/parser/LabParser.h"
#include <fstream>
@ -61,7 +61,7 @@ void dtmcToDot(mrmc::models::Dtmc<double>* dtmc, std::string filename) {
//TODO: Should this stay here or be integrated in the new parser structure?
mrmc::models::Dtmc<double>* parseDTMC(const char* tra_file, const char* lab_file) {
mrmc::parser::TraParser tp(tra_file);
mrmc::parser::DeterministicSparseTransitionParser tp(tra_file);
uint_fast64_t node_count = tp.getMatrix()->getRowCount();
mrmc::parser::LabParser lp(node_count, lab_file);

14
test/parser/ReadTraFileTest.cpp

@ -8,7 +8,7 @@
#include "gtest/gtest.h"
#include "mrmc-config.h"
#include "src/storage/SquareSparseMatrix.h"
#include "src/parser/TraParser.h"
#include "src/parser/DeterministicSparseTransitionParser.h"
#include "src/exceptions/FileIoException.h"
#include "src/exceptions/WrongFileFormatException.h"
@ -16,14 +16,14 @@
TEST(ReadTraFileTest, NonExistingFileTest) {
//No matter what happens, please don't create a file with the name "nonExistingFile.not"! :-)
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/nonExistingFile.not"), mrmc::exceptions::FileIoException);
ASSERT_THROW(mrmc::parser::DeterministicSparseTransitionParser(MRMC_CPP_TESTS_BASE_PATH "/nonExistingFile.not"), mrmc::exceptions::FileIoException);
}
/* The following test case is based on one of the original MRMC test cases
*/
TEST(ReadTraFileTest, ParseFileTest1) {
mrmc::parser::TraParser* parser;
ASSERT_NO_THROW(parser = new mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/csl_general_input_01.tra"));
mrmc::parser::DeterministicSparseTransitionParser* parser;
ASSERT_NO_THROW(parser = new mrmc::parser::DeterministicSparseTransitionParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/csl_general_input_01.tra"));
std::shared_ptr<mrmc::storage::SquareSparseMatrix<double>> result = parser->getMatrix();
if (result != NULL) {
@ -69,13 +69,13 @@ TEST(ReadTraFileTest, ParseFileTest1) {
}
TEST(ReadTraFileTest, WrongFormatTestHeader1) {
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_header1.tra"), mrmc::exceptions::WrongFileFormatException);
ASSERT_THROW(mrmc::parser::DeterministicSparseTransitionParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_header1.tra"), mrmc::exceptions::WrongFileFormatException);
}
TEST(ReadTraFileTest, WrongFormatTestHeader2) {
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_header2.tra"), mrmc::exceptions::WrongFileFormatException);
ASSERT_THROW(mrmc::parser::DeterministicSparseTransitionParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_header2.tra"), mrmc::exceptions::WrongFileFormatException);
}
TEST(ReadTraFileTest, WrongFormatTestTransition) {
ASSERT_THROW(mrmc::parser::TraParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_transition.tra"), mrmc::exceptions::WrongFileFormatException);
ASSERT_THROW(mrmc::parser::DeterministicSparseTransitionParser(MRMC_CPP_TESTS_BASE_PATH "/parser/tra_files/wrong_format_transition.tra"), mrmc::exceptions::WrongFileFormatException);
}
Loading…
Cancel
Save