mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-24 16:30:02 -06:00
Parameters::IsSet split out parts of implementation
allows putting it in translation unit
This commit is contained in:
parent
98b33d582f
commit
741e97da61
@ -160,6 +160,24 @@ void Hide_(const std::string& paramName)
|
||||
paramInfo.isHidden = true;
|
||||
}
|
||||
|
||||
bool IsSet_(const std::string& paramName, bool errorIfNotRegistered)
|
||||
{
|
||||
if (errorIfNotRegistered) {
|
||||
if (MetaData::registrationOpen()) {
|
||||
throw std::runtime_error("Parameters can only checked after _all_ of them have "
|
||||
"been registered.");
|
||||
}
|
||||
|
||||
if (MetaData::registry().find(paramName) == MetaData::registry().end())
|
||||
throw std::runtime_error("Accessing parameter " + std::string(paramName) +
|
||||
" without prior registration is not allowed.");
|
||||
}
|
||||
|
||||
// check whether the parameter is in the parameter tree
|
||||
return MetaData::tree().hasKey(paramName);
|
||||
|
||||
}
|
||||
|
||||
void Register_(const std::string& paramName,
|
||||
const std::string& paramTypeName,
|
||||
const std::string& defaultValue,
|
||||
|
@ -87,6 +87,9 @@ auto getParamName()
|
||||
//! \brief Private implementation.
|
||||
void Hide_(const std::string& paramName);
|
||||
|
||||
//! \brief Private implementation.
|
||||
bool IsSet_(const std::string& paramName, bool errorIfNotRegistered);
|
||||
|
||||
//! \brief Private implementation.
|
||||
void Register_(const std::string& paramName,
|
||||
const std::string& paramTypeName,
|
||||
@ -428,21 +431,7 @@ void reset();
|
||||
template <class Param>
|
||||
bool IsSet(bool errorIfNotRegistered = true)
|
||||
{
|
||||
const std::string paramName = detail::getParamName<Param>();
|
||||
|
||||
if (errorIfNotRegistered) {
|
||||
if (MetaData::registrationOpen()) {
|
||||
throw std::runtime_error("Parameters can only checked after _all_ of them have "
|
||||
"been registered.");
|
||||
}
|
||||
|
||||
if (MetaData::registry().find(paramName) == MetaData::registry().end())
|
||||
throw std::runtime_error("Accessing parameter " + std::string(paramName) +
|
||||
" without prior registration is not allowed.");
|
||||
}
|
||||
|
||||
// check whether the parameter is in the parameter tree
|
||||
return MetaData::tree().hasKey(paramName);
|
||||
return detail::IsSet_(detail::getParamName<Param>(), errorIfNotRegistered);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user