]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
PR: corrections from A. Geay
authorprascle <prascle>
Wed, 2 Nov 2005 15:55:32 +0000 (15:55 +0000)
committerprascle <prascle>
Wed, 2 Nov 2005 15:55:32 +0000 (15:55 +0000)
src/Communication/Makefile.in
src/Communication/MultiCommException.hxx
src/Communication/SALOMEMultiComm.hxx
src/Communication/SenderFactory.hxx
src/Communication_SWIG/Makefile.in [new file with mode: 0644]
src/Communication_SWIG/libSALOME_Comm.i [new file with mode: 0644]
src/MPIContainer/Makefile.in
src/Makefile.in
src/TestMPIContainer/Makefile.in

index e859ea4fbaaa666d6b44317ca895274f9b2e60c4..15886f867d404847ed760c8af01b474237a789d7 100644 (file)
@@ -13,7 +13,9 @@ EXPORT_HEADERS = \
        ReceiverFactory.hxx \
        SenderFactory.hxx \
        SALOMEMultiComm.hxx \
-       MultiCommException.hxx
+       MultiCommException.hxx \
+       SALOME_Comm_i.hxx
+
 # Libraries targets
 
 LIB = libSalomeCommunication.la 
index 6313ab5e43e23c3cb3742a43e96f71d516f7884a..fe029fc4a17832dd4f56ef280c4d7dee8a448362 100644 (file)
@@ -3,13 +3,8 @@
 
 #include <string>
 
-#if defined WNT && defined COMMUNICATION_EXPORTS
-#define COMMUNICATION_EXPORT __declspec( dllexport )
-#else
-#define COMMUNICATION_EXPORT
-#endif
 
-class COMMUNICATION_EXPORT MultiCommException {
+class MultiCommException {
 private:
   std::string _message;
 public:
index 8c46251af175d281086b2f61a15b52349bbe47bb..2537dc042b3b3487a62faac8e399d8cd790e4fc8 100644 (file)
@@ -4,17 +4,11 @@
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOME_Comm)
 
-#if defined WNT && defined COMMUNICATION_EXPORTS
-#define COMMUNICATION_EXPORT __declspec( dllexport )
-#else
-#define COMMUNICATION_EXPORT
-#endif
-
 /*!
   Class is designed to ease the use of multi communication.\n
   Simply inherite from it your servant class you want to emit data with senders.
  */
-class COMMUNICATION_EXPORT SALOMEMultiComm : public virtual POA_SALOME::MultiCommClass {
+class SALOMEMultiComm : public virtual POA_SALOME::MultiCommClass {
 protected:
   SALOME::TypeOfCommunication _type;
 public:
index 39edaa3a11f70d6d8322b008f6f5768e1d97216e..ce3a0ad9130ab7a0133cc445b22f3047d5f05e90 100644 (file)
@@ -5,12 +5,6 @@
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOME_Comm)
 
-#if defined WNT && defined COMMUNICATION_EXPORTS
-#define COMMUNICATION_EXPORT __declspec( dllexport )
-#else
-#define COMMUNICATION_EXPORT
-#endif
-
 class SALOMEMultiComm;
 
 class SALOME_SenderDouble_i;
@@ -19,7 +13,7 @@ class SALOME_SenderInt_i;
 /*!
   This class implements the factory pattern of GoF by making a sender by giving an array and a communicator.It completely hides the type of sender from the user.
  */
-class COMMUNICATION_EXPORT SenderFactory
+class SenderFactory
 {
 public:
   static SALOME::SenderDouble_ptr buildSender(SALOMEMultiComm &multiCommunicator,const double *tab,long lgr,bool ownTab=false) throw(MultiCommException);
diff --git a/src/Communication_SWIG/Makefile.in b/src/Communication_SWIG/Makefile.in
new file mode 100644 (file)
index 0000000..5b0c6c1
--- /dev/null
@@ -0,0 +1,24 @@
+
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+@COMMENCE@
+
+# header files 
+EXPORT_HEADERS= libSALOME_Comm.i
+
+# Libraries targets
+
+LIB = libSALOME_Commcmodule.la
+LIB_SERVER_IDL = SALOME_Exception.idl
+
+SWIG_DEF = libSALOME_Comm.i
+EXPORT_PYSCRIPTS = libSALOME_Comm.py 
+
+CPPFLAGS+=$(PYTHON_INCLUDES) -I$(top_srcdir)/src/Communication/src
+LIBS+= $(PYTHON_LIBS)
+LDFLAGS+= -lSalomeCommunication
+
+@CONCLUDE@
diff --git a/src/Communication_SWIG/libSALOME_Comm.i b/src/Communication_SWIG/libSALOME_Comm.i
new file mode 100644 (file)
index 0000000..42d4d5a
--- /dev/null
@@ -0,0 +1,119 @@
+%module libSALOME_Comm
+
+%{
+  #include "ReceiverFactory.hxx"
+  #include "SALOME_Comm_i.hxx"
+%}
+
+%typemap(python,in) SALOME::SenderDouble_ptr
+{
+  PyObject* pdict = PyDict_New();
+  PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+  PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+  PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+                   pdict, pdict);
+  PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+  // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
+
+  PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+  if (iorSupport == Py_None)
+    return NULL;
+  char * s = PyString_AsString(PyObject_Str(iorSupport));
+  // Ask omniORB to convert IOR string to SALOME::SenderDouble_ptr
+
+  int argc = 0;
+  char *xargv = "";
+  char **argv = &xargv;
+  CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+  CORBA::Object_var O =  ORB->string_to_object(s);
+  SALOME::SenderDouble_ptr t = SALOME::SenderDouble::_narrow(O);
+  $1 = t;
+}
+
+%typemap(python,in) SALOME::SenderInt_ptr
+{
+  PyObject* pdict = PyDict_New();
+  PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
+  PyRun_String("import CORBA", Py_single_input, pdict, pdict);
+  PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
+                   pdict, pdict);
+  PyObject* orb = PyDict_GetItemString(pdict, "o");
+
+  // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
+
+  PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+  if (iorSupport == Py_None)
+    return NULL;
+  char * s = PyString_AsString(PyObject_Str(iorSupport));
+  // Ask omniORB to convert IOR string to SALOME::SenderInt_ptr
+
+  int argc = 0;
+  char *xargv = "";
+  char **argv = &xargv;
+  CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
+  CORBA::Object_var O =  ORB->string_to_object(s);
+  SALOME::SenderInt_ptr t = SALOME::SenderInt::_narrow(O);
+  $1 = t;
+}
+
+PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble);
+
+%{
+PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble)
+{
+  PyObject *py_list;
+  long size;
+  double *ret=ReceiverFactory::getValue(senderDouble,size);
+  py_list = PyList_New(size);
+  for (int i=0; i < size; i++)
+    {
+            int err = PyList_SetItem(py_list, i, Py_BuildValue("d", (double) ret[i]));
+            if(err)
+              {
+                char * message = "Error in SUPPORT::getTypes";
+                PyErr_SetString(PyExc_RuntimeError, message);
+                return NULL;
+              }
+    }
+  PyObject * result = Py_BuildValue("O", py_list);
+  delete [] ret;
+  Py_DECREF(py_list);
+  return result;
+}
+%}
+
+
+PyObject * getValueForSenderInt(SALOME::SenderInt_ptr senderInt);
+
+%{
+PyObject * getValueForSenderInt(SALOME::SenderInt_ptr senderInt)
+{
+  PyObject *py_list;
+  long size;
+  int *ret=ReceiverFactory::getValue(senderInt,size);
+  py_list = PyList_New(size);
+  for (int i=0; i < size; i++)
+    {
+            int err = PyList_SetItem(py_list, i, Py_BuildValue("i", (int) ret[i]));
+            if(err)
+              {
+                char * message = "Error in SUPPORT::getTypes";
+                PyErr_SetString(PyExc_RuntimeError, message);
+                return NULL;
+              }
+    }
+  PyObject * result = Py_BuildValue("O", py_list);
+  delete [] ret;
+  Py_DECREF(py_list);
+  return result;
+}
+%}
index 6aa39f7ce08ef9a8651b180695877b84ea61e810..808e9a42287f0257372ed30452ca5f8426848a63 100644 (file)
@@ -50,7 +50,7 @@ LIB_SERVER_IDL = SALOME_MPIObject.idl SALOME_MPIContainer.idl
 # Executables targets
 BIN = SALOME_MPIContainer
 BIN_SRC = 
