Convert to enum class

This commit is contained in:
Magne Sjaastad 2020-04-24 08:22:32 +02:00
parent 95fc63fe7c
commit 72fefb4db5
21 changed files with 54 additions and 47 deletions

View File

@ -43,7 +43,7 @@ RiaTextFileCompare::~RiaTextFileCompare()
//--------------------------------------------------------------------------------------------------
void RiaTextFileCompare::reset()
{
m_lastError = IC_NO_ERROR;
m_lastError = ErrorType::IC_NO_ERROR;
m_errorMsg.clear();
m_errorDetails.clear();
m_diffOutput.clear();
@ -77,7 +77,7 @@ bool RiaTextFileCompare::runComparison( const QString& baseFolder, const QString
QProcess::ProcessError procError = proc.error();
if ( procError != QProcess::UnknownError )
{
m_lastError = SEVERE_ERROR;
m_lastError = ErrorType::SEVERE_ERROR;
m_errorMsg = "Error running 'diff' tool process";
m_errorDetails = completeCommand;
return false;
@ -102,7 +102,7 @@ bool RiaTextFileCompare::runComparison( const QString& baseFolder, const QString
stdErr = stdErr.simplified();
// Report non-severe error
m_lastError = IC_ERROR;
m_lastError = ErrorType::IC_ERROR;
m_errorMsg = "Error running 'diff' tool process";
m_errorDetails = stdErr;

View File

@ -28,7 +28,7 @@
class RiaTextFileCompare
{
public:
enum ErrorType
enum class ErrorType
{
IC_NO_ERROR, // No error occurred
IC_ERROR, // An error occurred

View File

@ -31,14 +31,14 @@ namespace caf
template <>
void RicfCommandFileExecutor::ExportTypeEnum::setUp()
{
addItem( RicfCommandFileExecutor::COMPLETIONS, "COMPLETIONS", "Completions" );
addItem( RicfCommandFileExecutor::PROPERTIES, "PROPERTIES", "Properties" );
addItem( RicfCommandFileExecutor::SNAPSHOTS, "SNAPSHOTS", "Snapshots" );
addItem( RicfCommandFileExecutor::STATISTICS, "STATISTICS", "Statistics" );
addItem( RicfCommandFileExecutor::WELLPATHS, "WELLPATHS", "Well Path" );
addItem( RicfCommandFileExecutor::CELLS, "CELLS", "Cells" );
addItem( RicfCommandFileExecutor::LGRS, "LGRS", "Lgrs" );
setDefault( RicfCommandFileExecutor::COMPLETIONS );
addItem( RicfCommandFileExecutor::ExportType::COMPLETIONS, "COMPLETIONS", "Completions" );
addItem( RicfCommandFileExecutor::ExportType::PROPERTIES, "PROPERTIES", "Properties" );
addItem( RicfCommandFileExecutor::ExportType::SNAPSHOTS, "SNAPSHOTS", "Snapshots" );
addItem( RicfCommandFileExecutor::ExportType::STATISTICS, "STATISTICS", "Statistics" );
addItem( RicfCommandFileExecutor::ExportType::WELLPATHS, "WELLPATHS", "Well Path" );
addItem( RicfCommandFileExecutor::ExportType::CELLS, "CELLS", "Cells" );
addItem( RicfCommandFileExecutor::ExportType::LGRS, "LGRS", "Lgrs" );
setDefault( RicfCommandFileExecutor::ExportType::COMPLETIONS );
}
} // namespace caf

View File

@ -34,7 +34,7 @@ class RicfCommandObject;
class RicfCommandFileExecutor
{
public:
enum ExportType
enum class ExportType
{
COMPLETIONS,
SNAPSHOTS,

View File

@ -47,10 +47,10 @@ namespace caf
template <>
void AppEnum<MultipleFractures::Action>::setUp()
{
addItem( MultipleFractures::APPEND_FRACTURES, "APPEND_FRACTURES", "Append Fractures" );
addItem( MultipleFractures::REPLACE_FRACTURES, "REPLACE_FRACTURES", "Replace Fractures" );
addItem( MultipleFractures::Action::APPEND_FRACTURES, "APPEND_FRACTURES", "Append Fractures" );
addItem( MultipleFractures::Action::REPLACE_FRACTURES, "REPLACE_FRACTURES", "Replace Fractures" );
setDefault( MultipleFractures::NONE );
setDefault( MultipleFractures::Action::NONE );
}
} // namespace caf
@ -69,7 +69,7 @@ RicfCreateMultipleFractures::RicfCreateMultipleFractures()
CAF_PDM_InitScriptableFieldWithIO( &m_spacing, "spacing", 300.0, "Spacing", "", "", "" );
CAF_PDM_InitScriptableFieldWithIO( &m_action,
"action",
caf::AppEnum<MultipleFractures::Action>( MultipleFractures::APPEND_FRACTURES ),
caf::AppEnum<MultipleFractures::Action>( MultipleFractures::Action::APPEND_FRACTURES ),
"Action",
"",
"",
@ -161,8 +161,8 @@ caf::PdmScriptResponse RicfCreateMultipleFractures::execute()
if ( feature )
{
if ( m_action == MultipleFractures::APPEND_FRACTURES ) feature->appendFractures();
if ( m_action == MultipleFractures::REPLACE_FRACTURES ) feature->replaceFractures();
if ( m_action == MultipleFractures::Action::APPEND_FRACTURES ) feature->appendFractures();
if ( m_action == MultipleFractures::Action::REPLACE_FRACTURES ) feature->replaceFractures();
}
return caf::PdmScriptResponse();
}

View File

@ -25,7 +25,7 @@
namespace MultipleFractures
{
enum Action
enum class Action
{
NONE,
APPEND_FRACTURES,

View File

@ -85,7 +85,7 @@ caf::PdmScriptResponse RicfExportLgrForCompletions::execute()
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
}
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::LGRS );
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::LGRS );
if ( exportFolder.isNull() )
{
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "LGR" );

View File

@ -76,7 +76,8 @@ caf::PdmScriptResponse RicfExportMsw::execute()
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
}
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::COMPLETIONS );
QString exportFolder =
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::COMPLETIONS );
if ( exportFolder.isNull() )
{
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "completions" );

View File

@ -67,7 +67,8 @@ caf::PdmScriptResponse RicfExportMultiCaseSnapshots::execute()
std::vector<QString> listFileNames = RiaApplication::readFileListFromTextFile( m_gridListFile() );
app->runMultiCaseSnapshots( lastProjectPath,
listFileNames,
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::SNAPSHOTS ) );
RicfCommandFileExecutor::instance()->getExportPath(
RicfCommandFileExecutor::ExportType::SNAPSHOTS ) );
return caf::PdmScriptResponse();
}

