Modernize memory management: Convert m_mainGrid to std::shared_ptr

Replace cvf::ref<RigMainGrid> with std::shared_ptr<RigMainGrid> in
RigEclipseCaseData and related classes to use standard C++ smart pointers.

Changes:
- RigEclipseCaseData: Convert m_mainGrid member to shared_ptr, add
  mainGridShared() accessor methods
- RimIdenticalGridCaseGroup: Update grid sharing logic to use shared_ptr
- RigGridManager: Store and return shared_ptr for grid deduplication
- RimEclipseStatisticsCase: Update setMainGrid() signature
- RimEclipseResultCase: Use mainGridShared() for grid copying
- RimEclipseCaseCollection: Update grid deduplication to work with shared_ptr
- RifReaderOpmCommonActive: Wrap RigActiveCellGrid in shared_ptr
- Test updates: Convert tests to use std::shared_ptr and .use_count()

Grid sharing and deduplication functionality preserved. RigMainGrid retains
cvf::Object inheritance for framework compatibility, but std::shared_ptr
handles all reference counting.

All grid-related tests pass (26/26).
This commit is contained in:
Kristian Bendiksen committed 2025-12-22 19:19:33 +01:00
1 parent 96eebdf8ef
commit db0fce493b
12 files changed
+75 -65

No files matched your search

@@ -56,7 +56,7 @@ RifReaderOpmCommonActive::~RifReaderOpmCommonActive()
bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclipseCaseData* eclipseCaseData )
{
RigActiveCellGrid* activeGrid = new RigActiveCellGrid();
eclipseCaseData->setMainGrid( activeGrid );
eclipseCaseData->setMainGrid( std::shared_ptr<RigMainGrid>( activeGrid ) );
caf::ProgressInfo progInfo( 4, "Importing Eclipse Grid" );