Add generic version of getXxxValue
This allows us to call getIntegerValue/getFloatingPointValue from generic code where the type to be used is a template parameter.
This commit is contained in:
@@ -1178,4 +1178,16 @@ void EclipseGridParser::getNumericErtFields(const string& filename)
|
||||
#endif // HAVE_ERT
|
||||
}
|
||||
|
||||
// specializations for those types that can be provided; attempts
|
||||
// to access other types than these will result in linker error
|
||||
template <> const std::vector<int>&
|
||||
EclipseGridParser::getValue<int> (const std::string& keyword) const {
|
||||
return this->getIntegerValue(keyword);
|
||||
}
|
||||
|
||||
template <> const std::vector<double>&
|
||||
EclipseGridParser::getValue<double> (const std::string& keyword) const {
|
||||
return this->getFloatingPointValue(keyword);
|
||||
}
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
@@ -138,6 +138,12 @@ namespace Opm
|
||||
/// corresponding to the given floating-point keyword.
|
||||
const std::vector<double>& getFloatingPointValue(const std::string& keyword) const;
|
||||
|
||||
/// Returns a reference to a vector containing the values
|
||||
/// corresponding to the given keyword of a type only known
|
||||
/// indirectly (through a template)
|
||||
template <typename T>
|
||||
const std::vector<T>& getValue(const std::string& keyword) const;
|
||||
|
||||
typedef std::shared_ptr<SpecialBase> SpecialFieldPtr;
|
||||
|
||||
/// Returns a reference to a vector containing pointers to the values
|
||||
|
||||
Reference in New Issue
Block a user