Cached result variables in the summary reader

Fixed late field initialization
Additional cleanup and rename
This commit is contained in:
Jacob Støren
2016-05-31 13:37:50 +02:00
parent 286c434d3a
commit 5732b5008f
6 changed files with 34 additions and 28 deletions

View File

@@ -47,7 +47,10 @@ RifReaderEclipseSummary::~RifReaderEclipseSummary()
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseSummary::open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames)
{
assert(ecl_sum == NULL);
assert(ecl_sum == NULL);
if (headerFileName.empty() || dataFileNames.size() == 0) return false;
assert(!headerFileName.empty());
assert(dataFileNames.size() > 0);
@@ -106,17 +109,18 @@ std::vector<std::string> RifReaderEclipseSummary::variableNames() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RifEclipseSummaryAddress> RifReaderEclipseSummary::allResultAddresses() const
const std::vector<RifEclipseSummaryAddress>& RifReaderEclipseSummary::allResultAddresses()
{
std::vector<RifEclipseSummaryAddress> addresses;
std::vector<std::string> fileVariableNames = variableNames();
for (size_t i = 0; i < fileVariableNames.size(); i++)
if (m_allResultAddresses.size() == 0)
{
addresses.push_back(RifEclipseSummaryAddress(fileVariableNames[i]));
std::vector<std::string> fileVariableNames = variableNames();
for(size_t i = 0; i < fileVariableNames.size(); i++)
{
m_allResultAddresses.push_back(RifEclipseSummaryAddress(fileVariableNames[i]));
}
}
return addresses;
return m_allResultAddresses;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -23,20 +23,17 @@
#include <string>
#include <vector>
#include "cvfObject.h"
class QDateTime;
// Taken from ecl_sum.h
typedef struct ecl_sum_struct ecl_sum_type;
// Taken from stringlist.h
typedef struct stringlist_struct stringlist_type;
//==================================================================================================
//
//
//==================================================================================================
class RifReaderEclipseSummary
class RifReaderEclipseSummary : public cvf::Object
{
public:
RifReaderEclipseSummary();
@@ -46,7 +43,7 @@ public:
void close();
std::vector<std::string> variableNames() const;
std::vector<RifEclipseSummaryAddress> allResultAddresses() const;
const std::vector<RifEclipseSummaryAddress>& allResultAddresses();
std::vector<time_t> timeSteps() const;
@@ -61,8 +58,14 @@ private:
int timeStepCount() const;
// Taken from stringlist.h
typedef struct stringlist_struct stringlist_type;
static void populateVectorFromStringList(stringlist_type* stringList, std::vector<std::string>* strings);
private:
// Taken from ecl_sum.h
typedef struct ecl_sum_struct ecl_sum_type;
ecl_sum_type* ecl_sum;
std::vector<RifEclipseSummaryAddress> m_allResultAddresses;
};