From: abn Date: Thu, 13 Nov 2014 10:29:03 +0000 (+0100) Subject: Added copy constructor and operator. X-Git-Tag: V7_5_0rc1~2^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=45254b0defdc12175effe8b9ea5a79f7cc9aa422;p=tools%2Fmedcoupling.git Added copy constructor and operator. --- diff --git a/src/ParaMEDMEM/ICoCoMEDField.cxx b/src/ParaMEDMEM/ICoCoMEDField.cxx index 907c2f329..ffab3a964 100644 --- a/src/ParaMEDMEM/ICoCoMEDField.cxx +++ b/src/ParaMEDMEM/ICoCoMEDField.cxx @@ -36,10 +36,27 @@ namespace ICoCo if(_field) _field->incrRef(); } + MEDField::MEDField(const MEDField& field):_field(field.getField()) + { + if(_field) + _field->incrRef(); + } MEDField::~MEDField() { if(_field) _field->decrRef(); } + + + MEDField& MEDField::operator=(const MEDField& field) + { + if (_field) + _field->decrRef(); + + _field=field.getField(); + if(_field) + _field->incrRef(); + return *this; + } } diff --git a/src/ParaMEDMEM/ICoCoMEDField.hxx b/src/ParaMEDMEM/ICoCoMEDField.hxx index 30a65005a..9e5244484 100644 --- a/src/ParaMEDMEM/ICoCoMEDField.hxx +++ b/src/ParaMEDMEM/ICoCoMEDField.hxx @@ -33,6 +33,8 @@ namespace ICoCo public: MEDField():_field(0) { } MEDField(ParaMEDMEM::MEDCouplingFieldDouble* field); + MEDField(const MEDField& field); + MEDField& operator=(const MEDField& field); virtual ~MEDField(); ParaMEDMEM::MEDCouplingFieldDouble *getField() const { return _field; } const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _field->getMesh(); }