Salome HOME
Agressive windows porting
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 21 Jun 2021 19:55:21 +0000 (21:55 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 21 Jun 2021 19:55:21 +0000 (21:55 +0200)
16 files changed:
src/cpp/CMakeLists.txt
src/cpp/Exceptions.hxx
src/cpp/Job.hxx
src/cpp/JobParametersProxy.hxx
src/cpp/Launcher.hxx
src/cpp/MonoPyJob.hxx
src/cpp/PyConversions.hxx
src/cpp/PyStudyFunction.hxx
src/cpp/PyStudyJob.hxx
src/cpp/Sample.hxx
src/cpp/SamplePyConversions.hxx
src/cpp/StudyFunction.hxx
src/cpp/TMonoPyJob.hxx
src/cpp/TPyStudyJob.hxx
src/cpp/YacsStudyFunction.hxx
src/cpp/ydefxExports.hxx [new file with mode: 0644]

index 9f802656e56ea6a60b3a6b34c1fa07c9f7f7d8cd..1d82cf2b2082e1d0dd7ddc85ffd7d8e15668fcc1 100644 (file)
@@ -47,6 +47,7 @@ SET(ydefx_HEADERS
   Launcher.hxx
   PyStudyJob.hxx
   TPyStudyJob.hxx
+  ydefxExports.hxx
 )
 
 SET(ydefx_LINK
index 0c832e34d401f5541f482b734a7f0bdba5785733..3ed0260518f8ba96ddcf75bc0b833ae4d8c4df5b 100644 (file)
 //
 #ifndef YDEFX_EXCEPTIONS_HXX
 #define YDEFX_EXCEPTIONS_HXX
+#include "ydefxExports.hxx"
 #include <string>
 
 namespace ydefx
 {
-class Exception:public std::exception
+class YDEFX_EXPORT Exception:public std::exception
 {
 public:
   Exception(const std::string& message);
index 86cae676dd572dea0488f2535e5d621b930aa1c9..57007d0ee5f55875758f489ee4b7b53b756a202b 100644 (file)
 //
 #ifndef YDEFX_JOB_H
 #define YDEFX_JOB_H
+#include "ydefxExports.hxx"
 #include <string>
 
 namespace ydefx
 {
 
-class Job
+class YDEFX_EXPORT Job
 {
 public:
   virtual ~Job(){}
index aa95cae53a5d9407b1ff258b2d2e0d3c988649b3..f8a9069f7dff6c8607fc5504e7ed8f3f6588c899 100644 (file)
@@ -18,6 +18,7 @@
 //
 #ifndef YDEFX_JOBPARAMETERSPROXY_H
 #define YDEFX_JOBPARAMETERSPROXY_H
+#include "ydefxExports.hxx"
 #include <string>
 #include <list>
 #include <map>
@@ -25,7 +26,7 @@
 
 namespace ydefx
 {
-class JobParametersProxy
+class YDEFX_EXPORT JobParametersProxy
 {
 public:
   JobParametersProxy();
index 78492c3c054709c4ff83b41b3f31b3edb600c4fd..c2d241c9076cf31fd8833644757f18f358c34105 100644 (file)
 #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(){}
index 5f011e63bf9f6c364e6ac418271a5a386f9b62ee..9f4e7ab4677f7221dca96c6a08c999b6be98422d 100644 (file)
 //
 #ifndef YDEFX_MONOPYJOB_HXX
 #define YDEFX_MONOPYJOB_HXX
+#include "ydefxExports.hxx"
 #include "Job.hxx"
 #include <py2cpp/PyPtr.hxx>
 
 namespace ydefx
 {
-class MonoPyJob : public Job
+class YDEFX_EXPORT MonoPyJob : public Job
 {
 public:
   MonoPyJob();
index a5402189e3bb0ca4f101c58fe6690941d5efc28a..493de2368f95e5cb93ad0feed22f2b4beef8ae47 100644 (file)
@@ -18,6 +18,7 @@
 //
 #ifndef YDEFX_PYCONVERSIONS_HXX
 #define YDEFX_PYCONVERSIONS_HXX
+#include "ydefxExports.hxx"
 #include <py2cpp/PyPtr.hxx>
 
 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 <py2cpp/py2cpp.hxx>
index 9860ce16734bfb3f6fe190765b43df57c9d046d3..17ae27d06ac5643a01062c4059517073b27104d7 100644 (file)
 //
 #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();
index 25863efe5751ac2f809f7c3a7e17911540fd9230..98330951645c25c358d04468de83c7472dd75ad0 100644 (file)
 //
 #ifndef YDEFX_PYSTUDYJOB_HXX
 #define YDEFX_PYSTUDYJOB_HXX
+#include "ydefxExports.hxx"
 #include "Job.hxx"
 #include <py2cpp/PyPtr.hxx>
 
 namespace ydefx
 {
-class PyStudyJob : public Job
+class YDEFX_EXPORT PyStudyJob : public Job
 {
 public:
   PyStudyJob(const std::string& pymodule_name, const std::string& pyclass_name);
index 292150bafbf797e6d7dfcd9ce5bd09494e4f0a34..8c70b87da792740997b730d4fe85ee7c414b917b 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef YDEFX_SAMPLE_H\r
 #define YDEFX_SAMPLE_H\r
 \r
+#include "ydefxExports.hxx"\r
 #include <vector>\r
 #include <string>\r
 #include <list>\r
@@ -28,7 +29,7 @@ namespace ydefx
 {\r
 \r
 template <class T>\r
-class VariablesGroup\r
+class YDEFX_EXPORT VariablesGroup\r
 {\r
 public:\r
   VariablesGroup();\r
@@ -58,10 +59,10 @@ private:
   T _defaultValue;\r
 };\r
 \r
-enum class ExecutionState {NOTEXECUTED, DONE, ERROR};\r
+enum class YDEFX_EXPORT ExecutionState {NOTEXECUTED, DONE, ERROR};\r
 \r
 template <class T>\r
-class OneTypeSample\r
+class YDEFX_EXPORT OneTypeSample\r
 {\r
 public:\r
   const VariablesGroup<T>& inputs()const;\r
@@ -80,7 +81,7 @@ template <class... Ts> class Sample;
 \r
 // no type sample\r
 template <>\r
-class Sample<>\r
+class YDEFX_EXPORT Sample<>\r
 {\r
 public:\r
   const std::vector<std::string>& errors()const{return _errors;}\r
@@ -128,7 +129,7 @@ private:
 \r
 // multi type sample\r
 template <class T, class... Ts>\r
-class Sample<T, Ts...> : public OneTypeSample<T>, public Sample<Ts...>\r
+class YDEFX_EXPORT Sample<T, Ts...> : public OneTypeSample<T>, public Sample<Ts...>\r
 {\r
 public:\r
   virtual ExecutionState pointState(int index);\r
index 1e70e9c0e480cd378934f60185be7a50312916d1..b720bbdbaed7f0efbdfa74ebe59f17915e281bbb 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef YDEFX_SAMPLEPYCONVERSIONS_HXX
 #define YDEFX_SAMPLEPYCONVERSIONS_HXX
 
+#include "ydefxExports.hxx"
 #include <py2cpp/py2cpp.hxx>
 #include "Sample.hxx"
 #include "Exceptions.hxx"
@@ -33,7 +34,7 @@ namespace ydefx
  *      list of sample types.
  */
 template <class S, class... Ts>
-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 <class ...Ts>
-PyObject* inputToPy(const Sample<Ts...>& sample);
+YDEFX_EXPORT PyObject* inputToPy(const Sample<Ts...>& sample);
 
 /*!
  * Fill the input values of the sample from a python dictionary.
@@ -53,7 +54,7 @@ PyObject* inputToPy(const Sample<Ts...>& sample);
  * Keys from the python dictionary that do not exist in the sample are ignored.
  */
 template <class ...Ts>
-py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample<Ts...>& sample);
+YDEFX_EXPORT py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample<Ts...>& sample);
 
 /*!
  * Convert output variables of a sample to a python dictionary.
@@ -64,7 +65,7 @@ py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample<Ts...>& sample);
  * The returned value is NULL in case of error.
  */
 template <class ...Ts>
-PyObject* outputToPy(const Sample<Ts...>& sample);
+YDEFX_EXPORT PyObject* outputToPy(const Sample<Ts...>& sample);
 
 /*!
  * Fill the output values of a sample from a python dictionary.
@@ -75,7 +76,7 @@ PyObject* outputToPy(const Sample<Ts...>& sample);
  * ignored.
  */
 template <class ...Ts>
-py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample<Ts...>& sample);
+YDEFX_EXPORT py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample<Ts...>& sample);
 
 /*!
  * Fill the error values of a sample from a python list of strings.
@@ -83,7 +84,7 @@ py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample<Ts...>& sample);
  * strings.
  */
 template <class ...Ts>
-py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample<Ts...>& sample);
+YDEFX_EXPORT py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample<Ts...>& 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<Ts...>& sample);
  * not copied.
  */
 template <class ...Ts>
-py2cpp::PyPtr createPySample(const Sample<Ts...>& sample);
+YDEFX_EXPORT py2cpp::PyPtr createPySample(const Sample<Ts...>& sample);
 
 /*!
  * Fetch output values and errors from the python objet.
@@ -99,14 +100,14 @@ py2cpp::PyPtr createPySample(const Sample<Ts...>& sample);
  * function is called.
  */
 template <class ...Ts>
-py2cpp::ConversionCheck fetchResults(PyObject* obj, Sample<Ts...>& sample);
+YDEFX_EXPORT py2cpp::ConversionCheck fetchResults(PyObject* obj, Sample<Ts...>& sample);
 
 ////////////////////////////////////////////////////////////////////////////////
 // Template implementations
 ////////////////////////////////////////////////////////////////////////////////
 
 template <class S>
-class SamplePyConverter<S>
+class YDEFX_EXPORT SamplePyConverter<S>
 {
 public:
   bool inputToPy(const S& sample, PyObject* result){return true;}
@@ -118,7 +119,7 @@ public:
 };
 
 template <class S, class T, class... Ts>
-class SamplePyConverter<S,T, Ts...> : public SamplePyConverter<S, Ts...>
+class YDEFX_EXPORT SamplePyConverter<S,T, Ts...> : public SamplePyConverter<S, Ts...>
 {
 public:
   /*! Add sample.inputs<T> 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<std::string> names = sample.OneTypeSample<T>::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<std::string> names = sample.OneTypeSample<T>::outputs().names();
@@ -266,7 +267,7 @@ public:
 };
 
 template <class ...Ts>
-PyObject* inputToPy(const Sample<Ts...>& sample)
+YDEFX_EXPORT PyObject* inputToPy(const Sample<Ts...>& sample)
 {
   PyObject * result = PyDict_New();
   if(result)
@@ -283,7 +284,7 @@ PyObject* inputToPy(const Sample<Ts...>& sample)
 }
 
 template <class ...Ts>
-py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample<Ts...>& sample)
+YDEFX_EXPORT py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample<Ts...>& sample)
 {
   py2cpp::ConversionCheck check;
   if(PyDict_Check(obj))
@@ -299,7 +300,7 @@ py2cpp::ConversionCheck inputFromPy(PyObject* obj, Sample<Ts...>& sample)
 }
 
 template <class ...Ts>
-PyObject* outputToPy(const Sample<Ts...>& sample)
+YDEFX_EXPORT PyObject* outputToPy(const Sample<Ts...>& sample)
 {
   PyObject * result = PyDict_New();
   if(result)
@@ -315,7 +316,7 @@ PyObject* outputToPy(const Sample<Ts...>& sample)
 }
 
 template <class ...Ts>
-py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample<Ts...>& sample)
+YDEFX_EXPORT py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample<Ts...>& sample)
 {
   py2cpp::ConversionCheck check;
   if(PyDict_Check(obj))
@@ -330,7 +331,7 @@ py2cpp::ConversionCheck outputFromPy(PyObject* obj, Sample<Ts...>& sample)
 }
 
 template <class ...Ts>
-py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample<Ts...>& sample)
+YDEFX_EXPORT py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample<Ts...>& sample)
 {
   py2cpp::ConversionCheck check;
   if(PyList_Check(obj))
@@ -355,7 +356,7 @@ py2cpp::ConversionCheck errorsFromPy(PyObject* obj, Sample<Ts...>& sample)
 }
 
 template <class ...Ts>
-py2cpp::PyPtr createPySample(const Sample<Ts...>& sample)
+YDEFX_EXPORT py2cpp::PyPtr createPySample(const Sample<Ts...>& sample)
 {
   py2cpp::PyFunction sampleConstructor;
   sampleConstructor.loadExp("pydefx", "Sample");
@@ -370,7 +371,7 @@ py2cpp::PyPtr createPySample(const Sample<Ts...>& sample)
 }
 
 template <class ...Ts>
-py2cpp::ConversionCheck fetchResults(const py2cpp::PyPtr& obj, Sample<Ts...>& sample)
+YDEFX_EXPORT py2cpp::ConversionCheck fetchResults(const py2cpp::PyPtr& obj, Sample<Ts...>& sample)
 {
   py2cpp::ConversionCheck check;
   check.addError(outputFromPy(obj.getAttr("_output").get(), sample));
index 6816165cbfec9ae62c198d00ad3af1d2e4ac6f51..0486dfb92270fbf0d19bb884440aa3179f3da71a 100644 (file)
 //
 #ifndef YDEFX_STUDYFUNCTION_H
 #define YDEFX_STUDYFUNCTION_H
+#include "ydefxExports.hxx"
 #include <string>
 #include <list>
 
 namespace ydefx
 {
-class StudyFunction
+class YDEFX_EXPORT StudyFunction
 {
 public:
   virtual ~StudyFunction(){}
index 426d951d285f9caa735bb3401daa2fa62c30a8d6..54753d8e7ce69128d50c898c8bf820b779dfecfd 100644 (file)
@@ -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 ...Ts>
-class TMonoPyJob : public MonoPyJob
+class YDEFX_EXPORT TMonoPyJob : public MonoPyJob
 {
 public:
   //! Create a new job.
index ba277ebd95a319fafb6a08efafb8a7b34780bdb1..02e3e803a21917c5a0ceda3496e94531dcaab44e 100644 (file)
@@ -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 ...Ts>
-class TPyStudyJob : public PyStudyJob
+class YDEFX_EXPORT TPyStudyJob : public PyStudyJob
 {
 public:
   //! Create a new job using the default pystudy class.
index 58fd95499091404b02879a759e239251187f8ddc..39389a06d81e0af10e16aa762093d9119e8d8e17 100644 (file)
 //
 #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 (file)
index 0000000..0ccfaa7
--- /dev/null
@@ -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