diff --git a/src/models/Ctmc.h b/src/models/Ctmc.h index 413350124..f13f00cd6 100644 --- a/src/models/Ctmc.h +++ b/src/models/Ctmc.h @@ -18,6 +18,8 @@ #include "src/storage/SparseMatrix.h" #include "src/exceptions/InvalidArgumentException.h" +#include "src/models/Model.h" + namespace storm { namespace models { @@ -27,7 +29,7 @@ namespace models { * labeled with atomic propositions. */ template -class Ctmc { +class Ctmc : public storm::models::Model { public: //! Constructor diff --git a/src/models/Dtmc.h b/src/models/Dtmc.h index 55abacffe..2d7837dc5 100644 --- a/src/models/Dtmc.h +++ b/src/models/Dtmc.h @@ -19,6 +19,8 @@ #include "src/exceptions/InvalidArgumentException.h" #include "src/utility/CommandLine.h" +#include "src/models/Model.h" + namespace storm { namespace models { @@ -28,7 +30,7 @@ namespace models { * labeled with atomic propositions. */ template -class Dtmc { +class Dtmc : public storm::models::Model { public: //! Constructor diff --git a/src/models/Model.h b/src/models/Model.h new file mode 100644 index 000000000..fbb2da3de --- /dev/null +++ b/src/models/Model.h @@ -0,0 +1,13 @@ +#ifndef STORM_MODELS_MODEL_H_ +#define STORM_MODELS_MODEL_H_ + +namespace storm { +namespace models { + +class Model { +}; + +} // namespace models +} // namespace storm + +#endif /* STORM_MODELS_MODEL_H_ */ \ No newline at end of file diff --git a/src/parser/AutoTransitionParser.cpp b/src/parser/AutoParser.cpp similarity index 80% rename from src/parser/AutoTransitionParser.cpp rename to src/parser/AutoParser.cpp index d65318a76..31c71953c 100644 --- a/src/parser/AutoTransitionParser.cpp +++ b/src/parser/AutoParser.cpp @@ -1,4 +1,4 @@ -#include "src/parser/AutoTransitionParser.h" +#include "src/parser/AutoParser.h" #include "src/exceptions/WrongFileFormatException.h" @@ -10,12 +10,12 @@ namespace storm { namespace parser { -AutoTransitionParser::AutoTransitionParser(const std::string& filename) +AutoParser::AutoParser(const std::string& filename) : type(Unknown) { - TransitionType name = this->analyzeFilename(filename); - std::pair content = this->analyzeContent(filename); - TransitionType hint = content.first, transitions = content.second; + ModelType name = this->analyzeFilename(filename); + std::pair content = this->analyzeContent(filename); + ModelType hint = content.first, transitions = content.second; if (hint == Unknown) { if (name == transitions) this->type = name; @@ -60,8 +60,8 @@ AutoTransitionParser::AutoTransitionParser(const std::string& filename) } } -TransitionType AutoTransitionParser::analyzeFilename(const std::string& filename) { - TransitionType type = Unknown; +ModelType AutoParser::analyzeFilename(const std::string& filename) { + ModelType type = Unknown; // find file extension std::string::size_type extpos = filename.rfind("."); @@ -75,9 +75,9 @@ TransitionType AutoTransitionParser::analyzeFilename(const std::string& filename return type; } -std::pair AutoTransitionParser::analyzeContent(const std::string& filename) { +std::pair AutoParser::analyzeContent(const std::string& filename) { - TransitionType hintType = Unknown, transType = Unknown; + ModelType hintType = Unknown, transType = Unknown; // Open file MappedFile file(filename.c_str()); char* buf = file.data; @@ -90,7 +90,11 @@ std::pair AutoTransitionParser::analyzeContent(co if (strncmp(hint, "dtmc", sizeof(hint)) == 0) hintType = DTMC; else if (strncmp(hint, "ndtmc", sizeof(hint)) == 0) hintType = NDTMC; - return std::pair(hintType, transType); + + // check transition format + // todo. + + return std::pair(hintType, transType); } } //namespace parser diff --git a/src/parser/AutoTransitionParser.h b/src/parser/AutoParser.h similarity index 73% rename from src/parser/AutoTransitionParser.h rename to src/parser/AutoParser.h index 334173975..f1452520b 100644 --- a/src/parser/AutoTransitionParser.h +++ b/src/parser/AutoParser.h @@ -14,19 +14,19 @@ namespace storm { namespace parser { /*! - * @brief Enumeration of all supported types of transition systems. + * @brief Enumeration of all supported types of models. */ -enum TransitionType { +enum ModelType { Unknown, DTMC, NDTMC }; -std::ostream& operator<<(std::ostream& os, const TransitionType type) +std::ostream& operator<<(std::ostream& os, const ModelType type) { switch (type) { case Unknown: os << "Unknown"; break; case DTMC: os << "DTMC"; break; case NDTMC: os << "NDTMC"; break; - default: os << "Invalid TransitionType"; + default: os << "Invalid ModelType"; } return os; } @@ -46,35 +46,34 @@ std::ostream& operator<<(std::ostream& os, const TransitionType type) * parser. * Otherwise, it will issue an error. */ -class AutoTransitionParser : Parser { +class AutoParser : Parser { public: - AutoTransitionParser(const std::string& filename); + AutoParser(const std::string& filename); /*! * @brief Returns the type of transition system that was detected. */ - TransitionType getTransitionType() { + ModelType getModelType() { return this->type; } - // TODO: is this actually safe with shared_ptr? template T* getParser() { return dynamic_cast( this->parser ); } - ~AutoTransitionParser() { + ~AutoParser() { delete this->parser; } private: - TransitionType analyzeFilename(const std::string& filename); - std::pair analyzeContent(const std::string& filename); + ModelType analyzeFilename(const std::string& filename); + std::pair analyzeContent(const std::string& filename); /*! * @brief Type of the transition system. */ - TransitionType type; + ModelType type; /*! * @brief Pointer to a parser that has parsed the given transition system.