From 16b60a404aa2462723cec9c052b5c8e805d78bce Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 18 Dec 2012 10:38:15 +0000 Subject: [PATCH] AutoRef::retn --- src/MEDLoader/MEDFileField.cxx | 32 ++++++++---------------- src/MEDLoader/MEDFileMesh.cxx | 40 ++++++++++-------------------- src/MEDLoader/MEDFileMeshLL.cxx | 6 ++--- src/MEDLoader/SauvMedConvertor.cxx | 3 +-- src/MEDLoader/SauvReader.cxx | 6 ++--- 5 files changed, 28 insertions(+), 59 deletions(-) diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 783ae845a..1f14a7a30 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -2084,8 +2084,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const } } // - ret->incrRef(); - return ret; + return ret.retn(); } /*! @@ -2110,8 +2109,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, cons m2->setName(mesh->getName()); MEDCouplingAutoRefCountObjectPtr ret=finishField(type,glob,dads,locs,m2,isPfl); isPfl=true; - ret->incrRef(); - return ret; + return ret.retn(); } /*! @@ -2143,8 +2141,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileField meshuc->finishInsertingCells(); ret->setMesh(meshuc); ret->checkCoherency(); - ret->incrRef(); - return ret; + return ret.retn(); } } // @@ -2161,8 +2158,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileField ret->getArray()->renumberInPlace(da3->getConstPointer()); mesh2->setName(mesh->getName()); ret->setMesh(mesh2); - ret->incrRef(); - return ret; + return ret.retn(); } else { @@ -2200,8 +2196,7 @@ DataArrayDouble *MEDFileFieldPerMesh::finishField4(const std::vectorsetInfoOnComponent(i,infos[i].c_str()); safePfl->incrRef(); - da->incrRef(); - return da; + return da.retn(); } MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder), @@ -3554,8 +3549,7 @@ MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfF case 0: { //no need to test _field_per_mesh.empty() because geMeshName has already done it - ret->incrRef(); - return ret; + return ret.retn(); } case 3: case 1: @@ -3574,10 +3568,7 @@ MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfF ret->renumberCells(cellRenum->getConstPointer(),true); } if(renumPol==1) - { - ret->incrRef(); - return ret; - } + return ret.retn(); } case 2: { @@ -3595,8 +3586,7 @@ MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfF MEDCouplingAutoRefCountObjectPtr nodeRenumSafe=nodeRenum->checkAndPreparePermutation(); ret->renumberNodes(nodeRenumSafe->getConstPointer()); } - ret->incrRef(); - return ret; + return ret.retn(); } default: throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !"); @@ -4837,8 +4827,7 @@ MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTE const MEDFileField1TSWithoutSDA *item=_content->getTimeStepAtPos2(pos); MEDCouplingAutoRefCountObjectPtr ret=MEDFileField1TS::New(*item,false); ret->shallowCpyGlobs(*this); - ret->incrRef(); - return ret; + return ret.retn(); } MEDFileField1TS *MEDFileFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception) @@ -5481,8 +5470,7 @@ MEDFileFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERN const MEDFileFieldMultiTSWithoutSDA *fmts=_fields[i]; MEDCouplingAutoRefCountObjectPtr ret=MEDFileFieldMultiTS::New(*fmts,false); ret->shallowCpyGlobs(*this); - ret->incrRef(); - return ret; + return ret.retn(); } MEDFileFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 5c5ccd8f8..fc0461d03 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -58,15 +58,13 @@ MEDFileMesh *MEDFileMesh::New(const char *fileName) throw(INTERP_KERNEL::Excepti { MEDCouplingAutoRefCountObjectPtr ret=MEDFileUMesh::New(); ret->loadUMeshFromFile(fid,ms.front().c_str(),dt,it); - ret->incrRef(); - return (MEDFileUMesh *)ret; + return (MEDFileUMesh *)ret.retn(); } case CARTESIAN: { MEDCouplingAutoRefCountObjectPtr ret=MEDFileCMesh::New(); ret->loadCMeshFromFile(fid,ms.front().c_str(),dt,it); - ret->incrRef(); - return (MEDFileCMesh *)ret; + return (MEDFileCMesh *)ret.retn(); } default: { @@ -90,15 +88,13 @@ MEDFileMesh *MEDFileMesh::New(const char *fileName, const char *mName, int dt, i { MEDCouplingAutoRefCountObjectPtr ret=MEDFileUMesh::New(); ret->loadUMeshFromFile(fid,mName,dt,it); - ret->incrRef(); - return (MEDFileUMesh *)ret; + return (MEDFileUMesh *)ret.retn(); } case CARTESIAN: { MEDCouplingAutoRefCountObjectPtr ret=MEDFileCMesh::New(); ret->loadCMeshFromFile(fid,mName,dt,it); - ret->incrRef(); - return (MEDFileCMesh *)ret; + return (MEDFileCMesh *)ret.retn(); } default: { @@ -855,7 +851,7 @@ DataArrayInt *MEDFileMesh::getAllFamiliesIdsReferenced() const throw(INTERP_KERN v.insert((*it).second); ret->alloc((int)v.size(),1); std::copy(v.begin(),v.end(),ret->getPointer()); - ret->incrRef(); return ret; + return ret.retn(); } /*! @@ -1832,8 +1828,7 @@ MEDCouplingUMesh *MEDFileUMesh::getFamilies(int meshDimRelToMaxExt, const std::v MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New(); MEDCouplingAutoRefCountObjectPtr c=_coords->selectByTupleId(arr->getConstPointer(),arr->getConstPointer()+arr->getNbOfElems()); ret->setCoords(c); - ret->incrRef(); - return ret; + return ret.retn(); } std::vector famIds=getFamiliesIds(fams); const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt); @@ -1858,10 +1853,7 @@ DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::ve if(renum) return MEDFileUMeshSplitL1::Renumber(_num_coords,da); else - { - da->incrRef(); - return da; - } + return da.retn(); } else throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamiliesArr : no family array specified on nodes !"); @@ -2110,9 +2102,9 @@ void MEDFileUMesh::duplicateNodesOnM1Group(const char *grpNameM1, DataArrayInt * newFam->setPartOfValuesSimple1(0,nbNodes,newNbOfNodes,1,0,1,1); _fam_coords=newFam; } - nodesDuplicated=nodeIdsToDuplicate; nodeIdsToDuplicate->incrRef(); - cellsModified=cellsToModifyConn0; cellsToModifyConn0->incrRef(); - cellsNotModified=cellsToModifyConn1; cellsToModifyConn1->incrRef(); + nodesDuplicated=nodeIdsToDuplicate.retn(); + cellsModified=cellsToModifyConn0.retn(); + cellsNotModified=cellsToModifyConn1.retn(); } /*! @@ -2180,7 +2172,7 @@ bool MEDFileUMesh::unPolyze(std::vector& oldCode, std::vector& newCode { MEDCouplingAutoRefCountObjectPtr renumCells=DataArrayInt::Aggregate(renumCellsSplited); MEDCouplingAutoRefCountObjectPtr o2nRenumCellRet=renumCells->buildPermArrPerLevel(); - o2nRenumCell=o2nRenumCellRet; o2nRenumCellRet->incrRef(); + o2nRenumCell=o2nRenumCellRet.retn(); } return ret; } @@ -2803,10 +2795,7 @@ DataArrayInt *MEDFileCMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::ve if(renum) return MEDFileUMeshSplitL1::Renumber(_num_nodes,da); else - { - da->incrRef(); - return da; - } + return da.retn(); } else throw INTERP_KERNEL::Exception("MEDFileCMesh::getFamiliesArr : no family array specified on nodes !"); @@ -2823,10 +2812,7 @@ DataArrayInt *MEDFileCMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::ve if(renum) return MEDFileUMeshSplitL1::Renumber(_num_cells,da); else - { - da->incrRef(); - return da; - } + return da.retn(); } else throw INTERP_KERNEL::Exception("MEDFileCMesh::getFamiliesArr : no family array specified on cells !"); diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index cfb86ad46..3774a0516 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -611,8 +611,7 @@ DataArrayInt *MEDFileUMeshSplitL1::getFamilyPartArr(const int *idsBg, const int MEDCouplingAutoRefCountObjectPtr da=_fam->getIdsEqualList(idsBg,idsEnd); if(renum) return renumIfNeededArr(da); - da->incrRef(); - return da; + return da.retn(); } MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const @@ -622,8 +621,7 @@ MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const tmp=_m; else tmp=_m_by_types; - tmp->incrRef(); - return tmp; + return tmp.retn(); } const DataArrayInt *MEDFileUMeshSplitL1::getFamilyField() const diff --git a/src/MEDLoader/SauvMedConvertor.cxx b/src/MEDLoader/SauvMedConvertor.cxx index 75e1d0c13..bf2c9d1d0 100644 --- a/src/MEDLoader/SauvMedConvertor.cxx +++ b/src/MEDLoader/SauvMedConvertor.cxx @@ -1118,8 +1118,7 @@ ParaMEDMEM::MEDFileData* IntermediateMED::convertInMEDFileDS() medData->setMeshes( meshes ); if ( fields ) medData->setFields( fields ); - medData->incrRef(); - return medData; + return medData.retn(); } //================================================================================ diff --git a/src/MEDLoader/SauvReader.cxx b/src/MEDLoader/SauvReader.cxx index 720d34b65..5b17dcdf7 100644 --- a/src/MEDLoader/SauvReader.cxx +++ b/src/MEDLoader/SauvReader.cxx @@ -55,8 +55,7 @@ SauvReader* SauvReader::New(const char *fileName) throw(INTERP_KERNEL::Exception if ( parser->open() ) { SauvReader* reader = new SauvReader; - reader->_fileReader = parser; - parser->incrRef(); + reader->_fileReader = parser.retn(); return reader; } @@ -65,8 +64,7 @@ SauvReader* SauvReader::New(const char *fileName) throw(INTERP_KERNEL::Exception if ( parser->open() ) { SauvReader* reader = new SauvReader; - reader->_fileReader = parser; - parser->incrRef(); + reader->_fileReader = parser.retn(); return reader; } -- 2.39.2