changed: hide the templated 'has' and 'get' interfaces in FieldPropsManager
motivation: an upcoming parallel frontend to the field props manager. templated functions cannot be virtualized, and thus having these exposed would give a great chance of confusing the users in the downstream code, where properties would be caught from the (potentially) empty backend instead of from the frontend.
This commit is contained in:
+10
-10
@@ -10,35 +10,35 @@
|
||||
namespace {
|
||||
|
||||
bool contains( const FieldPropsManager& manager, const std::string& kw) {
|
||||
if (manager.has<int>(kw))
|
||||
if (manager.has_int(kw))
|
||||
return true;
|
||||
if (manager.has<double>(kw))
|
||||
if (manager.has_double(kw))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
py::array_t<double> get_double_array(const FieldPropsManager& m, const std::string& kw) {
|
||||
if (m.has<double>(kw))
|
||||
return convert::numpy_array( m.get<double>(kw) );
|
||||
if (m.has_double(kw))
|
||||
return convert::numpy_array( m.get_double(kw) );
|
||||
else
|
||||
throw std::invalid_argument("Keyword '" + kw + "'is not of type double.");
|
||||
}
|
||||
|
||||
py::array_t<int> get_int_array(const FieldPropsManager& m, const std::string& kw) {
|
||||
if (m.has<int>(kw))
|
||||
return convert::numpy_array( m.get<int>(kw) );
|
||||
if (m.has_int(kw))
|
||||
return convert::numpy_array( m.get_int(kw) );
|
||||
else
|
||||
throw std::invalid_argument("Keyword '" + kw + "'is not of type int.");
|
||||
}
|
||||
|
||||
|
||||
py::array get_array(const FieldPropsManager& m, const std::string& kw) {
|
||||
if (m.has<double>(kw))
|
||||
return convert::numpy_array(m.get<double>(kw));
|
||||
if (m.has_double(kw))
|
||||
return convert::numpy_array(m.get_double(kw));
|
||||
|
||||
if (m.has<int>(kw))
|
||||
return convert::numpy_array(m.get<int>(kw));
|
||||
if (m.has_int(kw))
|
||||
return convert::numpy_array(m.get_int(kw));
|
||||
|
||||
throw std::invalid_argument("No such keyword: " + kw);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user