1 // Copyright (C) 2007-2008 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.
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
22 #ifndef MEDMEM_ARRAYINTERFACE_HXX
23 #define MEDMEM_ARRAYINTERFACE_HXX
25 #include "MEDMEM_nArray.hxx"
26 #include "MEDMEM_InterlacingTraits.hxx"
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
39 template < class ARRAY_ELEMENT_TYPE,
42 class CHECKING_POLICY=IndexCheckPolicy>
44 class MEDMEM_EXPORT MEDMEM_ArrayInterface {
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;
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;
58 static inline int getNbGauss(int i, const Array & array) {
59 return array.getNbGauss(i);
62 static inline ElementType * getPtr( Array & array) {
63 return array.getPtr();
66 static inline void setPtr( ElementType * arrayptr, Array & array,
67 bool shallowCopy=false,
68 bool ownershipOfValues=false ) {
69 array.setPtr(arrayptr,shallowCopy,ownershipOfValues);
72 static inline const ElementType * getRow(int i, const Array & array ) {
73 return array.getRow(i);
76 static inline void setRow(int i, const ElementType & value, const Array & array ) {
77 return array.setRow(i,value);
80 static inline const ElementType * getColumn(int j, const Array & array ) {
81 return array.getColumn(j);
84 static inline void setColumn(int j, const ElementType & value, const Array & array ) {
85 return array.setColumn(j,value);
88 static inline const ElementType & getIJ(int i, int j, const Array & array) {
89 return array.getIJ(i,j);
92 static inline const ElementType & getIJK(int i, int j, int k, const Array & array) {
93 return array.getIJK(i,j,k);
96 static inline void setIJ(int i, int j, const ElementType & value, Array & array) {
97 array.setIJ(i,j,value);
100 static inline void setIJK(int i, int j, int k, const ElementType & value, Array & array) {
101 array.setIJK(i,j,k,value);