9#include <pybind11/functional.h>
10#include <pybind11/stl.h>
19 const std::string& errorMessage, std::function<
bool(
void)>& isValidFunction, py::args& args) {
21 for(
const auto& arg : args) {
22 if(py::type::of(arg).is(py::type::of<PyScalarAccessor>())) {
26 else if(py::type::of(arg).is(py::type::of<PyArrayAccessor>())) {
31 throw ChimeraTK::logic_error(
"Invalid accessor type " + py::type::of(arg).attr(
"__name__").cast<std::string>());
39 py::class_<PyUserInputValidator>(m,
"UserInputValidator")
48 py::overload_cast<
PyArrayAccessor&,
const UserTypeTemplateVariantNoVoid<Vector>&>(
55 acc.
visit([&](
auto& accessor) {
56 using Accessor =
typename std::remove_reference_t<
decltype(accessor)>;
57 using UserType =
typename Accessor::value_type;
59 [&](
auto value) {
_impl.
setFallback(accessor, ChimeraTK::userTypeToUserType<UserType>(value)); }, inputValue);
66 PyArrayAccessor& acc,
const UserTypeTemplateVariantNoVoid<Vector>& inputValue) {
67 acc.
visit([&](
auto& accessor) {
68 using Accessor =
typename std::remove_reference_t<
decltype(accessor)>;
69 using UserType =
typename Accessor::value_type;
72 std::vector<UserType> converted(vector.size());
73 std::transform(vector.begin(), vector.end(), converted.begin(),
74 [](
auto& value) { return userTypeToUserType<UserType>(value); });
Helper class acting as a ArrayAccessor with a variant UserType.
auto visit(CALLABLE fn) const
InvalidityTracer application module.