Back to index

salome-kernel  6.5.0
SALOME_Comm_i.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef _SALOME_COMM_I_HXX_
00024 #define _SALOME_COMM_I_HXX_
00025 
00026 #include "SALOME_Communication.hxx"
00027 
00028 #ifdef HAVE_MPI2
00029 #include "mpi.h"
00030 #endif
00031 #include <string>
00032 #include <SALOMEconfig.h>
00033 #include CORBA_SERVER_HEADER(SALOME_Comm)
00034 
00035 #define TIMEOUT 20
00036 
00037 
00042 class COMMUNICATION_EXPORT SALOME_Sender_i : public virtual POA_SALOME::Sender
00043 {
00044 protected:
00046   const void *_tabToSend;
00048   long _lgrTabToSend;
00052   int _sizeOf;
00054   bool _ownTabToSend;
00055 
00056   SALOME_Sender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false);
00057 public:
00058   const void *getData(long &size) const;
00059   int getSizeOf() const;
00060   void setOwnerShip(bool own);
00061   bool getOwnerShip() const { return _ownTabToSend; }
00062   void release();
00063   virtual ~SALOME_Sender_i() {}
00064 };
00065 
00066 class COMMUNICATION_EXPORT SALOME_SenderDouble_i : public virtual POA_SALOME::SenderDouble,
00067                               public virtual SALOME_Sender_i
00068 {
00069 public:
00070   SALOME_SenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
00071   SALOME::TypeOfDataTransmitted getTypeOfDataTransmitted() { return SALOME::DOUBLE_; }
00072   SALOME::SenderDouble_ptr buildOtherWithProtocol(SALOME::TypeOfCommunication type);
00073   virtual ~SALOME_SenderDouble_i();
00074   static SALOME_SenderDouble_i *find(SALOME::SenderDouble_ptr pCorba);
00075 };
00076 
00077 class COMMUNICATION_EXPORT SALOME_SenderInt_i : public virtual POA_SALOME::SenderInt,
00078                            public virtual SALOME_Sender_i
00079 {
00080 public:
00081   SALOME_SenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
00082   SALOME::TypeOfDataTransmitted getTypeOfDataTransmitted() { return SALOME::INT_; }
00083   SALOME::SenderInt_ptr buildOtherWithProtocol(SALOME::TypeOfCommunication type);
00084   virtual ~SALOME_SenderInt_i();
00085   static SALOME_SenderInt_i *find(SALOME::SenderInt_ptr pCorba);
00086 };
00087 
00090 class COMMUNICATION_EXPORT SALOME_CorbaDoubleNCSender_i : public POA_SALOME::CorbaDoubleNCSender,
00091                                      public SALOME_SenderDouble_i
00092 {
00093 public:
00094   SALOME_CorbaDoubleNCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
00095   ~SALOME_CorbaDoubleNCSender_i();
00096   CORBA::ULong getSize();
00097   SALOME::vectorOfDouble* sendPart(CORBA::ULong offset, CORBA::ULong length);
00098   SALOME::vectorOfDouble* send();
00099 };
00100 
00103 class COMMUNICATION_EXPORT SALOME_CorbaDoubleCSender_i : public POA_SALOME::CorbaDoubleCSender,
00104                                     public SALOME_SenderDouble_i
00105 {
00106 public:
00107   SALOME_CorbaDoubleCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
00108   ~SALOME_CorbaDoubleCSender_i();
00109   CORBA::ULong getSize();
00110   SALOME::vectorOfDouble* sendPart(CORBA::ULong offset, CORBA::ULong length);
00111 };
00112 
00115 class COMMUNICATION_EXPORT SALOME_CorbaLongNCSender_i : public POA_SALOME::CorbaLongNCSender,
00116                                    public SALOME_SenderInt_i
00117 {
00118 public:
00119   SALOME_CorbaLongNCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
00120   ~SALOME_CorbaLongNCSender_i();
00121   CORBA::ULong getSize();
00122   SALOME::vectorOfLong* sendPart(CORBA::ULong offset, CORBA::ULong length);
00123   SALOME::vectorOfLong* send();
00124 };
00125 
00128 class COMMUNICATION_EXPORT SALOME_CorbaLongCSender_i : public POA_SALOME::CorbaLongCSender,
00129                                   public SALOME_SenderInt_i
00130 {
00131 public:
00132   SALOME_CorbaLongCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
00133   ~SALOME_CorbaLongCSender_i();
00134   CORBA::ULong getSize();
00135   SALOME::vectorOfLong* sendPart(CORBA::ULong offset, CORBA::ULong length);
00136 };
00137 
00138 #ifdef HAVE_MPI2
00139 
00142 class COMMUNICATION_EXPORT SALOME_MPISender_i : public virtual POA_SALOME::MPISender,
00143                            public virtual SALOME_Sender_i
00144 {
00145 private:
00146   static unsigned long _tag1;
00147   static unsigned long _tag2;
00149   char *_portName;
00150   int _cproc;
00152   int _tag1Inst;
00154   int _tag2Inst;
00156   MPI_Comm _com;
00158   void **_argsForThr;
00160   omni_thread *_newThr;
00162   SALOME::TypeOfDataTransmitted _type;
00163 public:
00164   SALOME_MPISender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false);
00165   ~SALOME_MPISender_i();
00166   SALOME::MPISender::param* getParam();
00167   void send();
00168   void close(const SALOME::MPISender::param& p);
00169 private:
00170   static void* myThread(void *args);
00171 };
00172 
00173 class COMMUNICATION_EXPORT SALOME_MPISenderDouble_i : public POA_SALOME::MPISenderDouble,
00174                                  public SALOME_SenderDouble_i,
00175                                  public SALOME_MPISender_i
00176 {
00177 public:
00178   SALOME_MPISenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
00179 };
00180 
00181 class COMMUNICATION_EXPORT SALOME_MPISenderInt_i : public POA_SALOME::MPISenderInt,
00182                               public SALOME_SenderInt_i,
00183                               public SALOME_MPISender_i
00184 {
00185 public:
00186   SALOME_MPISenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
00187 };
00188 
00189 #endif
00190 
00191 #ifdef HAVE_SOCKET
00192 
00195 class COMMUNICATION_EXPORT SALOME_SocketSender_i : public virtual POA_SALOME::SocketSender,
00196                               public virtual SALOME_Sender_i
00197 {
00198 private:
00199   int _serverSockfd;
00200   int _clientSockfd;
00201   int _port;
00202   std::string _IPAddress;
00203   void **_argsForThr;
00204   omni_thread *_newThr;
00205   bool _errorFlag;
00207   SALOME::TypeOfDataTransmitted _type;
00208 public:
00209   SALOME_SocketSender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false);
00210   ~SALOME_SocketSender_i();
00211   SALOME::SocketSender::param* getParam();
00212   void send();
00213   void initCom() throw(SALOME::SALOME_Exception);
00214   void acceptCom() throw(SALOME::SALOME_Exception);
00215   void endOfCom();
00216   void closeCom();
00217 private:
00218   static void* myThread(void *args);
00219   std::string inetAddress();
00220 };
00221 
00222 class COMMUNICATION_EXPORT SALOME_SocketSenderDouble_i : public POA_SALOME::SocketSenderDouble,
00223                                     public SALOME_SenderDouble_i,
00224                                     public SALOME_SocketSender_i
00225 {
00226 public:
00227   SALOME_SocketSenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
00228 };
00229 
00230 class COMMUNICATION_EXPORT SALOME_SocketSenderInt_i : public POA_SALOME::SocketSenderInt,
00231                                  public SALOME_SenderInt_i,
00232                                  public SALOME_SocketSender_i
00233 {
00234 public:
00235   SALOME_SocketSenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false);
00236 };
00237 
00238 #endif
00239 
00240 #endif
00241