From 46466ea4b6badaa333f3bf1daf368e41aa3124d4 Mon Sep 17 00:00:00 2001 From: sjunges Date: Tue, 19 Jan 2016 10:08:50 +0100 Subject: [PATCH] an unhappy intermediate commit, not worth celebrating Former-commit-id: 577674fd0de85f8df02f29563b901553a567a4ba --- src/python/storm-core.cpp | 45 +++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/python/storm-core.cpp b/src/python/storm-core.cpp index b9ccb1909..3d7b00404 100644 --- a/src/python/storm-core.cpp +++ b/src/python/storm-core.cpp @@ -4,9 +4,31 @@ #include "../logic/Formulas.h" -namespace boost { - template T* get_pointer(std::shared_ptr p) { return p.get(); } +//namespace boost { +// template T* get_pointer(std::shared_ptr p) { return p.get(); } +//} + +namespace boost { namespace python { namespace converter { + + template + PyObject* shared_ptr_to_python(std::shared_ptr const& x) + { + if (!x) + return python::detail::none(); + else if (shared_ptr_deleter* d = std::get_deleter(x)) + return incref( d->owner.get() ); + else + return converter::registered const&>::converters.to_python(&x); + } + + }}} // namespace boost::python::converter + + + +std::shared_ptr buildModel(storm::prism::Program const& program, std::shared_ptr const& formula) { + return storm::buildSymbolicModel(program, std::vector>(1,formula)).model; } + BOOST_PYTHON_MODULE(_core) { using namespace boost::python; @@ -42,16 +64,31 @@ BOOST_PYTHON_MODULE(_core) //////////////////////////////////////////// // Models //////////////////////////////////////////// + + enum_("ModelType") + .value("dtmc", storm::models::ModelType::Dtmc) + .value("mdp", storm::models::ModelType::Mdp) + .value("ctmc", storm::models::ModelType::Ctmc) + .value("ma", storm::models::ModelType::MarkovAutomaton) + ; + class_, boost::noncopyable>("ModelBase", no_init) .add_property("nrStates", &storm::models::ModelBase::getNumberOfStates) - .add_property("nrTransitions", &storm::models::ModelBase::getNumberOfTransitions); + .add_property("nrTransitions", &storm::models::ModelBase::getNumberOfTransitions) + .add_property("model_type", &storm::models::ModelBase::getType) + .def("asPdtmc", &storm::models::ModelBase::as>) + ; class_, std::shared_ptr >, boost::noncopyable, bases>("SparseParametricModel", no_init); class_, std::shared_ptr>, boost::noncopyable, bases>("SparseModel", no_init); - class_, std::shared_ptr>, boost::noncopyable, bases>>("SparseParamtricMc", no_init); + class_, std::shared_ptr>, boost::noncopyable, bases>("SparseParamtricMc", no_init); + + def("parseFormulae", storm::parseFormulasForProgram); def("parseProgram", storm::parseProgram); + def("buildModel", buildModel); + def("buildModelFromPrismProgram", storm::buildSymbolicModel); def("buildParametricModelFromPrismProgram", storm::buildSymbolicModel);