1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : Copy2CorbaSpace.hxx
24 // Author : Eric Fayolle (EDF)
26 // Modified by : $LastChangedBy$
27 // Date : $LastChangedDate: 2007-02-07 18:26:44 +0100 (mer, 07 fév 2007) $
30 #ifndef _COPY_TO_CORBA_SPACE_HXX_
31 #define _COPY_TO_CORBA_SPACE_HXX_
36 #include "CalciumPortTraits.hxx"
40 template <bool zerocopy, typename DataManipulator>
41 struct Copy2CorbaSpace {
43 template <class T1, class T2>
44 static void apply( T1 * & corbaData, T2 const & data, size_t nRead){
46 typedef typename ProvidesPortTraits<T2>::PortType PortType;
47 //typedef typename UsesPortTraits<T2>::PortType PortType;
48 //ESSAI: typedef typename PortType::DataManipulator DataManipulator;
49 typedef typename DataManipulator::InnerType InnerType;
52 std::cerr << "-------- Copy2CorbaSpace<true> MARK 1 ------------------" << std::endl;
54 // Crée le type corba à partir du data sans lui en donner la propriété.
55 // Le const_cast supprime le caractère const du type T2 const & de data car
56 // DataManipulator::create n'a pas le caractère const sur son paramètre data pour le
57 // cas de figure où la propriété de la donnée lui est donnée.
58 corbaData = DataManipulator::create(nRead,const_cast<T2 * > (&data),false);
60 std::cerr << "-------- Copy2CorbaSpace<true> MARK 2 --(dataPtr : "
61 << DataManipulator::getPointer(corbaData,false)<<")----------------" << std::endl;
67 // Cas ou il faut effectuer une recopie
68 template <typename DataManipulator> struct
69 Copy2CorbaSpace<false, DataManipulator> {
71 template <class T1, class T2>
72 static void apply( T1 * & corbaData, T2 const & data, size_t nRead){
74 typedef typename ProvidesPortTraits<T2>::PortType PortType;
75 // typedef typename UsesPortTraits<T2>::PortType PortType;
76 //ESSAI: typedef typename PortType::DataManipulator DataManipulator;
77 typedef typename DataManipulator::InnerType InnerType;
79 corbaData = DataManipulator::create(nRead);
80 InnerType * dataPtr = DataManipulator::getPointer(corbaData,false);
83 std::cerr << "-------- Copy2CorbaSpace<false> MARK 1 --(dataPtr : " <<
84 dataPtr<<")----------------" << std::endl;
86 // Attention : Pour les chaines ou tout autre object complexe il faut utiliser une recopie profonde !
87 std::copy(&data,&data+nRead,dataPtr);
90 std::cerr << "-------- Copy2CorbaSpace<false> MARK 2 --(nRead: "<<nRead<<")-------------" << std::endl;
92 std::cerr << "-------- Copy2CorbaSpace<false> MARK 3 : " ;
93 std::copy(dataPtr,dataPtr+nRead,std::ostream_iterator<InnerType>(std::cout," "));
94 std::cout << std::endl;
95 std::cerr << "-------- Copy2CorbaSpace<false> MARK 4 --(data : " <<data<<") :" ;
96 for (int i=0; i<nRead; ++i)
97 std::cerr << (*corbaData)[i] << " ";
98 std::cout << std::endl;