Browse Source

changed model base class

AbstractModel is the new base class for every model.
If requires all models to implement ``ModelType getType()``
And implements ``as<ModelClass>()`` performing a dynamic cast on a shared pointer, assuming that we will always use Models within shared pointers.
tempestpy_adaptions
gereon 12 years ago
parent
commit
006c9e6b88
  1. 47
      src/models/AbstractModel.h
  2. 13
      src/models/Model.h

47
src/models/AbstractModel.h

@ -0,0 +1,47 @@
#ifndef STORM_MODELS_ABSTRACTMODEL_H_
#define STORM_MODELS_ABSTRACTMODEL_H_
#include <memory>
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 <typename Model>
std::shared_ptr<Model> as() {
//return *dynamic_cast<Model*>(this);
return std::dynamic_pointer_cast<Model>(std::shared_ptr<AbstractModel>(this));
}
virtual ModelType getType() = 0;
};
} // namespace models
} // namespace storm
#endif /* STORM_MODELS_ABSTRACTMODEL_H_ */

13
src/models/Model.h

@ -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_ */
Loading…
Cancel
Save