From 903d822879ba1479f5d8a68579f6a02090a07475 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 12 Jul 2019 16:30:14 +0200 Subject: [PATCH] Ready pour l export --- ...Layer4Quintet.cxx => AdaoExchangeLayer.cxx | 28 +++++++++---------- ...Layer4Quintet.hxx => AdaoExchangeLayer.hxx | 6 ++-- CMakeLists.txt | 6 ++-- TestAdaoExchange.cxx | 10 +++---- 4 files changed, 25 insertions(+), 25 deletions(-) rename AdaoExchangeLayer4Quintet.cxx => AdaoExchangeLayer.cxx (94%) rename AdaoExchangeLayer4Quintet.hxx => AdaoExchangeLayer.hxx (93%) diff --git a/AdaoExchangeLayer4Quintet.cxx b/AdaoExchangeLayer.cxx similarity index 94% rename from AdaoExchangeLayer4Quintet.cxx rename to AdaoExchangeLayer.cxx index 4b82af4..9a101a4 100644 --- a/AdaoExchangeLayer4Quintet.cxx +++ b/AdaoExchangeLayer.cxx @@ -18,7 +18,7 @@ // // Author: Anthony Geay, anthony.geay@edf.fr, EDF R&D -#include "AdaoExchangeLayer4Quintet.hxx" +#include "AdaoExchangeLayer.hxx" #include "AdaoExchangeLayerException.hxx" #include "AdaoModelKeyVal.hxx" #include "PyObjectRAII.hxx" @@ -164,7 +164,7 @@ private: AdaoCallbackSt *_pt = nullptr; }; -class AdaoExchangeLayer4Quintet::Internal +class AdaoExchangeLayer::Internal { public: Internal():_context(PyObjectRAII::FromNew(PyDict_New())) @@ -206,32 +206,32 @@ void FreeWChar(int argc, wchar_t **tab) delete [] tab; } -AdaoExchangeLayer4Quintet::AdaoExchangeLayer4Quintet() +AdaoExchangeLayer::AdaoExchangeLayer() { } -AdaoExchangeLayer4Quintet::~AdaoExchangeLayer4Quintet() +AdaoExchangeLayer::~AdaoExchangeLayer() { delete _internal; } -void AdaoExchangeLayer4Quintet::init() +void AdaoExchangeLayer::init() { initPythonIfNeeded(); } -PyObject *AdaoExchangeLayer4Quintet::getPythonContext() const +PyObject *AdaoExchangeLayer::getPythonContext() const { if(!_internal) throw AdaoExchangeLayerException("getPythonContext : not initialized !"); return _internal->_context; } -void AdaoExchangeLayer4Quintet::initPythonIfNeeded() +void AdaoExchangeLayer::initPythonIfNeeded() { if (!Py_IsInitialized()) { - const char *TAB[]={"AdaoExchangeLayer4Quintet"}; + const char *TAB[]={"AdaoExchangeLayer"}; wchar_t **TABW(ConvertToWChar(1,TAB)); // Python is not initialized Py_SetProgramName(const_cast(TABW[0])); @@ -278,7 +278,7 @@ private: PyObject *_context = nullptr; }; -void AdaoExchangeLayer4Quintet::loadTemplate(AdaoModel::MainModel *model) +void AdaoExchangeLayer::loadTemplate(AdaoModel::MainModel *model) { const char DECORATOR_FUNC[]="def DecoratorAdao(cppFunc):\n" " def evaluator( xserie ):\n" @@ -330,13 +330,13 @@ void ExecuteAsync(PyObject *pyExecuteFunction, DataExchangedBetweenThreads *data sem_post(&data->_sem); } -void AdaoExchangeLayer4Quintet::execute() +void AdaoExchangeLayer::execute() { - _internal->_tstate=PyEval_SaveThread(); // release the lock acquired in AdaoExchangeLayer4Quintet::initPythonIfNeeded by PyEval_InitThreads() + _internal->_tstate=PyEval_SaveThread(); // release the lock acquired in AdaoExchangeLayer::initPythonIfNeeded by PyEval_InitThreads() _internal->_fut = std::async(std::launch::async,ExecuteAsync,_internal->_execute_func,&_internal->_data_btw_threads); } -bool AdaoExchangeLayer4Quintet::next(PyObject *& inputRequested) +bool AdaoExchangeLayer::next(PyObject *& inputRequested) { sem_wait(&_internal->_data_btw_threads._sem); if(_internal->_data_btw_threads._finished) @@ -351,14 +351,14 @@ bool AdaoExchangeLayer4Quintet::next(PyObject *& inputRequested) } } -void AdaoExchangeLayer4Quintet::setResult(PyObject *outputAssociated) +void AdaoExchangeLayer::setResult(PyObject *outputAssociated) { _internal->_data_btw_threads._data = outputAssociated; _internal->_data_btw_threads._finished = false; sem_post(&_internal->_data_btw_threads._sem_result_is_here); } -PyObject *AdaoExchangeLayer4Quintet::getResult() +PyObject *AdaoExchangeLayer::getResult() { _internal->_fut.wait(); PyEval_RestoreThread(_internal->_tstate); diff --git a/AdaoExchangeLayer4Quintet.hxx b/AdaoExchangeLayer.hxx similarity index 93% rename from AdaoExchangeLayer4Quintet.hxx rename to AdaoExchangeLayer.hxx index 0ef1405..dbb3dba 100644 --- a/AdaoExchangeLayer4Quintet.hxx +++ b/AdaoExchangeLayer.hxx @@ -29,12 +29,12 @@ namespace AdaoModel class MainModel; } -class AdaoExchangeLayer4Quintet +class AdaoExchangeLayer { class Internal; public: - AdaoExchangeLayer4Quintet(); - ~AdaoExchangeLayer4Quintet(); + AdaoExchangeLayer(); + ~AdaoExchangeLayer(); PyObject *getPythonContext() const; void init(); void loadTemplate(AdaoModel::MainModel *model); diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b6d503..8a07675 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ # Author: Anthony Geay, anthony.geay@edf.fr, EDF R&D cmake_minimum_required(VERSION 2.6) -project(AdaoExchangeLayer4Quintet) +project(AdaoExchangeLayer) ## @@ -61,10 +61,10 @@ include_directories( ${PY2CPP_INCLUDE_DIR} ${CPPUNIT_INCLUDE_DIRS} ) -set(adaoexchange_SOURCES AdaoExchangeLayer4Quintet.cxx AdaoModelKeyVal.cxx) +set(adaoexchange_SOURCES AdaoExchangeLayer.cxx AdaoModelKeyVal.cxx) add_library(adaoexchange ${adaoexchange_SOURCES}) target_link_libraries(adaoexchange ${PYTHON_LIBRARIES}) -install(FILES AdaoExchangeLayer4Quintet.hxx PyObjectRAII.hxx AdaoExchangeLayerException.hxx AdaoModelKeyVal.hxx DESTINATION include) +install(FILES AdaoExchangeLayer.hxx PyObjectRAII.hxx AdaoExchangeLayerException.hxx AdaoModelKeyVal.hxx DESTINATION include) install(TARGETS adaoexchange DESTINATION lib) ## diff --git a/TestAdaoExchange.cxx b/TestAdaoExchange.cxx index 803cbc1..f0d7150 100644 --- a/TestAdaoExchange.cxx +++ b/TestAdaoExchange.cxx @@ -20,7 +20,7 @@ #include "TestAdaoExchange.hxx" -#include "AdaoExchangeLayer4Quintet.hxx" +#include "AdaoExchangeLayer.hxx" #include "AdaoExchangeLayerException.hxx" #include "AdaoModelKeyVal.hxx" #include "PyObjectRAII.hxx" @@ -121,7 +121,7 @@ void AdaoExchangeTest::test3DVar() { NonParallelFunctor functor(funcBase); MainModel mm; - AdaoExchangeLayer4Quintet adao; + AdaoExchangeLayer adao; adao.init(); // For bounds, Background/Vector, Observation/Vector Visitor2 visitorPythonObj(adao.getPythonContext()); @@ -175,7 +175,7 @@ void AdaoExchangeTest::testBlue() TestBlueVisitor vis; mm.visitAll(&vis); // - AdaoExchangeLayer4Quintet adao; + AdaoExchangeLayer adao; adao.init(); // For bounds, Background/Vector, Observation/Vector Visitor2 visitorPythonObj(adao.getPythonContext()); @@ -228,7 +228,7 @@ void AdaoExchangeTest::testNonLinearLeastSquares() TestNonLinearLeastSquaresVisitor vis; mm.visitAll(&vis); // - AdaoExchangeLayer4Quintet adao; + AdaoExchangeLayer adao; adao.init(); // For bounds, Background/Vector, Observation/Vector Visitor2 visitorPythonObj(adao.getPythonContext()); @@ -265,7 +265,7 @@ void AdaoExchangeTest::testCasCrue() { NonParallelFunctor functor(funcCrue); MainModel mm; - AdaoExchangeLayer4Quintet adao; + AdaoExchangeLayer adao; adao.init(); // For bounds, Background/Vector, Observation/Vector VisitorCruePython visitorPythonObj(adao.getPythonContext()); -- 2.39.2