From 006c9e6b8827adcf410629a600c4c7ed7e7191e4 Mon Sep 17 00:00:00 2001 From: gereon Date: Sat, 12 Jan 2013 13:35:11 +0100 Subject: [PATCH] changed model base class AbstractModel is the new base class for every model. If requires all models to implement ``ModelType getType()`` And implements ``as()`` performing a dynamic cast on a shared pointer, assuming that we will always use Models within shared pointers. --- src/models/AbstractModel.h | 47 ++++++++++++++++++++++++++++++++++++++ src/models/Model.h | 13 ----------- 2 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 src/models/AbstractModel.h delete mode 100644 src/models/Model.h diff --git a/src/models/AbstractModel.h b/src/models/AbstractModel.h new file mode 100644 index 000000000..1e7d6a32d --- /dev/null +++ b/src/models/AbstractModel.h @@ -0,0 +1,47 @@ +#ifndef STORM_MODELS_ABSTRACTMODEL_H_ +#define STORM_MODELS_ABSTRACTMODEL_H_ + +#include + +namespace storm { +namespace models { + +/*! + * @brief Enumeration of all supported types of models. + */ +enum ModelType { + Unknown, DTMC, CTMC, MDP, CTMDP +}; +/* +// TODO: If we want this to work, it has to be in a cpp... :-) +std::ostream& operator<<(std::ostream& os, const ModelType type) +{ + switch (type) { + case Unknown: os << "Unknown"; break; + case DTMC: os << "DTMC"; break; + case CTMC: os << "CTMC"; break; + case MDP: os << "MDP"; break; + case CTMDP: os << "CTMDP"; break; + default: os << "Invalid ModelType"; break; + } + return os; +} +*/ + +class AbstractModel { + + public: + template + std::shared_ptr as() { + //return *dynamic_cast(this); + return std::dynamic_pointer_cast(std::shared_ptr(this)); + } + + virtual ModelType getType() = 0; + +}; + +} // namespace models +} // namespace storm + +#endif /* STORM_MODELS_ABSTRACTMODEL_H_ */ \ No newline at end of file diff --git a/src/models/Model.h b/src/models/Model.h deleted file mode 100644 index fbb2da3de..000000000 --- a/src/models/Model.h +++ /dev/null @@ -1,13 +0,0 @@ -#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