Horizon
rule.hpp
1 #pragma once
2 #include "nlohmann/json_fwd.hpp"
3 #include "rule_match.hpp"
4 #include "util/uuid.hpp"
5 #include "common/lut.hpp"
6 
7 namespace horizon {
8 using json = nlohmann::json;
9 
10 enum class RuleID {
11  NONE,
12  HOLE_SIZE,
13  CLEARANCE_SILKSCREEN_EXPOSED_COPPER,
14  TRACK_WIDTH,
15  CLEARANCE_COPPER,
16  SINGLE_PIN_NET,
17  PARAMETERS,
18  VIA,
19  CLEARANCE_COPPER_OTHER,
20  PLANE,
21  DIFFPAIR,
22  PACKAGE_CHECKS,
23  PREFLIGHT_CHECKS,
24  CLEARANCE_COPPER_KEEPOUT,
25  LAYER_PAIR
26 };
27 
28 extern const LutEnumStr<RuleID> rule_id_lut;
29 
30 class Rule {
31  friend class Rules;
32 
33 public:
34  Rule(const UUID &uu);
35  Rule(const json &j);
36  Rule(const UUID &uu, const json &j);
37  UUID uuid;
38  RuleID id = RuleID::NONE;
39  bool enabled = true;
40  int get_order() const
41  {
42  return order;
43  }
44 
45  virtual json serialize() const;
46  virtual std::string get_brief(const class Block *block = nullptr) const = 0;
47  virtual bool is_match_all() const
48  {
49  return false;
50  }
51 
52  virtual ~Rule();
53 
54 protected:
55  Rule();
56 
57 private:
58  int order = -1;
59 };
60 } // namespace horizon
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Rules
Definition: rules.hpp:47
horizon::Rule
Definition: rule.hpp:30
horizon::Block
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:165
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16