Salome HOME
1a49ab09e383c0f05a803711e077033a29689cd9
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingPartDefinition.hxx
1 // Copyright (C) 2007-2019  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 __PARAMEDMEM_MEDCOUPLINGPARTDEFINITION_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGPARTDEFINITION_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingMemArray.hxx"
26 #include "MCAuto.hxx"
27
28 namespace MEDCoupling
29 {
30   class PartDefinition : public RefCountObject, public TimeLabel
31   {
32   public:
33     MEDCOUPLING_EXPORT static PartDefinition *New(mcIdType start, mcIdType stop, mcIdType step);
34     MEDCOUPLING_EXPORT static PartDefinition *New(DataArrayIdType *listOfIds);
35     MEDCOUPLING_EXPORT static PartDefinition *Unserialize(std::vector<mcIdType>& tinyInt, std::vector< MCAuto<DataArrayIdType> >& bigArraysI);
36     MEDCOUPLING_EXPORT virtual bool isEqual(const PartDefinition *other, std::string& what) const = 0;
37     MEDCOUPLING_EXPORT virtual PartDefinition *deepCopy() const = 0;
38     MEDCOUPLING_EXPORT virtual DataArrayIdType *toDAI() const = 0;
39     MEDCOUPLING_EXPORT virtual mcIdType getNumberOfElems() const = 0;
40     MEDCOUPLING_EXPORT virtual PartDefinition *operator+(const PartDefinition& other) const = 0;
41     MEDCOUPLING_EXPORT virtual std::string getRepr() const = 0;
42     MEDCOUPLING_EXPORT virtual PartDefinition *composeWith(const PartDefinition *other) const = 0;
43     MEDCOUPLING_EXPORT virtual void checkConsistencyLight() const = 0;
44     MEDCOUPLING_EXPORT virtual PartDefinition *tryToSimplify() const = 0;
45     MEDCOUPLING_EXPORT virtual void serialize(std::vector<mcIdType>& tinyInt, std::vector< MCAuto<DataArrayIdType> >& bigArraysI) const = 0;
46   protected:
47     virtual ~PartDefinition();
48   };
49
50   class SlicePartDefinition;
51
52   class DataArrayPartDefinition : public PartDefinition
53   {
54   public:
55     MEDCOUPLING_EXPORT static DataArrayPartDefinition *New(DataArrayIdType *listOfIds);
56     MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("DataArrayPartDefinition"); }
57     MEDCOUPLING_EXPORT bool isEqual(const PartDefinition *other, std::string& what) const;
58     MEDCOUPLING_EXPORT DataArrayPartDefinition *deepCopy() const;
59     MEDCOUPLING_EXPORT DataArrayIdType *toDAI() const;
60     MEDCOUPLING_EXPORT mcIdType getNumberOfElems() const;
61     MEDCOUPLING_EXPORT PartDefinition *operator+(const PartDefinition& other) const;
62     MEDCOUPLING_EXPORT std::string getRepr() const;
63     MEDCOUPLING_EXPORT PartDefinition *composeWith(const PartDefinition *other) const;
64     MEDCOUPLING_EXPORT void checkConsistencyLight() const;
65     MEDCOUPLING_EXPORT PartDefinition *tryToSimplify() const;
66     MEDCOUPLING_EXPORT void serialize(std::vector<mcIdType>& tinyInt, std::vector< MCAuto<DataArrayIdType> >& bigArraysI) const;
67   private:
68     DataArrayPartDefinition(DataArrayIdType *listOfIds);
69     void checkInternalArrayOK() const;
70     static void CheckInternalArrayOK(const DataArrayIdType *listOfIds);
71     MEDCOUPLING_EXPORT void updateTime() const;
72     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
73     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
74     DataArrayPartDefinition *add1(const DataArrayPartDefinition *other) const;
75     DataArrayPartDefinition *add2(const SlicePartDefinition *other) const;
76     virtual ~DataArrayPartDefinition();
77   private:
78     MCAuto<DataArrayIdType> _arr;
79   };
80
81   class SlicePartDefinition : public PartDefinition
82   {
83   public:
84     MEDCOUPLING_EXPORT static SlicePartDefinition *New(mcIdType start, mcIdType stop, mcIdType step);
85     MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("SlicePartDefinition"); }
86     MEDCOUPLING_EXPORT bool isEqual(const PartDefinition *other, std::string& what) const;
87     MEDCOUPLING_EXPORT SlicePartDefinition *deepCopy() const;
88     MEDCOUPLING_EXPORT DataArrayIdType *toDAI() const;
89     MEDCOUPLING_EXPORT mcIdType getNumberOfElems() const;
90     MEDCOUPLING_EXPORT PartDefinition *operator+(const PartDefinition& other) const;
91     MEDCOUPLING_EXPORT std::string getRepr() const;
92     MEDCOUPLING_EXPORT PartDefinition *composeWith(const PartDefinition *other) const;
93     MEDCOUPLING_EXPORT void checkConsistencyLight() const;
94     MEDCOUPLING_EXPORT PartDefinition *tryToSimplify() const;
95     MEDCOUPLING_EXPORT void serialize(std::vector<mcIdType>& tinyInt, std::vector< MCAuto<DataArrayIdType> >& bigArraysI) const;
96     //specific method
97     MEDCOUPLING_EXPORT mcIdType getEffectiveStop() const;
98     MEDCOUPLING_EXPORT void getSlice(mcIdType& start, mcIdType& stop, mcIdType& step) const;
99   private:
100     SlicePartDefinition(mcIdType start, mcIdType stop, mcIdType step);
101     MEDCOUPLING_EXPORT void updateTime() const;
102     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
103     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
104     DataArrayPartDefinition *add1(const DataArrayPartDefinition *other) const;
105     PartDefinition *add2(const SlicePartDefinition *other) const;
106     virtual ~SlicePartDefinition();
107   private:
108     mcIdType _start;
109     mcIdType _stop;
110     mcIdType _step;
111   };
112 }
113
114 #endif