Salome HOME
Implemented a possibility to dlopen SalomeDS libarary and create SObject, Study,...
[modules/kernel.git] / src / Communication / SALOME_Comm_i.hxx
index 7b6e8df4376315ae862cfe1980f361ea10df7150..e5e0c65ce301c708a94b56ec4be11276de1200f8 100644 (file)
@@ -1,12 +1,31 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// 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.
+// 
+// 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/
+//
 #ifndef _SALOME_COMM_I_HXX_
 #define _SALOME_COMM_I_HXX_
 
-#include <string>
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SALOME_Comm)
 #ifdef HAVE_MPI2
 #include "mpi.h"
 #endif
+#include <string>
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOME_Comm)
 
 #define TIMEOUT 20
 
@@ -26,26 +45,48 @@ protected:
     Practically in terms of bytes the size to be transmitted is _lgrTabToSend*_sizeOf
   */
   int _sizeOf;
-  /*! Type the component of the array*/
-  SALOME::TypeOfDataTransmitted _type;
+  /*! Indicates if _tabToSend has to be deallocated */ 
+  bool _ownTabToSend;
 
-  SALOME_Sender_i(SALOME::TypeOfDataTransmitted type,const void *tabToSend,long lgrTabToSend,int sizeOf);
+  SALOME_Sender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false);
 public:
   const void *getData(long &size) const;
   int getSizeOf() const;
+  void setOwnerShip(bool own);
+  bool getOwnerShip() const { return _ownTabToSend; }
   void release();
-  SALOME::TypeOfDataTransmitted getTypeOfDataTransmitted();
-  SALOME::Sender_ptr buildOtherWithProtocol(SALOME::TypeOfCommunication type);
-  static SALOME_Sender_i *find(SALOME::Sender_ptr pCorba);
+  virtual ~SALOME_Sender_i() {}
+};
+
+class SALOME_SenderDouble_i : public virtual POA_SALOME::SenderDouble,
+                             public virtual SALOME_Sender_i
+{
+public:
+  SALOME_SenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
+  SALOME::TypeOfDataTransmitted getTypeOfDataTransmitted() { return SALOME::DOUBLE_; }
+  SALOME::SenderDouble_ptr buildOtherWithProtocol(SALOME::TypeOfCommunication type);
+  virtual ~SALOME_SenderDouble_i();
+  static SALOME_SenderDouble_i *find(SALOME::SenderDouble_ptr pCorba);
+};
+
+class SALOME_SenderInt_i : public virtual POA_SALOME::SenderInt,
+                          public virtual SALOME_Sender_i
+{
+public:
+  SALOME_SenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
+  SALOME::TypeOfDataTransmitted getTypeOfDataTransmitted() { return SALOME::INT_; }
+  SALOME::SenderInt_ptr buildOtherWithProtocol(SALOME::TypeOfCommunication type);
+  virtual ~SALOME_SenderInt_i();
+  static SALOME_SenderInt_i *find(SALOME::SenderInt_ptr pCorba);
 };
 
 /*! Servant class for CORBA sender for double* when no copy of array _tabToSend is required, that is to say double and CORBA::Double are binary equal.
  */
 class SALOME_CorbaDoubleNCSender_i : public POA_SALOME::CorbaDoubleNCSender,
