From 542c1d719c4b51a8fcd9aacff51ef12e68104b2c Mon Sep 17 00:00:00 2001 From: abn Date: Thu, 13 Nov 2014 11:29:03 +0100 Subject: [PATCH] Added copy constructor and operator. --- src/ParaMEDMEM/ICoCoMEDField.cxx | 17 +++++++++++++++++ src/ParaMEDMEM/ICoCoMEDField.hxx | 2 ++ 2 files changed, 19 insertions(+) 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(); } -- 2.39.2