Back to index

salome-med  6.5.0
UtilClient.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 UTILCLIENT_HXX_
00024 #define UTILCLIENT_HXX_
00025 
00026 #include <vector>
00027 #include <utilities.h>
00028 #include "MEDMEM_PointerOf.hxx"
00029 
00030 namespace MEDMEM {
00031 template <typename TLocal, 
00032           typename TCorbaSeq,
00033           typename Tint>
00034 inline void convertCorbaArray (TLocal * & T, Tint &nT, const TCorbaSeq & S)
00035 {
00036   Tint i, n = S->length();
00037 
00038   nT = n;
00039   T = n > 0 ? new TLocal[n] : NULL;
00040 
00041   for (i=0; i<n; i++) {
00042     T[i] = (*S)[i];
00043   }
00044 }
00045 
00046 template <typename TLocal, 
00047           typename TCorbaSeq,
00048           typename Tint>
00049 inline void convertCorbaArray2 (TLocal& tab, Tint &nT, const TCorbaSeq s)
00050 {
00051   Tint i, n = s.length();
00052 
00053   nT = n;
00054   tab.set(n);
00055   for (i=0; i<n; i++) {
00056     tab[i] = s[i];
00057   }
00058 }
00059 
00060 template <typename TCorba,
00061           typename TLocal,
00062           typename TCorbaSeq>
00063 inline void convertCorbaArray (TLocal * & T, long &nT, const TCorbaSeq & S,
00064                                void *f)
00065 {
00066   int i, n = S->length();
00067   SCRUTE(n);
00068 
00069   nT = n;
00070   T = n > 0 ? new TLocal[n] : NULL;
00071 
00072   typedef TLocal (*pfn) (const TCorba &T);
00073 
00074   pfn convert = pfn(f);
00075   for (i=0; i<n; i++) {
00076     SCRUTE((*S)[i]);
00077     T[i] = convert((*S)[i]);
00078     SCRUTE(T[i]);
00079   }
00080 }
00081 
00082 template <typename TLocal,
00083           typename TCorbaSeq>
00084 inline void convertCorbaArray (std::vector<TLocal> & T, int &nT, 
00085                                const TCorbaSeq & S)
00086 {
00087   int i, n = S->length();
00088   SCRUTE(n);
00089 
00090   nT = n;
00091   T.resize(nT);
00092 
00093   for (i=0; i<nT; i++) {
00094     SCRUTE((*S)[i]);
00095     T[i] = convert((*S)[i]);
00096     SCRUTE(T[i]);
00097   }
00098 }
00099 
00100 
00101 template <typename TCorba,
00102           typename TLocal,
00103           typename TCorbaSeq>
00104 inline void convertCorbaArray (std::vector<TLocal> & T, int &nT, 
00105                                const TCorbaSeq & S,
00106                                void *f)
00107 {
00108   int i, n = S->length();
00109   SCRUTE(n);
00110 
00111   nT = n;
00112   T.resize(nT);
00113 
00114   typedef TLocal (*pfn) (const TCorba &T);
00115 
00116   pfn convert = pfn(f);
00117   for (i=0; i<nT; i++) {
00118     SCRUTE((*S)[i]);
00119     T[i] = convert((*S)[i]);
00120     SCRUTE(T[i]);
00121   }
00122  
00123 }
00124 
00125 
00126 template <typename TCorba,
00127           typename TLocal,
00128           typename TCorbaSeq,
00129           typename TInfo>
00130 inline void convertCorbaArray (std::vector<TLocal> & T, 
00131                                const TCorbaSeq & S,
00132                                void *f, TInfo M)
00133 {
00134   int i, n = S->length();
00135   SCRUTE(n);
00136 
00137   int nT = n;
00138   T.resize(nT);
00139 
00140   typedef TLocal (*pfn) (const TCorba & , TInfo);
00141 
00142   pfn convert = pfn(f);
00143   for (i=0; i<nT; i++) {
00144     SCRUTE((*S)[i]);
00145     T[i] = convert((*S)[i], M);
00146     SCRUTE(T[i]);
00147   }
00148  
00149 }
00150 }
00151 
00152 #endif