Salome HOME
f02c3d68d442e55b67fdc7bef753c340d0614052
[tools/medcoupling.git] / src / ParaMEDMEM / ParaDataArray.hxx
1 // Copyright (C) 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 #pragma once
22
23 #include "MEDCouplingMemArray.hxx"
24
25 namespace MEDCoupling
26 {
27   /*!
28    * Parallel representation of a DataArray
29    *
30    * This class is very specific to the requirement of parallel code computations.
31    */
32   class ParaDataArray : public RefCountObject
33   {
34   };
35
36   template<class T>
37   class ParaDataArrayTemplate : public ParaDataArray
38   {
39   protected:
40     ParaDataArrayTemplate(typename Traits<T>::ArrayType *seqDa);
41   protected:
42     std::size_t getHeapMemorySizeWithoutChildren() const override;
43     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const override;
44     void checkOKOneComponent(const std::string& msg) const;
45   protected:
46     MCAuto<typename Traits<T>::ArrayType> _seq_da;
47   };
48
49   template<class T>
50   class ParaDataArrayDiscrete : public ParaDataArrayTemplate<T>
51   {
52   public:
53     DataArrayIdType *buildComplement(T nbOfElems) const;
54   protected:
55     ParaDataArrayDiscrete(typename Traits<T>::ArrayType *seqDa):ParaDataArrayTemplate<T>(seqDa) { }
56   };
57
58   class ParaDataArrayInt32 : public ParaDataArrayDiscrete<Int32>
59   {
60   public:
61     static ParaDataArrayInt32 *New(DataArrayInt32 *seqDa);
62   private:
63     ParaDataArrayInt32(DataArrayInt32 *seqDa):ParaDataArrayDiscrete<Int32>(seqDa) { }
64     std::string getClassName() const override { return "ParaDataArrayInt32"; }
65   };
66
67   class ParaDataArrayInt64 : public ParaDataArrayDiscrete<Int64>
68   {
69   public:
70     static ParaDataArrayInt64 *New(DataArrayInt64 *seqDa);
71   private:
72     ParaDataArrayInt64(DataArrayInt64 *seqDa):ParaDataArrayDiscrete<Int64>(seqDa) { }
73     std::string getClassName() const override { return "ParaDataArrayInt64"; }
74   };
75   
76   #ifndef MEDCOUPLING_USE_64BIT_IDS
77   using ParaDataArrayIdType = ParaDataArrayInt32;
78   #else
79   using ParaDataArrayIdType = ParaDataArrayInt64;
80   #endif
81 }