visitor.h 636 B

1234567891011121314151617181920212223
  1. #pragma once
  2. #include <jvalidate/forward.h>
  3. #define VISITOR_PURE_VIRTUAL(TYPE) virtual Status visit(TYPE const &) const = 0;
  4. namespace jvalidate::constraint {
  5. /**
  6. * @brief The base interface for visitors to be implemented off of.
  7. * Provides a visit function for every provided concrete type of Constraint,
  8. * as well as the ExtensionConstraint interface.
  9. */
  10. struct ConstraintVisitor {
  11. virtual ~ConstraintVisitor() = default;
  12. CONSTRAINT_IMPLEMENTATION_LIST(VISITOR_PURE_VIRTUAL);
  13. };
  14. template <typename Cons> struct ExtensionConstraintVisitor {
  15. virtual Status visit(Cons const &) const = 0;
  16. };
  17. }
  18. #undef VISITOR_PURE_VIRTUAL