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:
Roland Kaufmann
2013-11-04 09:20:27 +01:00
parent 1467a16a34
commit 7d7470d36b
2 changed files with 18 additions and 0 deletions

View File

@@ -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

View File

@@ -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