]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_ArrayInterface.hxx
Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MEDMEM / MEDMEM_ArrayInterface.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, 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.
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 #ifndef MEDMEM_ARRAYINTERFACE_HXX
23 #define MEDMEM_ARRAYINTERFACE_HXX
24
25 #include "MEDMEM_nArray.hxx"
26 #include "MEDMEM_InterlacingTraits.hxx"
27
28 // L'astuce d'une classe d'interface consiste en 
29 // 1) La déclaration d'un type qui est celui de la classe d'implémentation
30 // 2) D'utiliser ce nouveau nom de type comme paramètres de toutes
31 //     les méthodes de l'interface.
32 // L'inconvenient est qu'il faut justement passer en argument une instance de
33 // le classe d'implémentation dans toutes les méthodes et que la classe
34 // appelante aura aussi à faire ce travail.
35 //  Ne surtout pas oublier inline sinon l'interface couterait cher à l'appel
36 //  des méthodes !
37 namespace MEDMEM {
38
39 template < class ARRAY_ELEMENT_TYPE,
40            class INTERLACE_TAG,
41            class GAUSS_TAG,
42            class CHECKING_POLICY=IndexCheckPolicy>
43            //NoIndexCheckPolicy>
44 class MEDMEM_EXPORT MEDMEM_ArrayInterface  {
45
46 public:
47
48   // Les type ElementType et Array sont a définir aussi dans les classes utilisatrice
49   // par une déclaration du type : typedef typename ArrayInterface::Array Array;
50
51   typedef  ARRAY_ELEMENT_TYPE  ElementType;
52   typedef  INTERLACE_TAG       Interlacing;
53   typedef  GAUSS_TAG           GaussPresence;
54   typedef  typename MEDMEM_InterlacingTraits<Interlacing,GaussPresence>::Type InterlacingPolicy;
55   typedef  CHECKING_POLICY     CheckingPolicy;
56   typedef  MEDMEM_Array<ElementType,InterlacingPolicy,CheckingPolicy> Array;
57
58   static inline int getNbGauss(int i, const Array & array)  {
59     return array.getNbGauss(i);
60   };
61
62   static inline ElementType * getPtr( Array & array)  {
63     return array.getPtr();
64   };
65
66   static inline void setPtr( ElementType * arrayptr,  Array & array, 
67                              bool shallowCopy=false,
68                              bool ownershipOfValues=false )  {
69     array.setPtr(arrayptr,shallowCopy,ownershipOfValues);
70   };
71
72   static inline const ElementType * getRow(int i, const Array & array ) {
73     return array.getRow(i);
74   }
75
76   static inline void setRow(int i, const ElementType & value, const Array & array ) {
77     return array.setRow(i,value);
78   }
79
80   static inline const ElementType * getColumn(int j, const Array & array ) {
81     return array.getColumn(j);
82   }
83
84   static inline void setColumn(int j, const ElementType & value, const Array & array ) {
85     return array.setColumn(j,value);
86   }
87
88   static inline const ElementType & getIJ(int i, int j, const Array & array) {
89     return array.getIJ(i,j);
90   }
91
92   static inline const ElementType & getIJK(int i, int j, int k, const Array & array) {
93     return array.getIJK(i,j,k);
94   }
95
96   static inline void setIJ(int i, int j, const ElementType & value, Array & array) {
97     array.setIJ(i,j,value);
98   }
99
100   static inline void setIJK(int i, int j, int k, const ElementType & value, Array & array) {
101     array.setIJK(i,j,k,value);
102   }
103
104 };
105
106 } //END NAMESPACE
107 #endif