View File

@ -98,7 +98,8 @@ caf::PdmScriptResponse RicfExportProperty::execute()
QString filePath = m_exportFileName;
if ( filePath.isNull() )
{
QDir propertiesDir( RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::PROPERTIES ) );
QDir propertiesDir(
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::PROPERTIES ) );
QString fileName = QString( "%1-%2" ).arg( eclipseCase->caseUserDescription() ).arg( m_propertyName );
fileName = caf::Utils::makeValidFileBasename( fileName );
filePath = propertiesDir.filePath( fileName );

View File

@ -139,7 +139,8 @@ caf::PdmScriptResponse RicfExportPropertyInViews::execute()
continue;
}
QDir propertiesDir( RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::PROPERTIES ) );
QDir propertiesDir(
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::PROPERTIES ) );
QString fileName = QString( "%1-%2-T%3-%4" )
.arg( eclipseCase->caseUserDescription() )

View File

@ -98,7 +98,8 @@ caf::PdmScriptResponse RicfExportSimWellFractureCompletions::execute()
exportSettings->caseToApply = eclipseCase;
}
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::COMPLETIONS );
QString exportFolder =
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::COMPLETIONS );
if ( exportFolder.isNull() )
{
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "completions" );

View File

@ -48,10 +48,10 @@ void RicfExportSnapshots::PreferredOutputFormatEnum::setUp()
template <>
void RicfExportSnapshots::SnapshotsTypeEnum::setUp()
{
addItem( RicfExportSnapshots::ALL, "ALL", "All" );
addItem( RicfExportSnapshots::VIEWS, "VIEWS", "Views" );
addItem( RicfExportSnapshots::PLOTS, "PLOTS", "Plots" );
setDefault( RicfExportSnapshots::ALL );
addItem( RicfExportSnapshots::SnapshotsType::ALL, "ALL", "All" );
addItem( RicfExportSnapshots::SnapshotsType::VIEWS, "VIEWS", "Views" );
addItem( RicfExportSnapshots::SnapshotsType::PLOTS, "PLOTS", "Plots" );
setDefault( RicfExportSnapshots::SnapshotsType::ALL );
}
} // namespace caf
@ -86,7 +86,7 @@ caf::PdmScriptResponse RicfExportSnapshots::execute()
RiaGuiApplication::instance()->processEvents();
QString absolutePathToSnapshotDir =
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::SNAPSHOTS );
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::SNAPSHOTS );
if ( !m_exportFolder().isEmpty() )
{
@ -97,7 +97,7 @@ caf::PdmScriptResponse RicfExportSnapshots::execute()
absolutePathToSnapshotDir =
RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "snapshots" );
}
if ( m_type == RicfExportSnapshots::VIEWS || m_type == RicfExportSnapshots::ALL )
if ( m_type == RicfExportSnapshots::SnapshotsType::VIEWS || m_type == RicfExportSnapshots::SnapshotsType::ALL )
{
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
{
@ -111,7 +111,7 @@ caf::PdmScriptResponse RicfExportSnapshots::execute()
m_caseId(),
m_viewId() );
}
if ( m_type == RicfExportSnapshots::PLOTS || m_type == RicfExportSnapshots::ALL )
if ( m_type == RicfExportSnapshots::SnapshotsType::PLOTS || m_type == RicfExportSnapshots::SnapshotsType::ALL )
{
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
{

View File

@ -42,7 +42,7 @@ public:
};
typedef caf::AppEnum<PlotOutputFormat> PreferredOutputFormatEnum;
enum SnapshotsType
enum class SnapshotsType
{
VIEWS,
PLOTS,

View File

@ -50,10 +50,10 @@ namespace caf
template <>
void AppEnum<RicfExportVisibleCells::ExportKeyword>::setUp()
{
addItem( RicfExportVisibleCells::FLUXNUM, "FLUXNUM", "FLUXNUM" );
addItem( RicfExportVisibleCells::MULTNUM, "MULTNUM", "MULTNUM" );
addItem( RicfExportVisibleCells::ExportKeyword::FLUXNUM, "FLUXNUM", "FLUXNUM" );
addItem( RicfExportVisibleCells::ExportKeyword::MULTNUM, "MULTNUM", "MULTNUM" );
setDefault( RicfExportVisibleCells::FLUXNUM );
setDefault( RicfExportVisibleCells::ExportKeyword::FLUXNUM );
}
} // namespace caf
@ -119,7 +119,7 @@ caf::PdmScriptResponse RicfExportVisibleCells::execute()
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
}
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::CELLS );
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::CELLS );
if ( exportFolder.isNull() )
{
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "visibleCells" );

