From: Anthony Geay Date: Mon, 21 Jun 2021 19:55:21 +0000 (+0200) Subject: Agressive windows porting X-Git-Tag: V9_8_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a10935cb0a6a2dd8e269c1ceece262cfbfeecfb;p=tools%2Fydefx.git Agressive windows porting --- diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 9f80265..1d82cf2 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -47,6 +47,7 @@ SET(ydefx_HEADERS Launcher.hxx PyStudyJob.hxx TPyStudyJob.hxx + ydefxExports.hxx ) SET(ydefx_LINK diff --git a/src/cpp/Exceptions.hxx b/src/cpp/Exceptions.hxx index 0c832e3..3ed0260 100644 --- a/src/cpp/Exceptions.hxx +++ b/src/cpp/Exceptions.hxx @@ -18,11 +18,12 @@ // #ifndef YDEFX_EXCEPTIONS_HXX #define YDEFX_EXCEPTIONS_HXX +#include "ydefxExports.hxx" #include namespace ydefx { -class Exception:public std::exception +class YDEFX_EXPORT Exception:public std::exception { public: Exception(const std::string& message); diff --git a/src/cpp/Job.hxx b/src/cpp/Job.hxx index 86cae67..57007d0 100644 --- a/src/cpp/Job.hxx +++ b/src/cpp/Job.hxx @@ -18,12 +18,13 @@ // #ifndef YDEFX_JOB_H #define YDEFX_JOB_H +#include "ydefxExports.hxx" #include namespace ydefx { -class Job +class YDEFX_EXPORT Job { public: virtual ~Job(){} diff --git a/src/cpp/JobParametersProxy.hxx b/src/cpp/JobParametersProxy.hxx index aa95cae..f8a9069 100644 --- a/src/cpp/JobParametersProxy.hxx +++ b/src/cpp/JobParametersProxy.hxx @@ -18,6 +18,7 @@ // #ifndef YDEFX_JOBPARAMETERSPROXY_H #define YDEFX_JOBPARAMETERSPROXY_H +#include "ydefxExports.hxx" #include #include #include @@ -25,7 +26,7 @@ namespace ydefx { -class JobParametersProxy +class YDEFX_EXPORT JobParametersProxy { public: JobParametersProxy(); diff --git a/src/cpp/Launcher.hxx b/src/cpp/Launcher.hxx index 78492c3..c2d241c 100644 --- a/src/cpp/Launcher.hxx +++ b/src/cpp/Launcher.hxx @@ -19,13 +19,14 @@ #ifndef YDEFX_LAUNCHER_H #define YDEFX_LAUNCHER_H +#include "ydefxExports.hxx" #include "TMonoPyJob.hxx" #include "TPyStudyJob.hxx" namespace ydefx { class Job; -class Launcher +class YDEFX_EXPORT Launcher { public: Launcher():_lastError(){} diff --git a/src/cpp/MonoPyJob.hxx b/src/cpp/MonoPyJob.hxx index 5f011e6..9f4e7ab 100644 --- a/src/cpp/MonoPyJob.hxx +++ b/src/cpp/MonoPyJob.hxx @@ -18,12 +18,13 @@ // #ifndef YDEFX_MONOPYJOB_HXX #define YDEFX_MONOPYJOB_HXX +#include "ydefxExports.hxx" #include "Job.hxx" #include namespace ydefx { -class MonoPyJob : public Job +class YDEFX_EXPORT MonoPyJob : public Job { public: MonoPyJob(); diff --git a/src/cpp/PyConversions.hxx b/src/cpp/PyConversions.hxx index a540218..493de23 100644 --- a/src/cpp/PyConversions.hxx +++ b/src/cpp/PyConversions.hxx @@ -18,6 +18,7 @@ // #ifndef YDEFX_PYCONVERSIONS_HXX #define YDEFX_PYCONVERSIONS_HXX +#include "ydefxExports.hxx" #include namespace ydefx @@ -27,8 +28,8 @@ class PyStudyFunction; } namespace py2cpp { -PyObject * toPy(const ydefx::JobParametersProxy& jp); -PyObject * toPy(const ydefx::PyStudyFunction& jp); +YDEFX_EXPORT PyObject * toPy(const ydefx::JobParametersProxy& jp); +YDEFX_EXPORT PyObject * toPy(const ydefx::PyStudyFunction& jp); } #include diff --git a/src/cpp/PyStudyFunction.hxx b/src/cpp/PyStudyFunction.hxx index 9860ce1..17ae27d 100644 --- a/src/cpp/PyStudyFunction.hxx +++ b/src/cpp/PyStudyFunction.hxx @@ -18,12 +18,13 @@ // #ifndef YDEFX_PYSTUDYFUNCTION_H #define YDEFX_PYSTUDYFUNCTION_H +#include "ydefxExports.hxx" #include "StudyFunction.hxx" #include "PyConversions.hxx" namespace ydefx { -class PyStudyFunction : StudyFunction +class YDEFX_EXPORT PyStudyFunction : StudyFunction { public: PyStudyFunction(); diff --git a/src/cpp/PyStudyJob.hxx b/src/cpp/PyStudyJob.hxx index 25863ef..9833095 100644 --- a/src/cpp/PyStudyJob.hxx +++ b/src/cpp/PyStudyJob.hxx @@ -18,12 +18,13 @@ // #ifndef YDEFX_PYSTUDYJOB_HXX #define YDEFX_PYSTUDYJOB_HXX +#include "ydefxExports.hxx" #include "Job.hxx" #include namespace ydefx { -class PyStudyJob : public Job +class YDEFX_EXPORT PyStudyJob : public Job { public: PyStudyJob(const std::string& pymodule_name, const std::string& pyclass_name); diff --git a/src/cpp/Sample.hxx b/src/cpp/Sample.hxx index 292150b..8c70b87 100644 --- a/src/cpp/Sample.hxx +++ b/src/cpp/Sample.hxx @@ -19,6 +19,7 @@ #ifndef YDEFX_SAMPLE_H #define YDEFX_SAMPLE_H +#include "ydefxExports.hxx" #include #include #include @@ -28,7 +29,7 @@ namespace ydefx { template -class VariablesGroup +class YDEFX_EXPORT VariablesGroup { public: VariablesGroup(); @@ -58,10 +59,10 @@ private: T _defaultValue; }; -enum class ExecutionState {NOTEXECUTED, DONE, ERROR}; +enum class YDEFX_EXPORT ExecutionState {NOTEXECUTED, DONE, ERROR}; template -class OneTypeSample +class YDEFX_EXPORT OneTypeSample { public: const VariablesGroup& inputs()const; @@ -80,7 +81,7 @@ template class Sample; // no type sample template <> -class Sample<> +class YDEFX_EXPORT Sample<> { public: const std::vector& errors()const{return _errors;} @@ -128,7 +129,7 @@ private: // multi type sample template -class Sample : public OneTypeSample, public Sample +class YDEFX_EXPORT Sample : public OneTypeSample, public Sample { public: virtual ExecutionState pointState(int index); diff --git a/src/cpp/SamplePyConversions.hxx b/src/cpp/SamplePyConversions.hxx index 1e70e9c..b720bbd 100644 --- a/src/cpp/SamplePyConversions.hxx +++ b/src/cpp/SamplePyConversions.hxx @@ -19,6 +19,7 @@ #ifndef YDEFX_SAMPLEPYCONVERSIONS_HXX #define YDEFX_SAMPLEPYCONVERSIONS_HXX +#include "ydefxExports.hxx" #include #include "Sample.hxx" #include "Exceptions.hxx" @@ -33,7 +34,7 @@ namespace ydefx * list of sample types. */ template -class SamplePyConverter; +YDEFX_EXPORT class SamplePyConverter; /*! * Convert input variables of a sample to a python dictionary. @@ -41,7 +42,7 @@ class SamplePyConverter; * The returned value is NULL in case of error. */ template -PyObject* inputToPy(const Sample& sample); +YDEFX_EXPORT PyObject* inputToPy(const Sample& sample); /*! * Fill the input values of the sample from a python dictionary. @@ -53,7 +54,7 @@ PyObject* inputToPy(const Sample& sample); * Keys from the python dictionary that do not exist in the sample are ignored. */ template -py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample& sample); +YDEFX_EXPORT py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample& sample); /*! * Convert output variables of a sample to a python dictionary. @@ -64,7 +65,7 @@ py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample& sample); * The returned value is NULL in case of error. */ template -PyObject* outputToPy(const Sample& sample); +YDEFX_EXPORT PyObject* outputToPy(const Sample& sample); /*! * Fill the output values of a sample from a python dictionary. @@ -75,7 +76,7 @@ PyObject* outputToPy(const Sample& sample); * ignored. */ template -py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample& sample); +YDEFX_EXPORT py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample& sample); /*! * Fill the error values of a sample from a python list of strings. @@ -83,7 +84,7 @@ py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample& sample); * strings. */ template -py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample& sample); +YDEFX_EXPORT py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample& sample); /*! * A python sample object is created and it contains input and output names of @@ -91,7 +92,7 @@ py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample& sample); * not copied. */ template -py2cpp::PyPtr createPySample(const Sample& sample); +YDEFX_EXPORT py2cpp::PyPtr createPySample(const Sample& sample); /*! * Fetch output values and errors from the python objet. @@ -99,14 +100,14 @@ py2cpp::PyPtr createPySample(const Sample& sample); * function is called. */ template -py2cpp::ConversionCheck fetchResults(PyObject* obj, Sample& sample); +YDEFX_EXPORT py2cpp::ConversionCheck fetchResults(PyObject* obj, Sample& sample); //////////////////////////////////////////////////////////////////////////////// // Template implementations //////////////////////////////////////////////////////////////////////////////// template -class SamplePyConverter +class YDEFX_EXPORT SamplePyConverter { public: bool inputToPy(const S& sample, PyObject* result){return true;} @@ -118,7 +119,7 @@ public: }; template -class SamplePyConverter : public SamplePyConverter +class YDEFX_EXPORT SamplePyConverter : public SamplePyConverter { public: /*! Add sample.inputs to result. @@ -141,7 +142,7 @@ public: return ok; } - py2cpp::ConversionCheck inputFromPy(PyObject* obj, S& sample) + YDEFX_EXPORT py2cpp::ConversionCheck inputFromPy(PyObject* obj, S& sample) { py2cpp::ConversionCheck check; std::list names = sample.OneTypeSample::inputs().names(); @@ -181,7 +182,7 @@ public: return check; } - bool outputToPy(const S& sample, PyObject* result) + YDEFX_EXPORT bool outputToPy(const S& sample, PyObject* result) { bool ok = true; std::size_t maxsize = sample.maxSize(); @@ -217,7 +218,7 @@ public: return ok; } - py2cpp::ConversionCheck outputFromPy(PyObject* obj, S& sample) + YDEFX_EXPORT py2cpp::ConversionCheck outputFromPy(PyObject* obj, S& sample) { py2cpp::ConversionCheck check; std::list names = sample.OneTypeSample::outputs().names(); @@ -266,7 +267,7 @@ public: }; template -PyObject* inputToPy(const Sample& sample) +YDEFX_EXPORT PyObject* inputToPy(const Sample& sample) { PyObject * result = PyDict_New(); if(result) @@ -283,7 +284,7 @@ PyObject* inputToPy(const Sample& sample) } template -py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample& sample) +YDEFX_EXPORT py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample& sample) { py2cpp::ConversionCheck check; if(PyDict_Check(obj)) @@ -299,7 +300,7 @@ py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample& sample) } template -PyObject* outputToPy(const Sample& sample) +YDEFX_EXPORT PyObject* outputToPy(const Sample& sample) { PyObject * result = PyDict_New(); if(result) @@ -315,7 +316,7 @@ PyObject* outputToPy(const Sample& sample) } template -py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample& sample) +YDEFX_EXPORT py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample& sample) { py2cpp::ConversionCheck check; if(PyDict_Check(obj)) @@ -330,7 +331,7 @@ py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample& sample) } template -py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample& sample) +YDEFX_EXPORT py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample& sample) { py2cpp::ConversionCheck check; if(PyList_Check(obj)) @@ -355,7 +356,7 @@ py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample& sample) } template -py2cpp::PyPtr createPySample(const Sample& sample) +YDEFX_EXPORT py2cpp::PyPtr createPySample(const Sample& sample) { py2cpp::PyFunction sampleConstructor; sampleConstructor.loadExp("pydefx", "Sample"); @@ -370,7 +371,7 @@ py2cpp::PyPtr createPySample(const Sample& sample) } template -py2cpp::ConversionCheck fetchResults(const py2cpp::PyPtr& obj, Sample& sample) +YDEFX_EXPORT py2cpp::ConversionCheck fetchResults(const py2cpp::PyPtr& obj, Sample& sample) { py2cpp::ConversionCheck check; check.addError(outputFromPy(obj.getAttr("_output").get(), sample)); diff --git a/src/cpp/StudyFunction.hxx b/src/cpp/StudyFunction.hxx index 6816165..0486dfb 100644 --- a/src/cpp/StudyFunction.hxx +++ b/src/cpp/StudyFunction.hxx @@ -18,12 +18,13 @@ // #ifndef YDEFX_STUDYFUNCTION_H #define YDEFX_STUDYFUNCTION_H +#include "ydefxExports.hxx" #include #include namespace ydefx { -class StudyFunction +class YDEFX_EXPORT StudyFunction { public: virtual ~StudyFunction(){} diff --git a/src/cpp/TMonoPyJob.hxx b/src/cpp/TMonoPyJob.hxx index 426d951..54753d8 100644 --- a/src/cpp/TMonoPyJob.hxx +++ b/src/cpp/TMonoPyJob.hxx @@ -18,6 +18,7 @@ // #ifndef YDEFX_TMONOPYJOB_HXX #define YDEFX_TMONOPYJOB_HXX +#include "ydefxExports.hxx" #include "JobParametersProxy.hxx" #include "MonoPyJob.hxx" #include "SamplePyConversions.hxx" @@ -26,7 +27,7 @@ namespace ydefx { template -class TMonoPyJob : public MonoPyJob +class YDEFX_EXPORT TMonoPyJob : public MonoPyJob { public: //! Create a new job. diff --git a/src/cpp/TPyStudyJob.hxx b/src/cpp/TPyStudyJob.hxx index ba277eb..02e3e80 100644 --- a/src/cpp/TPyStudyJob.hxx +++ b/src/cpp/TPyStudyJob.hxx @@ -18,6 +18,7 @@ // #ifndef YDEFX_TPYSTUDYJOB_HXX #define YDEFX_TPYSTUDYJOB_HXX +#include "ydefxExports.hxx" #include "JobParametersProxy.hxx" #include "PyStudyJob.hxx" #include "SamplePyConversions.hxx" @@ -26,7 +27,7 @@ namespace ydefx { template -class TPyStudyJob : public PyStudyJob +class YDEFX_EXPORT TPyStudyJob : public PyStudyJob { public: //! Create a new job using the default pystudy class. diff --git a/src/cpp/YacsStudyFunction.hxx b/src/cpp/YacsStudyFunction.hxx index 58fd954..39389a0 100644 --- a/src/cpp/YacsStudyFunction.hxx +++ b/src/cpp/YacsStudyFunction.hxx @@ -18,11 +18,12 @@ // #ifndef YDEFX_YACSSTUDYFUNCTION_H #define YDEFX_YACSSTUDYFUNCTION_H +#include "ydefxExports.hxx" #include "StudyFunction.hxx" namespace ydefx { //TODO not implemented! -class YacsStudyFunction : StudyFunction +class YDEFX_EXPORT YacsStudyFunction : StudyFunction { public: YacsStudyFunction(); diff --git a/src/cpp/ydefxExports.hxx b/src/cpp/ydefxExports.hxx new file mode 100644 index 0000000..0ccfaa7 --- /dev/null +++ b/src/cpp/ydefxExports.hxx @@ -0,0 +1,30 @@ +// Copyright (C) 2021 EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#pragma once + +#ifdef WIN32 +# if defined(ydefx_EXPORTS) || defined(ydefx_EXPORTS) +# define YDEFX_EXPORT __declspec( dllexport ) +# else +# define YDEFX_EXPORT __declspec( dllimport ) +# endif +#else +# define YDEFX_EXPORT +#endif