Version: 9.16.0
Copy2CorbaSpace.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
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.
10//
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.
15//
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
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23// File : Copy2CorbaSpace.hxx
24// Author : Eric Fayolle (EDF)
25// Module : KERNEL
26// Modified by : $LastChangedBy$
27// Date : $LastChangedDate: 2007-02-07 18:26:44 +0100 (mer, 07 fév 2007) $
28// Id : $Id$
29//
30#ifndef _COPY_TO_CORBA_SPACE_HXX_
31#define _COPY_TO_CORBA_SPACE_HXX_
32
33
34#include <string>
35#include <iostream>
36#include "CalciumPortTraits.hxx"
37
38
39template <bool zerocopy, typename DataManipulator>
41
42 template <class T1, class T2>
43 static void apply( T1 * & corbaData, T2 const & data, size_t nRead){
44
45 typedef typename ProvidesPortTraits<T2>::PortType PortType;
46 //typedef typename UsesPortTraits<T2>::PortType PortType;
47 //ESSAI: typedef typename PortType::DataManipulator DataManipulator;
48 typedef typename DataManipulator::InnerType InnerType;
49
50 if (SALOME::VerbosityActivated())
51 std::cerr << "-------- Copy2CorbaSpace<true> MARK 1 ------------------" << std::endl;
52
53 // Crée le type corba à partir du data sans lui en donner la propriété.
54 // Le const_cast supprime le caractère const du type T2 const & de data car
55 // DataManipulator::create n'a pas le caractère const sur son paramètre data pour le
56 // cas de figure où la propriété de la donnée lui est donnée.
57 corbaData = DataManipulator::create(nRead,const_cast<T2 * > (&data),false);
58 if (SALOME::VerbosityActivated())
59 std::cerr << "-------- Copy2CorbaSpace<true> MARK 2 --(dataPtr : "
60 << DataManipulator::getPointer(corbaData,false)<<")----------------" << std::endl;
61 }
62};
63
64// Cas ou il faut effectuer une recopie
65template <typename DataManipulator> struct
67
68 template <class T1, class T2>
69 static void apply( T1 * & corbaData, T2 const & data, size_t nRead){
70
71 typedef typename ProvidesPortTraits<T2>::PortType PortType;
72 // typedef typename UsesPortTraits<T2>::PortType PortType;
73//ESSAI: typedef typename PortType::DataManipulator DataManipulator;
74 typedef typename DataManipulator::InnerType InnerType;
75
76 corbaData = DataManipulator::create(nRead);
77 InnerType * dataPtr = DataManipulator::getPointer(corbaData,false);
78
79 if (SALOME::VerbosityActivated())
80 std::cerr << "-------- Copy2CorbaSpace<false> MARK 1 --(dataPtr : " <<
81 dataPtr<<")----------------" << std::endl;
82
83 // Attention : Pour les chaines ou tout autre object complexe il faut utiliser une recopie profonde !
84 std::copy(&data,&data+nRead,dataPtr);
85
86 if (SALOME::VerbosityActivated())
87 {
88 std::cerr << "-------- Copy2CorbaSpace<false> MARK 2 --(nRead: "<<nRead<<")-------------" << std::endl;
89
90 std::cerr << "-------- Copy2CorbaSpace<false> MARK 3 : " ;
91 std::copy(dataPtr,dataPtr+nRead,std::ostream_iterator<InnerType>(std::cout," "));
92 std::cout << std::endl;
93 std::cerr << "-------- Copy2CorbaSpace<false> MARK 4 --(data : " <<data<<") :" ;
94 for (int i=0; i<nRead; ++i)
95 std::cerr << (*corbaData)[i] << " ";
96 std::cout << std::endl;
97 }
98 }
99};
100
101#endif
def copy(src, dst)
Definition: pythonpath_reduction.py:35
Definition: Copy2CorbaSpace.hxx:66
static void apply(T1 *&corbaData, T2 const &data, size_t nRead)
Definition: Copy2CorbaSpace.hxx:69
Definition: Copy2CorbaSpace.hxx:40
static void apply(T1 *&corbaData, T2 const &data, size_t nRead)
Definition: Copy2CorbaSpace.hxx:43
Definition: CalciumPortTraits.hxx:37