-                                    public SALOME_Sender_i
+                                    public SALOME_SenderDouble_i
 {
 public:
-  SALOME_CorbaDoubleNCSender_i(const double *tabToSend,long lgrTabToSend);
+  SALOME_CorbaDoubleNCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
   ~SALOME_CorbaDoubleNCSender_i();
   CORBA::ULong getSize();
   SALOME::vectorOfDouble* sendPart(CORBA::ULong offset, CORBA::ULong length);
@@ -55,10 +96,10 @@ public:
 /*! Servant class for CORBA sender for double* when copy of array _tabToSend is required, that is to say double and CORBA::Double are NOT binary equal.
  */
 class SALOME_CorbaDoubleCSender_i : public POA_SALOME::CorbaDoubleCSender,
-                                   public SALOME_Sender_i
+                                   public SALOME_SenderDouble_i
 {
 public:
-  SALOME_CorbaDoubleCSender_i(const double *tabToSend,long lgrTabToSend);
+  SALOME_CorbaDoubleCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
   ~SALOME_CorbaDoubleCSender_i();
   CORBA::ULong getSize();
   SALOME::vectorOfDouble* sendPart(CORBA::ULong offset, CORBA::ULong length);
@@ -67,10 +108,10 @@ public:
 /*! Servant class for CORBA sender for int* when no copy of array _tabToSend is required, that is to say int and CORBA::Long are binary equal.
  */
 class SALOME_CorbaLongNCSender_i : public POA_SALOME::CorbaLongNCSender,
-                                  public SALOME_Sender_i
+                                  public SALOME_SenderInt_i
 {
 public:
-  SALOME_CorbaLongNCSender_i(const int *tabToSend,long lgrTabToSend);
+  SALOME_CorbaLongNCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
   ~SALOME_CorbaLongNCSender_i();
   CORBA::ULong getSize();
   SALOME::vectorOfLong* sendPart(CORBA::ULong offset, CORBA::ULong length);
@@ -80,22 +121,24 @@ public:
 /*! Servant class for CORBA sender for int* when copy of array _tabToSend is required, that is to say int and CORBA::Long are NOT binary equal.
  */
 class SALOME_CorbaLongCSender_i : public POA_SALOME::CorbaLongCSender,
-                                 public SALOME_Sender_i
+                                 public SALOME_SenderInt_i
 {
 public:
-  SALOME_CorbaLongCSender_i(const int *tabToSend,long lgrTabToSend);
+  SALOME_CorbaLongCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
   ~SALOME_CorbaLongCSender_i();
   CORBA::ULong getSize();
   SALOME::vectorOfLong* sendPart(CORBA::ULong offset, CORBA::ULong length);
+#ifndef WNT
   SALOME::CorbaLongCSender_ptr _this();
+#endif
 };
 
 #ifdef HAVE_MPI2
 
 /*! Servant class of sender using MPI2.
  */
-class SALOME_MPISender_i : public POA_SALOME::MPISender,
-                          public SALOME_Sender_i
+class SALOME_MPISender_i : public virtual POA_SALOME::MPISender,
+                          public virtual SALOME_Sender_i
 {
 private:
   static unsigned long _tag1;
@@ -113,8 +156,10 @@ private:
   void **_argsForThr;
   /*! Pointer to thread created on asynchronous invocation*/
   omni_thread *_newThr;
+  /*! Type the component of the array*/
+  SALOME::TypeOfDataTransmitted _type;
 public:
-  SALOME_MPISender_i(SALOME::TypeOfDataTransmitted type,const void *tabToSend,long lgrTabToSend,int sizeOf);
+  SALOME_MPISender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false);
   ~SALOME_MPISender_i();
   SALOME::MPISender::param* getParam();
   void send();
@@ -123,14 +168,30 @@ private:
   static void* myThread(void *args);
 };
 
+class SALOME_MPISenderDouble_i : public POA_SALOME::MPISenderDouble,
+                                public SALOME_SenderDouble_i,
+                                public SALOME_MPISender_i
+{
+public:
+  SALOME_MPISenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
+};
+
+class SALOME_MPISenderInt_i : public POA_SALOME::MPISenderInt,
+                             public SALOME_SenderInt_i,
+                             public SALOME_MPISender_i
+{
+public:
+  SALOME_MPISenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
+};
+
 #endif
 
 #ifdef HAVE_SOCKET
 
 /*! Servant class of sender using Sockets.
  */
-class SALOME_SocketSender_i : public POA_SALOME::SocketSender,
-                             public SALOME_Sender_i
+class SALOME_SocketSender_i : public virtual POA_SALOME::SocketSender,
+                             public virtual SALOME_Sender_i
 {
 private:
   int _serverSockfd;
@@ -140,8 +201,10 @@ private:
   void **_argsForThr;
   omni_thread *_newThr;
   bool _errorFlag;
+  /*! Type the component of the array*/
+  SALOME::TypeOfDataTransmitted _type;
 public:
-  SALOME_SocketSender_i(SALOME::TypeOfDataTransmitted type,const void *tabToSend,long lgrTabToSend,int sizeOf);
+  SALOME_SocketSender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false);
   ~SALOME_SocketSender_i();
   SALOME::SocketSender::param* getParam();
   void send();
@@ -154,6 +217,22 @@ private:
   std::string inetAddress();
 };
 
+class SALOME_SocketSenderDouble_i : public POA_SALOME::SocketSenderDouble,
+                                   public SALOME_SenderDouble_i,
+                                   public SALOME_SocketSender_i
+{
+public:
+  SALOME_SocketSenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
+};
+
+class SALOME_SocketSenderInt_i : public POA_SALOME::SocketSenderInt,
+                                public SALOME_SenderInt_i,
+                                public SALOME_SocketSender_i
+{
+public:
+  SALOME_SocketSenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
+};
+
 #endif
 
 #endif