Back to index

salome-kernel  6.5.0
SenderFactory.cxx
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 #include "SALOME_Comm_i.hxx"
00024 #include "SenderFactory.hxx"
00025 #include "utilities.h"
00026 #include "SALOMEMultiComm.hxx"
00027 
00028 #ifdef COMP_CORBA_DOUBLE
00029 #define SALOME_CorbaDoubleSender SALOME_CorbaDoubleNCSender_i
00030 #else
00031 #define SALOME_CorbaDoubleSender SALOME_CorbaDoubleCSender_i
00032 #endif
00033 
00034 #ifdef COMP_CORBA_LONG
00035 #define SALOME_CorbaLongSender SALOME_CorbaLongNCSender_i
00036 #else
00037 #define SALOME_CorbaLongSender SALOME_CorbaLongCSender_i
00038 #endif
00039 
00040 SALOME::SenderDouble_ptr SenderFactory::buildSender(SALOMEMultiComm &multiCommunicator,const double *tab,long lgr,bool ownTab)throw(MultiCommException){
00041   switch(multiCommunicator.getProtocol())
00042     {
00043     case SALOME::CORBA_:
00044       {
00045         SALOME_CorbaDoubleSender * retc=new SALOME_CorbaDoubleSender(tab,lgr,ownTab);
00046         return retc->_this();
00047       }
00048 #ifdef HAVE_MPI2
00049     case SALOME::MPI_:
00050       {
00051         SALOME_MPISenderDouble_i* retm=new SALOME_MPISenderDouble_i(tab,lgr,ownTab);
00052         return retm->_this();
00053       }
00054 #endif
00055 #ifdef HAVE_SOCKET
00056     case SALOME::SOCKET_:
00057       {
00058         SALOME_SocketSenderDouble_i* rets=new SALOME_SocketSenderDouble_i(tab,lgr,ownTab);
00059         return rets->_this();
00060       }
00061 #endif
00062     default:
00063       {
00064         multiCommunicator.setProtocol(SALOME::CORBA_);
00065         MESSAGE("PROTOCOL CHANGED TO CORBA");
00066         SALOME_CorbaDoubleSender * retc=new SALOME_CorbaDoubleSender(tab,lgr,ownTab);
00067         return retc->_this();
00068       }
00069 //       throw MultiCommException("Communication protocol not implemented");
00070     }
00071 }
00072 
00073 SALOME::SenderInt_ptr SenderFactory::buildSender(SALOMEMultiComm &multiCommunicator,const int *tab,long lgr,bool ownTab)throw(MultiCommException){
00074   switch(multiCommunicator.getProtocol())
00075     {
00076     case SALOME::CORBA_:
00077       {
00078         SALOME_CorbaLongSender * retc=new SALOME_CorbaLongSender(tab,lgr,ownTab);
00079         return retc->_this();
00080       }
00081 #ifdef HAVE_MPI2
00082     case SALOME::MPI_:
00083       {
00084         SALOME_MPISenderInt_i* retm=new SALOME_MPISenderInt_i(tab,lgr,ownTab);
00085         return retm->_this();
00086       }
00087 #endif
00088 #ifdef HAVE_SOCKET
00089     case SALOME::SOCKET_:
00090       {
00091         SALOME_SocketSenderInt_i* rets=new SALOME_SocketSenderInt_i(tab,lgr,ownTab);
00092         return rets->_this();
00093       }
00094 #endif
00095     default:
00096       {
00097         multiCommunicator.setProtocol(SALOME::CORBA_);
00098         SALOME_CorbaLongSender * retc=new SALOME_CorbaLongSender(tab,lgr,ownTab);
00099         return retc->_this();
00100       }
00101 //       throw MultiCommException("Communication protocol not implemented"); 
00102     }
00103   }
00104 
00105 SALOME::SenderDouble_ptr SenderFactory::buildSender(SALOME::TypeOfCommunication NewType,SALOME_SenderDouble_i *src)
00106 {
00107   SALOMEMultiComm mc(NewType);
00108   long n;
00109   const double *data=(const double *)src->getData(n);
00110   bool own=src->getOwnerShip();
00111   src->setOwnerShip(false);
00112   return buildSender(mc,data,n,own);
00113 }
00114 
00115 SALOME::SenderInt_ptr SenderFactory::buildSender(SALOME::TypeOfCommunication NewType,SALOME_SenderInt_i *src)
00116 {
00117   SALOMEMultiComm mc(NewType);
00118   long n;
00119   const int *data=(const int *)src->getData(n);
00120   bool own=src->getOwnerShip();
00121   src->setOwnerShip(false);
00122   return buildSender(mc,data,n,own);
00123 }