mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Extract two utility methods to make loadAndSyncronizeInputProperties smaller.
This commit is contained in:
@@ -62,15 +62,7 @@ void RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties(
|
|||||||
QFileInfo fileNameInfo( filenames[i] );
|
QFileInfo fileNameInfo( filenames[i] );
|
||||||
bool isExistingFile = fileNameInfo.exists();
|
bool isExistingFile = fileNameInfo.exists();
|
||||||
|
|
||||||
std::set<QString> fileKeywordSet;
|
std::set<QString> fileKeywordSet = extractKeywordsOnFile( filenames[i], isExistingFile );
|
||||||
|
|
||||||
if ( isExistingFile )
|
|
||||||
{
|
|
||||||
std::vector<RifKeywordAndFilePos> fileKeywords;
|
|
||||||
RifEclipseInputFileTools::findKeywordsOnFile( filenames[i], &fileKeywords );
|
|
||||||
|
|
||||||
for_all( fileKeywords, fkIt ) fileKeywordSet.insert( fileKeywords[fkIt].keyword );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the input property objects referring to the file
|
// Find the input property objects referring to the file
|
||||||
|
|
||||||
@@ -128,13 +120,8 @@ void RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for_all( inputPropertyCollection->inputProperties, i )
|
// All input properties still unknown at this stage is missing a file
|
||||||
{
|
setResolvedState( inputPropertyCollection, RimEclipseInputProperty::UNKNOWN, RimEclipseInputProperty::FILE_MISSING );
|
||||||
if ( inputPropertyCollection->inputProperties[i]->resolvedState() == RimEclipseInputProperty::UNKNOWN )
|
|
||||||
{
|
|
||||||
inputPropertyCollection->inputProperties[i]->resolvedState = RimEclipseInputProperty::FILE_MISSING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RifEclipseInputPropertyLoader::readInputPropertiesFromFiles( RimEclipseInputPropertyCollection* inputPropertyCollection,
|
bool RifEclipseInputPropertyLoader::readInputPropertiesFromFiles( RimEclipseInputPropertyCollection* inputPropertyCollection,
|
||||||
@@ -173,3 +160,32 @@ bool RifEclipseInputPropertyLoader::readInputPropertiesFromFiles( RimEclipseInpu
|
|||||||
// TODO: seems a bit optimistic?
|
// TODO: seems a bit optimistic?
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<QString> RifEclipseInputPropertyLoader::extractKeywordsOnFile( const QString& filename, bool isExistingFile )
|
||||||
|
{
|
||||||
|
std::set<QString> fileKeywordSet;
|
||||||
|
if ( isExistingFile )
|
||||||
|
{
|
||||||
|
std::vector<RifKeywordAndFilePos> fileKeywords;
|
||||||
|
RifEclipseInputFileTools::findKeywordsOnFile( filename, &fileKeywords );
|
||||||
|
|
||||||
|
for ( const RifKeywordAndFilePos& fileKeyword : fileKeywords )
|
||||||
|
{
|
||||||
|
fileKeywordSet.insert( fileKeyword.keyword );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fileKeywordSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RifEclipseInputPropertyLoader::setResolvedState( RimEclipseInputPropertyCollection* inputPropertyCollection,
|
||||||
|
RimEclipseInputProperty::ResolveState currentState,
|
||||||
|
RimEclipseInputProperty::ResolveState newState )
|
||||||
|
{
|
||||||
|
for ( RimEclipseInputProperty* inputProperty : inputPropertyCollection->inputProperties )
|
||||||
|
{
|
||||||
|
if ( inputProperty->resolvedState() == currentState )
|
||||||
|
{
|
||||||
|
inputProperty->resolvedState = newState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "RimEclipseInputProperty.h"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -45,4 +48,10 @@ private:
|
|||||||
// Hide constructor to prevent instantiation
|
// Hide constructor to prevent instantiation
|
||||||
RifEclipseInputPropertyLoader();
|
RifEclipseInputPropertyLoader();
|
||||||
~RifEclipseInputPropertyLoader();
|
~RifEclipseInputPropertyLoader();
|
||||||
|
|
||||||
|
static std::set<QString> extractKeywordsOnFile( const QString& filename, bool isExistingFile );
|
||||||
|
|
||||||
|
static void setResolvedState( RimEclipseInputPropertyCollection* inputPropertyCollection,
|
||||||
|
RimEclipseInputProperty::ResolveState currentState,
|
||||||
|
RimEclipseInputProperty::ResolveState newState );
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user