Salome HOME
Merge branch 'master' into V7_5_BR
[modules/med.git] / src / MEDCoupling / MEDCouplingPartDefinition.hxx
1 // Copyright (C) 2007-2014  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 "MEDCouplingAutoRefCountObjectPtr.hxx"
27
28 namespace ParaMEDMEM
29 {
30   class PartDefinition : public RefCountObject, public TimeLabel
31   {
32   public:
33     MEDCOUPLING_EXPORT static PartDefinition *New(int start, int stop, int step);
34     MEDCOUPLING_EXPORT static PartDefinition *New(DataArrayInt *listOfIds);
35     MEDCOUPLING_EXPORT virtual DataArrayInt *toDAI() const = 0;
36     MEDCOUPLING_EXPORT virtual int getNumberOfElems() const = 0;
37     MEDCOUPLING_EXPORT virtual PartDefinition *operator+(const PartDefinition& other) const = 0;
38     MEDCOUPLING_EXPORT virtual std::string getRepr() const = 0;
39     MEDCOUPLING_EXPORT virtual PartDefinition *composeWith(const PartDefinition *other) const = 0;
40     MEDCOUPLING_EXPORT virtual void checkCoherency() const = 0;
41     MEDCOUPLING_EXPORT virtual PartDefinition *tryToSimplify() const = 0;
42   protected:
43     virtual ~PartDefinition();
44   };
45
46   class SlicePartDefinition;
47
48   class DataArrayPartDefinition : public PartDefinition
49   {
50   public:
51     MEDCOUPLING_EXPORT static DataArrayPartDefinition *New(DataArrayInt *listOfIds);
52     MEDCOUPLING_EXPORT DataArrayInt *toDAI() const;
53     MEDCOUPLING_EXPORT int getNumberOfElems() const;
54     MEDCOUPLING_EXPORT PartDefinition *operator+(const PartDefinition& other) const;
55     MEDCOUPLING_EXPORT std::string getRepr() const;
56     MEDCOUPLING_EXPORT PartDefinition *composeWith(const PartDefinition *other) const;
57     MEDCOUPLING_EXPORT void checkCoherency() const;
58     MEDCOUPLING_EXPORT PartDefinition *tryToSimplify() const;
59   private:
60     DataArrayPartDefinition(DataArrayInt *listOfIds);
61     void checkInternalArrayOK() const;
62     static void CheckInternalArrayOK(const DataArrayInt *listOfIds);
63     MEDCOUPLING_EXPORT void updateTime() const;
64     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
65     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
66     DataArrayPartDefinition *add1(const DataArrayPartDefinition *other) const;
67     DataArrayPartDefinition *add2(const SlicePartDefinition *other) const;
68     virtual ~DataArrayPartDefinition();
69   private:
70     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _arr;
71   };
72
73   class SlicePartDefinition : public PartDefinition
74   {
75   public:
76     MEDCOUPLING_EXPORT static SlicePartDefinition *New(int start, int stop, int step);
77     MEDCOUPLING_EXPORT DataArrayInt *toDAI() const;
78     MEDCOUPLING_EXPORT int getNumberOfElems() const;
79     MEDCOUPLING_EXPORT PartDefinition *operator+(const PartDefinition& other) const;
80     MEDCOUPLING_EXPORT std::string getRepr() const;
81     MEDCOUPLING_EXPORT PartDefinition *composeWith(const PartDefinition *other) const;
82     MEDCOUPLING_EXPORT void checkCoherency() const;
83     MEDCOUPLING_EXPORT PartDefinition *tryToSimplify() const;
84     //specific method
85     MEDCOUPLING_EXPORT int getEffectiveStop() const;
86     MEDCOUPLING_EXPORT void getSlice(int& start, int& stop, int& step) const;
87   private:
88     SlicePartDefinition(int start, int stop, int step);
89     MEDCOUPLING_EXPORT void updateTime() const;
90     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
91     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
92     DataArrayPartDefinition *add1(const DataArrayPartDefinition *other) const;
93     PartDefinition *add2(const SlicePartDefinition *other) const;
94     virtual ~SlicePartDefinition();
95   private:
96     int _start;
97     int _stop;
98     int _step;
99   };
100 }
101
102 #endif