#3106 Ensemble calculations. Hash only ensemble parameters common to all cases. Move cases validation

This commit is contained in:
Bjørn Erik Jensen
2018-07-04 14:36:14 +02:00
parent 224f379ea6
commit cc87da2ae0
9 changed files with 193 additions and 76 deletions

View File

@@ -115,6 +115,16 @@ std::map<QString, RigCaseRealizationParameters::Value> RigCaseRealizationParamet
return m_parameters;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<QString> RigCaseRealizationParameters::parameterNames() const
{
std::set<QString> names;
for (auto& par : parameters()) names.insert(par.first);
return names;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -143,16 +153,41 @@ size_t RigCaseRealizationParameters::parameterHash(const QString& name) const
//--------------------------------------------------------------------------------------------------
size_t RigCaseRealizationParameters::parametersHash()
{
if (m_parametersHash == 0)
if (m_parametersHash == 0) calculateParametersHash();
return m_parametersHash;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseRealizationParameters::clearParametersHash()
{
m_parametersHash = 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseRealizationParameters::calculateParametersHash(const std::set<QString>& paramNames /*= std::set<QString>()*/)
{
QStringList hashes;
if (paramNames.empty())
{
QStringList hashes;
for (auto param : m_parameters)
{
hashes.push_back(QString::number(parameterHash(param.first)));
}
std::hash<std::string> stringHasher;
m_parametersHash = stringHasher(hashes.join("").toStdString());
}
return m_parametersHash;
else
{
for (auto paramName : paramNames)
{
if (m_parameters.find(paramName) == m_parameters.end()) return;
hashes.push_back(QString::number(parameterHash(paramName)));
}
}
std::hash<std::string> stringHasher;
m_parametersHash = stringHasher(hashes.join("").toStdString());
}