-BIN_SERVER_IDL = SALOME_MPIObject.idl SALOME_MPIContainer.idl
+BIN_SERVER_IDL = SALOME_MPIObject.idl SALOME_MPIContainer.idl SALOME_Exception.idl
 
 CPPFLAGS+= $(PYTHON_INCLUDES) 
 LDFLAGS+= -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace -lSalomeResourcesManager
@@ -59,7 +59,7 @@ ifeq (@WITHMPI@,yes)
   LIBS += $(PYTHON_LIBS) $(MPI_LIBS)
   CXXFLAGS+=${MPI_INCLUDES}
   CXX_DEPEND_FLAG+=${MPI_INCLUDES}
-  LDFLAGSFORBIN= $(LDFLAGS)
+  LDFLAGSFORBIN= $(LDFLAGS) -lSALOMEBasics 
   LIBSFORBIN= $(LIBS)
 endif
 
index 66f59141333f1ff8eb4e71c1fdeb651b4868e780..2830eaca5a5eaaeb2ce194f3f19c0f660e184181 100644 (file)
@@ -59,7 +59,8 @@ SUBDIRS = \
  SALOMEDS \
  KERNEL_PY \
  ModuleGenerator \
- Communication 
+ Communication \
+ Communication_SWIG
 
 ifeq (@mpi_ok@,yes)
   SUBDIRS+= MPIContainer TestMPIContainer
index 451d9d20f912790be42294b205bd19b3aff3b34e..000d291af4a5591b12df5aef0d4d380be20f5c70 100644 (file)
@@ -28,10 +28,10 @@ LIB_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_TestMPIComponent.idl SAL
 # Executables targets
 BIN = TestMPIContainer
 BIN_SRC = 
-BIN_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_MPIContainer.idl SALOME_TestMPIComponent.idl
+BIN_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_MPIContainer.idl SALOME_TestMPIComponent.idl SALOME_Exception.idl
 BIN_SERVER_IDL = 
 
-LDFLAGSFORBIN+= -lSalomeNotification -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace  -lSalomeResourcesManager ${MPI_LIBS}
+LDFLAGSFORBIN+= -lSalomeNotification -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace -lSALOMEBasics -lSalomeResourcesManager ${MPI_LIBS}
 
 CXXFLAGS+=${MPI_INCLUDES}
 CXX_DEPEND_FLAG+=${MPI_INCLUDES}