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  CONNECTIVITY,
17  PARAMETERS,
18  VIA,
19  CLEARANCE_COPPER_OTHER,
20  PLANE,
21  DIFFPAIR,
22  PACKAGE_CHECKS,
23  SHORTED_PADS,
24  PREFLIGHT_CHECKS,
25  CLEARANCE_COPPER_KEEPOUT,
26  LAYER_PAIR,
27  CLEARANCE_SAME_NET,
28  SYMBOL_CHECKS,
29  CLEARANCE_PACKAGE,
30  THERMALS,
31  NET_TIES,
32  BOARD_CONNECTIVITY,
33 };
34 
35 extern const LutEnumStr<RuleID> rule_id_lut;
36 
38 public:
39  virtual UUID get_net_class(const UUID &uu) const
40  {
41  return uu;
42  }
43  virtual int get_order(int order) const
44  {
45  return order;
46  }
47  virtual bool is_imported() const
48  {
49  return false;
50  }
51 
52  virtual ~RuleImportMap()
53  {
54  }
55 };
56 
57 class Rule {
58  friend class Rules;
59 
60 public:
61  Rule(const UUID &uu);
62  Rule(const json &j);
63  Rule(const json &j, const RuleImportMap &import_map);
64  Rule(const UUID &uu, const json &j);
65  Rule(const UUID &uu, const json &j, const RuleImportMap &import_map);
66  UUID uuid;
67  virtual RuleID get_id() const = 0;
68  bool enabled = true;
69  bool imported = false;
70  int get_order() const
71  {
72  return order;
73  }
74 
75  virtual json serialize() const;
76  virtual std::string get_brief(const class Block *block = nullptr, class IPool *pool = nullptr) const = 0;
77  virtual bool is_match_all() const
78  {
79  return false;
80  }
81 
82  virtual bool can_export() const
83  {
84  return false;
85  }
86 
87  virtual ~Rule();
88 
89  enum class SerializeMode { SERIALIZE, EXPORT };
90 
91 protected:
92  Rule();
93 
94  static std::string layer_to_string(int layer);
95 
96 private:
97  int order = -1;
98 };
99 } // namespace horizon
A block is one level of hierarchy in the netlist.
Definition: block.hpp:29
Definition: ipool.hpp:14
Definition: rule.hpp:37
Definition: rule.hpp:57
Definition: rules.hpp:53
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:177
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62