mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use GSL::not_null a few places as a test/example.
This commit is contained in:
parent
e797c5ccdf
commit
e8368327da
@ -705,9 +705,8 @@ bool RiaApplication::loadProject( const QString& projectFileName )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaApplication::saveProject( QString* errorMessage )
|
||||
bool RiaApplication::saveProject( gsl::not_null<QString*> errorMessage )
|
||||
{
|
||||
CAF_ASSERT( errorMessage );
|
||||
CAF_ASSERT( m_project.notNull() );
|
||||
|
||||
if ( !isProjectSavedToDisc() )
|
||||
@ -724,8 +723,9 @@ bool RiaApplication::saveProject( QString* errorMessage )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaApplication::saveProjectAs( const QString& fileName, QString* errorMessage )
|
||||
bool RiaApplication::saveProjectAs( const QString& fileName, gsl::not_null<QString*> errorMessage )
|
||||
{
|
||||
CAF_ASSERT( m_project.notNull() );
|
||||
// Make sure we always store path with forward slash to avoid issues when opening the project file on Linux
|
||||
m_project->fileName = RiaFilePathTools::toInternalSeparator( fileName );
|
||||
|
||||
@ -733,7 +733,6 @@ bool RiaApplication::saveProjectAs( const QString& fileName, QString* errorMessa
|
||||
|
||||
if ( !m_project->writeProjectFile() )
|
||||
{
|
||||
CAF_ASSERT( errorMessage );
|
||||
*errorMessage = QString( "Not possible to save project file. Make sure you have sufficient access "
|
||||
"rights.\n\nProject file location : %1" )
|
||||
.arg( fileName );
|
||||
@ -889,10 +888,9 @@ bool RiaApplication::openOdbCaseFromFile( const QString& fileName, bool applyTim
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Add a list of well path file paths (JSON files) to the well path collection
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimWellPath*> RiaApplication::addWellPathsToModel( QList<QString> wellPathFilePaths, QStringList* errorMessages )
|
||||
std::vector<RimWellPath*> RiaApplication::addWellPathsToModel( QList<QString> wellPathFilePaths,
|
||||
gsl::not_null<QStringList*> errorMessages )
|
||||
{
|
||||
CAF_ASSERT( errorMessages );
|
||||
|
||||
if ( m_project == nullptr || m_project->oilFields.size() < 1 ) return {};
|
||||
|
||||
RimOilField* oilField = m_project->activeOilField();
|
||||
@ -946,10 +944,8 @@ void RiaApplication::addWellPathFormationsToModel( QList<QString> wellPathFormat
|
||||
/// Add a list of well log file paths (LAS files) to the well path collection
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimWellLogFile*> RiaApplication::addWellLogsToModel( const QList<QString>& wellLogFilePaths,
|
||||
QStringList* errorMessages )
|
||||
gsl::not_null<QStringList*> errorMessages )
|
||||
{
|
||||
CAF_ASSERT( errorMessages );
|
||||
|
||||
if ( m_project == nullptr || m_project->oilFields.size() < 1 ) return {};
|
||||
|
||||
RimOilField* oilField = m_project->activeOilField();
|
||||
@ -1776,10 +1772,8 @@ void RiaApplication::resetProject()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaApplication::generateCode( const QString& fileName, QString* errMsg )
|
||||
bool RiaApplication::generateCode( const QString& fileName, gsl::not_null<QString*> errMsg )
|
||||
{
|
||||
CAF_ASSERT( errMsg );
|
||||
|
||||
std::string fileExt = QFileInfo( fileName ).suffix().toStdString();
|
||||
|
||||
{
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include <QProcessEnvironment>
|
||||
#include <QString>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
@ -131,8 +133,8 @@ public:
|
||||
bool loadProject( const QString& projectFileName );
|
||||
bool loadProject( const QString& projectFileName, ProjectLoadAction loadAction, RiaProjectModifier* projectModifier );
|
||||
|
||||
bool saveProject( QString* errorMessage );
|
||||
bool saveProjectAs( const QString& fileName, QString* errorMessage );
|
||||
bool saveProject( gsl::not_null<QString*> errorMessage );
|
||||
bool saveProjectAs( const QString& fileName, gsl::not_null<QString*> errorMessage );
|
||||
|
||||
static bool hasValidProjectFileExtension( const QString& fileName );
|
||||
void closeProject();
|
||||
@ -144,9 +146,11 @@ public:
|
||||
|
||||
bool openOdbCaseFromFile( const QString& fileName, bool applyTimeStepFilter = false );
|
||||
|
||||
std::vector<RimWellPath*> addWellPathsToModel( QList<QString> wellPathFilePaths, QStringList* errorMessages );
|
||||
std::vector<RimWellPath*> addWellPathsToModel( QList<QString> wellPathFilePaths,
|
||||
gsl::not_null<QStringList*> errorMessages );
|
||||
void addWellPathFormationsToModel( QList<QString> wellPathFilePaths );
|
||||
std::vector<RimWellLogFile*> addWellLogsToModel( const QList<QString>& wellLogFilePaths, QStringList* errorMessages );
|
||||
std::vector<RimWellLogFile*> addWellLogsToModel( const QList<QString>& wellLogFilePaths,
|
||||
gsl::not_null<QStringList*> errorMessages );
|
||||
|
||||
QString scriptDirectories() const;
|
||||
QString scriptEditorPath() const;
|
||||
@ -196,7 +200,7 @@ public:
|
||||
|
||||
// Public implementation specific overrides
|
||||
virtual void initialize();
|
||||
virtual ApplicationStatus handleArguments( cvf::ProgramOptions* progOpt ) = 0;
|
||||
virtual ApplicationStatus handleArguments( gsl::not_null<cvf::ProgramOptions*> progOpt ) = 0;
|
||||
virtual int launchUnitTestsWithConsole();
|
||||
virtual void addToRecentFiles( const QString& fileName ) {}
|
||||
virtual void showFormattedTextInMessageBoxOrConsole( const QString& errMsg ) = 0;
|
||||
@ -227,7 +231,7 @@ protected:
|
||||
friend class RiaRegressionTestRunner;
|
||||
void resetProject();
|
||||
|
||||
bool generateCode( const QString& outputPath, QString* errMsg );
|
||||
bool generateCode( const QString& outputPath, gsl::not_null<QString*> errMsg );
|
||||
|
||||
protected:
|
||||
cvf::ref<cvf::Font> m_defaultSceneFont;
|
||||
|
@ -112,10 +112,8 @@ void RiaConsoleApplication::initialize()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaApplication::ApplicationStatus RiaConsoleApplication::handleArguments( cvf::ProgramOptions* progOpt )
|
||||
RiaApplication::ApplicationStatus RiaConsoleApplication::handleArguments( gsl::not_null<cvf::ProgramOptions*> progOpt )
|
||||
{
|
||||
CVF_ASSERT( progOpt );
|
||||
|
||||
// Handling of the actual command line options
|
||||
// --------------------------------------------------------
|
||||
if ( cvf::Option o = progOpt->option( "ignoreArgs" ) )
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
|
||||
// Public RiaApplication overrides
|
||||
void initialize() override;
|
||||
ApplicationStatus handleArguments( cvf::ProgramOptions* progOpt ) override;
|
||||
ApplicationStatus handleArguments( gsl::not_null<cvf::ProgramOptions*> progOpt ) override;
|
||||
void showFormattedTextInMessageBoxOrConsole( const QString& errMsg ) override;
|
||||
void launchGrpcServer() override;
|
||||
#ifdef ENABLE_GRPC
|
||||
|
@ -441,10 +441,8 @@ void RiaGuiApplication::initialize()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( cvf::ProgramOptions* progOpt )
|
||||
RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_null<cvf::ProgramOptions*> progOpt )
|
||||
{
|
||||
CVF_ASSERT( progOpt );
|
||||
|
||||
// Handling of the actual command line options
|
||||
// --------------------------------------------------------
|
||||
if ( cvf::Option o = progOpt->option( "ignoreArgs" ) )
|
||||
|
@ -136,7 +136,7 @@ public:
|
||||
|
||||
// Public RiaApplication overrides
|
||||
void initialize() override;
|
||||
ApplicationStatus handleArguments( cvf::ProgramOptions* progOpt ) override;
|
||||
ApplicationStatus handleArguments( gsl::not_null<cvf::ProgramOptions*> progOpt ) override;
|
||||
int launchUnitTestsWithConsole() override;
|
||||
void addToRecentFiles( const QString& fileName ) override;
|
||||
void showFormattedTextInMessageBoxOrConsole( const QString& errMsg ) override;
|
||||
|
@ -37,27 +37,22 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCase* summaryCase,
|
||||
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( gsl::not_null<RimSummaryCase*> summaryCase,
|
||||
const RifEclipseSummaryAddress& summaryAddress,
|
||||
bool isEnsembleCurve )
|
||||
: m_summaryCase( summaryCase )
|
||||
, m_summaryAddress( summaryAddress )
|
||||
, m_isEnsembleCurve( isEnsembleCurve )
|
||||
{
|
||||
CAF_ASSERT( summaryCase );
|
||||
|
||||
if ( summaryCase )
|
||||
{
|
||||
RimSummaryCaseCollection* ensemble = nullptr;
|
||||
summaryCase->firstAncestorOfType( ensemble );
|
||||
m_ensemble = ensemble;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble,
|
||||
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( gsl::not_null<RimSummaryCaseCollection*> ensemble,
|
||||
const RifEclipseSummaryAddress& summaryAddress )
|
||||
: m_summaryCase( nullptr )
|
||||
, m_summaryAddress( summaryAddress )
|
||||
@ -101,10 +96,9 @@ bool RiaSummaryCurveDefinition::isEnsembleCurve() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSummaryCurveDefinition::resultValues( const RiaSummaryCurveDefinition& curveDefinition, std::vector<double>* values )
|
||||
void RiaSummaryCurveDefinition::resultValues( const RiaSummaryCurveDefinition& curveDefinition,
|
||||
gsl::not_null<std::vector<double>*> values )
|
||||
{
|
||||
CVF_ASSERT( values );
|
||||
|
||||
if ( !curveDefinition.summaryAddress().isValid() ) return;
|
||||
if ( !curveDefinition.summaryCase() ) return;
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl>
|
||||
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCaseCollection;
|
||||
|
||||
@ -35,10 +37,11 @@ class RiaSummaryCurveDefinition
|
||||
{
|
||||
public:
|
||||
RiaSummaryCurveDefinition();
|
||||
explicit RiaSummaryCurveDefinition( RimSummaryCase* summaryCase,
|
||||
explicit RiaSummaryCurveDefinition( gsl::not_null<RimSummaryCase*> summaryCase,
|
||||
const RifEclipseSummaryAddress& summaryAddress,
|
||||
bool isEnsembleCurve );
|
||||
explicit RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddress );
|
||||
explicit RiaSummaryCurveDefinition( gsl::not_null<RimSummaryCaseCollection*> ensemble,
|
||||
const RifEclipseSummaryAddress& summaryAddress );
|
||||
|
||||
RimSummaryCase* summaryCase() const;
|
||||
const RifEclipseSummaryAddress& summaryAddress() const;
|
||||
@ -48,7 +51,7 @@ public:
|
||||
bool operator<( const RiaSummaryCurveDefinition& other ) const;
|
||||
|
||||
// TODO: Consider moving to a separate tools class
|
||||
static void resultValues( const RiaSummaryCurveDefinition& curveDefinition, std::vector<double>* values );
|
||||
static void resultValues( const RiaSummaryCurveDefinition& curveDefinition, gsl::not_null<std::vector<double>*> values );
|
||||
static const std::vector<time_t>& timeSteps( const RiaSummaryCurveDefinition& curveDefinition );
|
||||
|
||||
QString curveDefinitionText() const;
|
||||
|
Loading…
Reference in New Issue
Block a user