From: Anthony Geay Date: Thu, 26 Sep 2019 13:56:48 +0000 (+0200) Subject: Split loadTemplate into 2 parts to ease overload of default visitor X-Git-Tag: V9_4_0~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d4f5598b1519a28c144f99a709d75316e17b1fc7;p=tools%2Fadao_interface.git Split loadTemplate into 2 parts to ease overload of default visitor --- diff --git a/AdaoExchangeLayer.cxx b/AdaoExchangeLayer.cxx index 8e9e280..38b1ba3 100644 --- a/AdaoExchangeLayer.cxx +++ b/AdaoExchangeLayer.cxx @@ -319,7 +319,7 @@ private: PyObject *_context = nullptr; }; -void AdaoExchangeLayer::loadTemplate(AdaoModel::MainModel *model) +void AdaoExchangeLayer::setFunctionCallbackInModel(AdaoModel::MainModel *model) { AutoGIL agil; const char DECORATOR_FUNC[]="def DecoratorAdao(cppFunc):\n" @@ -346,7 +346,11 @@ void AdaoExchangeLayer::loadTemplate(AdaoModel::MainModel *model) // Visitor1 visitor(this->_internal->_decorator_func,this->_internal->_context); model->visitPythonLeaves(&visitor); - // +} + +void AdaoExchangeLayer::loadTemplate(AdaoModel::MainModel *model) +{ + AutoGIL agil; { std::string sciptPyOfModelMaker(model->pyStr()); PyObjectRAII res(PyObjectRAII::FromNew(PyRun_String(sciptPyOfModelMaker.c_str(),Py_file_input,this->_internal->_context,this->_internal->_context))); diff --git a/AdaoExchangeLayer.hxx b/AdaoExchangeLayer.hxx index 988e23c..c9f2257 100644 --- a/AdaoExchangeLayer.hxx +++ b/AdaoExchangeLayer.hxx @@ -40,6 +40,7 @@ public: PyObject *getPythonContext() const; std::string printContext() const; void init(); + void setFunctionCallbackInModel(AdaoModel::MainModel *model); void loadTemplate(AdaoModel::MainModel *model); void execute(); bool next(PyObject *& inputRequested); diff --git a/TestAdaoExchange.cxx b/TestAdaoExchange.cxx index 30d2949..668201f 100644 --- a/TestAdaoExchange.cxx +++ b/TestAdaoExchange.cxx @@ -124,6 +124,7 @@ void AdaoExchangeTest::test3DVar() AdaoExchangeLayer adao; adao.init(); // For bounds, Background/Vector, Observation/Vector + adao.setFunctionCallbackInModel(&mm); Visitor2 visitorPythonObj(adao.getPythonContext()); { AutoGIL agil; @@ -181,6 +182,7 @@ void AdaoExchangeTest::testBlue() AdaoExchangeLayer adao; adao.init(); // For bounds, Background/Vector, Observation/Vector + adao.setFunctionCallbackInModel(&mm); Visitor2 visitorPythonObj(adao.getPythonContext()); { AutoGIL agil; @@ -237,6 +239,7 @@ void AdaoExchangeTest::testNonLinearLeastSquares() AdaoExchangeLayer adao; adao.init(); // For bounds, Background/Vector, Observation/Vector + adao.setFunctionCallbackInModel(&mm); Visitor2 visitorPythonObj(adao.getPythonContext()); { AutoGIL agil; @@ -277,6 +280,7 @@ void AdaoExchangeTest::testCasCrue() AdaoExchangeLayer adao; adao.init(); // For bounds, Background/Vector, Observation/Vector + adao.setFunctionCallbackInModel(&mm); VisitorCruePython visitorPythonObj(adao.getPythonContext()); { AutoGIL agil;