1 // Copyright (C) 2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : Copy2CorbaSpace.hxx
23 // Author : Eric Fayolle (EDF)
25 // Modified by : $LastChangedBy$
26 // Date : $LastChangedDate: 2007-02-07 18:26:44 +0100 (mer, 07 fév 2007) $
29 #ifndef _COPY_TO_CORBA_SPACE_HXX_
30 #define _COPY_TO_CORBA_SPACE_HXX_
34 #include "CalciumPortTraits.hxx"
36 template <bool zerocopy>
37 struct Copy2CorbaSpace {
39 template <class T1, class T2>
40 static void apply( T1 * & corbaData, T2 & data, size_t nRead){
42 typedef typename ProvidesPortTraits<T2>::PortType PortType;
43 //typedef typename UsesPortTraits<T2>::PortType PortType;
44 typedef typename PortType::DataManipulator DataManipulator;
45 typedef typename DataManipulator::InnerType InnerType;
48 std::cerr << "-------- Copy2CorbaSpace<true> MARK 1 ------------------" << std::endl;
50 // Crée le type corba à partir du data sans lui en donner la propriété
51 corbaData = DataManipulator::create(nRead,&data,false);
53 std::cerr << "-------- Copy2CorbaSpace<true> MARK 2 --(dataPtr : "
54 << DataManipulator::getPointer(corbaData,false)<<")----------------" << std::endl;
60 // Cas ou il faut effectuer une recopie
62 Copy2CorbaSpace<false> {
64 template <class T1, class T2>
65 static void apply( T1 * & corbaData, T2 & data, size_t nRead){
67 typedef typename ProvidesPortTraits<T2>::PortType PortType;
68 // typedef typename UsesPortTraits<T2>::PortType PortType;
69 typedef typename PortType::DataManipulator DataManipulator;
70 typedef typename DataManipulator::InnerType InnerType;
72 corbaData = DataManipulator::create(nRead);
73 InnerType * dataPtr = DataManipulator::getPointer(corbaData,false);
76 std::cerr << "-------- Copy2CorbaSpace<false> MARK 1 --(dataPtr : " <<
77 dataPtr<<")----------------" << std::endl;
79 // Attention : Pour les chaines ou tout autre object complexe il faut utiliser une recopie profonde !
80 std::copy(&data,&data+nRead,dataPtr);
83 std::cerr << "-------- Copy2CorbaSpace<false> MARK 2 --(nRead: "<<nRead<<")-------------" << std::endl;
85 std::cerr << "-------- Copy2CorbaSpace<false> MARK 3 : " ;
86 std::copy(dataPtr,dataPtr+nRead,std::ostream_iterator<InnerType>(std::cout," "));
87 std::cout << std::endl;
88 std::cerr << "-------- Copy2CorbaSpace<false> MARK 4 --(data : " <<data<<") :" ;
89 for (int i=0; i<nRead; ++i)
90 std::cerr << (*corbaData)[i] << " ";
91 std::cout << std::endl;