2 #include "clipper/clipper.hpp"
3 #include "common/common.hpp"
4 #include "nlohmann/json_fwd.hpp"
6 #include "util/uuid.hpp"
14 enum class RulesCheckErrorLevel { NOT_RUN, PASS, WARN, FAIL, DISABLED };
16 Color rules_check_error_level_to_color(RulesCheckErrorLevel lev);
17 std::string rules_check_error_level_to_string(RulesCheckErrorLevel lev);
24 RulesCheckErrorLevel level = RulesCheckErrorLevel::NOT_RUN;
28 bool has_location =
false;
29 ClipperLib::Paths error_polygons;
31 json serialize()
const;
38 json serialize()
const;
40 RulesCheckErrorLevel level = RulesCheckErrorLevel::NOT_RUN;
43 std::deque<RulesCheckError> errors;
46 typedef std::function<void(
const std::string &)> check_status_cb_t;
51 virtual void load_from_json(
const json &j) = 0;
54 throw std::logic_error(
"import_rules not implemented");
58 virtual json serialize()
const = 0;
59 virtual std::set<RuleID> get_rule_ids()
const = 0;
61 virtual const Rule *get_rule(RuleID
id)
const = 0;
62 Rule *get_rule(RuleID
id);
63 Rule *get_rule_nc(RuleID
id)
68 virtual const Rule *get_rule(RuleID
id,
const UUID &uu)
const = 0;
69 Rule *get_rule(RuleID
id,
const UUID &uu);
71 virtual std::map<UUID, const Rule *> get_rules(RuleID
id)
const = 0;
72 std::map<UUID, Rule *> get_rules(RuleID
id);
73 std::map<UUID, Rule *> get_rules_nc(RuleID
id)
78 template <
typename T = Rule> std::vector<const T *> get_rules_sorted(RuleID
id)
const
80 auto rs = get_rules(
id);
81 std::vector<const T *> rv;
82 rv.reserve(rs.size());
84 rv.push_back(
dynamic_cast<const T *
>(it.second));
86 std::sort(rv.begin(), rv.end(), [](
auto a,
auto b) { return a->order < b->order; });
90 template <
typename T = Rule> std::vector<T *> get_rules_sorted(RuleID
id)
93 auto rs =
static_cast<const Rules *
>(
this)->get_rules_sorted<T>(
id);
95 std::transform(rs.begin(), rs.end(), std::back_inserter(r), [](
auto x) { return const_cast<T *>(x); });
99 virtual void remove_rule(RuleID
id,
const UUID &uu) = 0;
100 virtual Rule *add_rule(RuleID
id) = 0;
101 void move_rule(RuleID
id,
const UUID &uu,
int dir);
105 virtual bool can_export()
const
111 void fix_order(RuleID
id);
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
a class to store JSON values
Definition: json.hpp:166
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61