1 // Copyright (C) 2007-2012 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
23 #ifndef MEDMEM_ARRAYINTERFACE_HXX
24 #define MEDMEM_ARRAYINTERFACE_HXX
26 #include "MEDMEM_nArray.hxx"
27 #include "MEDMEM_InterlacingTraits.hxx"
29 // L'astuce d'une classe d'interface consiste en
30 // 1) La déclaration d'un type qui est celui de la classe d'implémentation
31 // 2) D'utiliser ce nouveau nom de type comme paramètres de toutes
32 // les méthodes de l'interface.
33 // L'inconvenient est qu'il faut justement passer en argument une instance de
34 // le classe d'implémentation dans toutes les méthodes et que la classe
35 // appelante aura aussi à faire ce travail.
36 // Ne surtout pas oublier inline sinon l'interface couterait cher à l'appel
40 template < class ARRAY_ELEMENT_TYPE,
43 class CHECKING_POLICY=IndexCheckPolicy>
45 class MEDMEM_EXPORT MEDMEM_ArrayInterface {
49 // Les type ElementType et Array sont a définir aussi dans les classes utilisatrice
50 // par une déclaration du type : typedef typename ArrayInterface::Array Array;
52 typedef ARRAY_ELEMENT_TYPE ElementType;
53 typedef INTERLACE_TAG Interlacing;
54 typedef GAUSS_TAG GaussPresence;
55 typedef typename MEDMEM_InterlacingTraits<Interlacing,GaussPresence>::Type InterlacingPolicy;
56 typedef CHECKING_POLICY CheckingPolicy;
57 typedef MEDMEM_Array<ElementType,InterlacingPolicy,CheckingPolicy> Array;
59 static inline int getNbGauss(int i, const Array & array) {
60 return array.getNbGauss(i);
63 static inline ElementType * getPtr( Array & array) {
64 return array.getPtr();
67 static inline void setPtr( ElementType * arrayptr, Array & array,
68 bool shallowCopy=false,
69 bool ownershipOfValues=false ) {
70 array.setPtr(arrayptr,shallowCopy,ownershipOfValues);
73 static inline const ElementType * getRow(int i, const Array & array ) {
74 return array.getRow(i);
77 static inline void setRow(int i, const ElementType & value, const Array & array ) {
78 return array.setRow(i,value);
81 static inline const ElementType * getColumn(int j, const Array & array ) {
82 return array.getColumn(j);
85 static inline void setColumn(int j, const ElementType & value, const Array & array ) {
86 return array.setColumn(j,value);
89 static inline const ElementType & getIJ(int i, int j, const Array & array) {
90 return array.getIJ(i,j);
93 static inline const ElementType & getIJK(int i, int j, int k, const Array & array) {
94 return array.getIJK(i,j,k);
97 static inline void setIJ(int i, int j, const ElementType & value, Array & array) {
98 array.setIJ(i,j,value);
101 static inline void setIJK(int i, int j, int k, const ElementType & value, Array & array) {
102 array.setIJK(i,j,k,value);