Salome HOME
Copyright update 2020
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingTraits.hxx
1 // Copyright (C) 2016-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (EDF R&D)
20
21 #ifndef __MEDCOUPLINGTRAITS_HXX__
22 #define __MEDCOUPLINGTRAITS_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MCType.hxx"
26 #include <vector>
27
28 namespace MEDCoupling
29 {
30   template<class T>
31   struct MEDCOUPLING_EXPORT Traits
32   {
33     typedef T EltType;
34   };
35
36   class DataArrayInt32;
37   class DataArrayFloat;
38   class DataArrayDouble;
39   class DataArrayChar;
40   class DataArrayByte;
41   class DataArrayInt64;
42   class MEDCouplingFieldDouble;
43   class MEDCouplingFieldFloat;
44   class MEDCouplingFieldInt;
45   class DataArrayInt32Tuple;
46   class DataArrayInt64Tuple;
47   class DataArrayFloatTuple;
48   class DataArrayDoubleTuple;
49   class DataArrayByteTuple;
50   class DataArrayInt32Iterator;
51   class DataArrayInt64Iterator;
52   class DataArrayByteIterator;
53   
54   template<>
55   struct MEDCOUPLING_EXPORT Traits<double>
56   {
57     static const char ArrayTypeName[];
58     static const char FieldTypeName[];
59     static const char NPYStr[];
60     static const char ReprStr[];
61     typedef DataArrayDouble ArrayType;
62     typedef DataArrayDouble ArrayTypeCh;
63     typedef MEDCouplingFieldDouble FieldType;
64     typedef DataArrayDoubleTuple ArrayTuple;
65   };
66
67   template<>
68   struct MEDCOUPLING_EXPORT Traits<float>
69   {
70     static const char ArrayTypeName[];
71     static const char FieldTypeName[];
72     static const char NPYStr[];
73     static const char ReprStr[];
74     typedef DataArrayFloat ArrayType;
75     typedef DataArrayFloat ArrayTypeCh;
76     typedef MEDCouplingFieldFloat FieldType;
77     typedef DataArrayFloatTuple ArrayTuple;
78   };
79   
80   template<>
81   struct MEDCOUPLING_EXPORT Traits<Int32>
82   {
83     static const char ArrayTypeName[];
84     static const char FieldTypeName[];
85     static const char NPYStr[];
86     static const char ReprStr[];
87     static const char VTKReprStr[];
88     typedef DataArrayInt32 ArrayType;
89     typedef DataArrayInt32 ArrayTypeCh;
90     typedef MEDCouplingFieldInt FieldType;
91     typedef DataArrayInt32Tuple ArrayTuple;
92     typedef DataArrayInt32Iterator IteratorType;
93   };
94
95   template<>
96   struct MEDCOUPLING_EXPORT Traits<Int64>
97   {
98     static const char ArrayTypeName[];
99     static const char FieldTypeName[];
100     static const char NPYStr[];
101     static const char ReprStr[];
102     static const char VTKReprStr[];
103     typedef DataArrayInt64 ArrayType;
104     typedef DataArrayInt64 ArrayTypeCh;
105     //typedef MEDCouplingFieldInt64 FieldType;
106     typedef DataArrayInt64Tuple ArrayTuple;
107     typedef DataArrayInt64Iterator IteratorType;
108   };
109
110   template<>
111   struct MEDCOUPLING_EXPORT Traits<char>
112   {
113     static const char ArrayTypeName[];
114     typedef DataArrayByte ArrayTypeCh;
115     typedef DataArrayChar ArrayType;
116     typedef DataArrayByteTuple ArrayTuple;
117     typedef DataArrayByteIterator IteratorType;
118   };
119 }
120
121 #endif