Salome HOME
updated copyright message
[tools/medcoupling.git] / src / ICoCo / ICoCoMEDDoubleField.cxx
1 // Copyright (C) 2007-2023  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
20 #include "ICoCoMEDDoubleField.hxx"
21 #include "MEDCouplingFieldDouble.hxx"
22
23 namespace ICoCo
24 {
25   MEDDoubleField::MEDDoubleField() : _field(0) {}
26
27   MEDDoubleField::MEDDoubleField(MEDCoupling::MEDCouplingFieldDouble *field):_field(field)
28   {
29     if(_field)
30       {
31         _field->incrRef();
32         setName(_field->getName());
33       }
34     else
35       setName("");
36   }
37
38   MEDDoubleField::MEDDoubleField(const MEDDoubleField& field):_field(field.getMCField())
39   {
40     if(_field)
41       _field->incrRef();
42     setName(field.getName());
43   }
44
45   MEDDoubleField::~MEDDoubleField()
46   {
47     if(_field)
48       _field->decrRef();
49   }
50
51   MEDDoubleField& MEDDoubleField::operator=(const MEDDoubleField& field)
52   {
53     if (_field)
54       _field->decrRef();
55
56     _field=field.getMCField();
57     if(_field)
58       _field->incrRef();
59     setName(field.getName());
60     return *this;
61   }
62
63   MEDCoupling::MEDCouplingFieldDouble *MEDDoubleField::getMCField() const
64   {
65     return _field;
66   }
67
68   void MEDDoubleField::setMCField(MEDCoupling::MEDCouplingFieldDouble * f)
69   {
70     if(_field)
71       _field->decrRef();
72     _field = f;
73     if(f != nullptr)
74       {
75         _field->incrRef();
76         setName(_field->getName());
77       }
78     else
79       setName("");
80   }
81
82 }