Change API for PdmObjectHandle and PdmFieldHandle

* Refactor interface to PdmObjectHandle and PdmFieldHandle
Return objects instead of passing in structures as parameters

* Add nodiscard to several functions
* Remove redundant this->
* Rename to ptrReferencedObjectsByType
This commit is contained in:
Magne Sjaastad
2023-05-12 21:41:34 +02:00
committed by GitHub
parent 37e29a0f68
commit 0c90f67dcc
510 changed files with 1651 additions and 3111 deletions

View File

@@ -265,8 +265,7 @@ QString RiaEnsembleNameTools::uniqueShortNameForSummaryCase( RimSummaryCase* sum
{
std::set<QString> allAutoShortNames;
std::vector<RimSummaryCase*> allCases;
RimProject::current()->descendantsOfType( allCases );
std::vector<RimSummaryCase*> allCases = RimProject::current()->descendantsOfType<RimSummaryCase>();
for ( auto sumCase : allCases )
{

View File

@@ -60,8 +60,7 @@ RigEclipseWellLogExtractor* RiaExtractionTools::findOrCreateSimWellExtractor( co
auto wlPlotCollection = wellLogPlotCollection();
if ( !wlPlotCollection ) return nullptr;
RimEclipseCase* eclipseCase = nullptr;
simWell->firstAncestorOrThisOfType( eclipseCase );
auto eclipseCase = simWell->firstAncestorOrThisOfType<RimEclipseCase>();
if ( !( eclipseCase && eclipseCase->eclipseCaseData() ) )
{
return nullptr;

View File

@@ -123,11 +123,10 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
auto existingSummaryCase = sumCaseColl->findTopLevelSummaryCaseFromFileName( newSumCase->summaryHeaderFilename() );
if ( existingSummaryCase )
{
existingSummaryCase->firstAncestorOrThisOfType( existingCollection );
existingCollection = existingSummaryCase->firstAncestorOrThisOfType<RimSummaryCaseCollection>();
// Replace file summary case pointers in Rft Curves
std::vector<RimWellLogRftCurve*> rftCurves;
existingSummaryCase->objectsWithReferringPtrFieldsOfType( rftCurves );
auto rftCurves = existingSummaryCase->objectsWithReferringPtrFieldsOfType<RimWellLogRftCurve>();
for ( RimWellLogRftCurve* curve : rftCurves )
{
if ( curve->summaryCase() == existingSummaryCase )
@@ -138,8 +137,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
// Replace all occurrences of file sum with ecl sum
std::vector<RimSummaryCurve*> objects;
existingSummaryCase->objectsWithReferringPtrFieldsOfType( objects );
auto objects = existingSummaryCase->objectsWithReferringPtrFieldsOfType<RimSummaryCurve>();
// UI settings of a curve filter is updated based
// on the new case association for the curves in the curve filter
@@ -158,8 +156,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList&
summaryCurve->setSummaryCaseY( newSumCase );
}
RimSummaryCurveCollection* parentCollection = nullptr;
summaryCurve->firstAncestorOrThisOfType( parentCollection );
auto parentCollection = summaryCurve->firstAncestorOrThisOfType<RimSummaryCurveCollection>();
if ( parentCollection )
{
parentCollection->loadDataAndUpdate( true );

View File

@@ -44,9 +44,8 @@ void RiaOptionItemFactory::appendOptionItemsForEnsembleCurveSets( QList<caf::Pdm
{
options->push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
RimMainPlotCollection* mainPlotColl = RimMainPlotCollection::current();
std::vector<RimEnsembleCurveSet*> ensembleCurveSets;
mainPlotColl->descendantsOfType( ensembleCurveSets );
RimMainPlotCollection* mainPlotColl = RimMainPlotCollection::current();
std::vector<RimEnsembleCurveSet*> ensembleCurveSets = mainPlotColl->descendantsOfType<RimEnsembleCurveSet>();
for ( auto ensembleCurveSet : ensembleCurveSets )
{
options->push_back( caf::PdmOptionItemInfo( ensembleCurveSet->name(), ensembleCurveSet ) );

View File

@@ -127,14 +127,12 @@ RimSummaryPlot* RiaSummaryTools::parentSummaryPlot( caf::PdmObject* object )
return nullptr;
}
RimSummaryPlot* summaryPlot = nullptr;
if ( object )
{
object->firstAncestorOrThisOfType( summaryPlot );
return object->firstAncestorOrThisOfType<RimSummaryPlot>();
}
return summaryPlot;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -142,14 +140,12 @@ RimSummaryPlot* RiaSummaryTools::parentSummaryPlot( caf::PdmObject* object )
//--------------------------------------------------------------------------------------------------
RimSummaryMultiPlotCollection* RiaSummaryTools::parentSummaryPlotCollection( caf::PdmObject* object )
{
RimSummaryMultiPlotCollection* summaryPlotColl = nullptr;
if ( object )
{
object->firstAncestorOrThisOfType( summaryPlotColl );
return object->firstAncestorOrThisOfType<RimSummaryMultiPlotCollection>();
}
return summaryPlotColl;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -157,14 +153,12 @@ RimSummaryMultiPlotCollection* RiaSummaryTools::parentSummaryPlotCollection( caf
//--------------------------------------------------------------------------------------------------
RimSummaryMultiPlot* RiaSummaryTools::parentSummaryMultiPlot( caf::PdmObject* object )
{
RimSummaryMultiPlot* multiPlot = nullptr;
if ( object )
{
object->firstAncestorOrThisOfType( multiPlot );
return object->firstAncestorOrThisOfType<RimSummaryMultiPlot>();
}
return multiPlot;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -172,14 +166,12 @@ RimSummaryMultiPlot* RiaSummaryTools::parentSummaryMultiPlot( caf::PdmObject* ob
//--------------------------------------------------------------------------------------------------
RimSummaryCrossPlot* RiaSummaryTools::parentCrossPlot( caf::PdmObject* object )
{
RimSummaryCrossPlot* crossPlot = nullptr;
if ( object )
{
object->firstAncestorOrThisOfType( crossPlot );
return object->firstAncestorOrThisOfType<RimSummaryCrossPlot>();
}
return crossPlot;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -187,14 +179,12 @@ RimSummaryCrossPlot* RiaSummaryTools::parentCrossPlot( caf::PdmObject* object )
//--------------------------------------------------------------------------------------------------
RimSummaryCrossPlotCollection* RiaSummaryTools::parentCrossPlotCollection( caf::PdmObject* object )
{
RimSummaryCrossPlotCollection* crossPlotColl = nullptr;
if ( object )
{
object->firstAncestorOrThisOfType( crossPlotColl );
return object->firstAncestorOrThisOfType<RimSummaryCrossPlotCollection>();
}
return crossPlotColl;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -210,14 +200,12 @@ bool RiaSummaryTools::isSummaryCrossPlot( const RimSummaryPlot* plot )
//--------------------------------------------------------------------------------------------------
RimSummaryTable* RiaSummaryTools::parentSummaryTable( caf::PdmObject* object )
{
RimSummaryTable* summaryTable = nullptr;
if ( object )
{
object->firstAncestorOrThisOfType( summaryTable );
return object->firstAncestorOrThisOfType<RimSummaryTable>();
}
return summaryTable;
return nullptr;
}
//--------------------------------------------------------------------------------------------------
@@ -225,14 +213,12 @@ RimSummaryTable* RiaSummaryTools::parentSummaryTable( caf::PdmObject* object )
//--------------------------------------------------------------------------------------------------
RimSummaryTableCollection* RiaSummaryTools::parentSummaryTableCollection( caf::PdmObject* object )
{
RimSummaryTableCollection* summaryTableColl = nullptr;
if ( object )
{
object->firstAncestorOrThisOfType( summaryTableColl );
return object->firstAncestorOrThisOfType<RimSummaryTableCollection>();
}
return summaryTableColl;
return nullptr;
}
//--------------------------------------------------------------------------------------------------