View File

@ -36,7 +36,7 @@ class RicfExportVisibleCells : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
enum ExportKeyword
enum class ExportKeyword
{
FLUXNUM,
MULTNUM

View File

@ -37,9 +37,9 @@ namespace caf
template <>
void RicfExportWellLogPlotData::ExportFormatEnum::setUp()
{
addItem( RicfExportWellLogPlotData::LAS, "LAS", "LAS" );
addItem( RicfExportWellLogPlotData::ASCII, "ASCII", "ASCII" );
setDefault( RicfExportWellLogPlotData::LAS );
addItem( RicfExportWellLogPlotData::ExportFormat::LAS, "LAS", "LAS" );
addItem( RicfExportWellLogPlotData::ExportFormat::ASCII, "ASCII", "ASCII" );
setDefault( RicfExportWellLogPlotData::ExportFormat::LAS );
}
} // namespace caf
@ -90,7 +90,7 @@ caf::PdmScriptResponse RicfExportWellLogPlotData::execute()
{
if ( plot->id() == m_viewId() )
{
if ( m_format() == ASCII )
if ( m_format() == ExportFormat::ASCII )
{
QString validFileName =
RicAsciiExportWellLogPlotFeature::makeValidExportFileName( plot,

View File

@ -49,7 +49,7 @@ class RicfExportWellLogPlotData : public RicfCommandObject
public:
// Values are exposed in gRPC .proto. Do not change without also changing .proto
enum ExportFormat
enum class ExportFormat
{
LAS,
ASCII

View File

@ -158,7 +158,8 @@ caf::PdmScriptResponse RicfExportWellPathCompletions::execute()
exportSettings->caseToApply = eclipseCase;
}
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::COMPLETIONS );
QString exportFolder =
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::COMPLETIONS );
if ( exportFolder.isNull() )
{
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "completions" );

View File

@ -78,7 +78,8 @@ caf::PdmScriptResponse RicfExportWellPaths::execute()
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
}
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::WELLPATHS );
QString exportFolder =
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::WELLPATHS );
if ( exportFolder.isNull() )
{
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "wellpaths" );

View File

@ -33,7 +33,7 @@ CAF_PDM_SOURCE_INIT( RicfSetExportFolder, "setExportFolder" );
RicfSetExportFolder::RicfSetExportFolder()
{
// clang-format off
CAF_PDM_InitScriptableFieldWithIO(&m_type, "type", RicfCommandFileExecutor::ExportTypeEnum(RicfCommandFileExecutor::COMPLETIONS), "Type", "", "", "");
CAF_PDM_InitScriptableFieldWithIO(&m_type, "type", RicfCommandFileExecutor::ExportTypeEnum(RicfCommandFileExecutor::ExportType::COMPLETIONS), "Type", "", "", "");
CAF_PDM_InitScriptableFieldWithIO(&m_path, "path", QString(), "Path", "", "", "");
CAF_PDM_InitScriptableFieldWithIO(&m_createFolder, "createFolder", false, "Create Folder", "", "", "");
// clang-format on