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  CLEARANCE_SAME_NET,
27  SYMBOL_CHECKS,
28  CLEARANCE_PACKAGE,
29 };
30 
31 extern const LutEnumStr<RuleID> rule_id_lut;
32 
34 public:
35  virtual UUID get_net_class(const UUID &uu) const
36  {
37  return uu;
38  }
39  virtual int get_order(int order) const
40  {
41  return order;
42  }
43  virtual bool is_imported() const
44  {
45  return false;
46  }
47 
48  virtual ~RuleImportMap()
49  {
50  }
51 };
52 
53 class Rule {
54  friend class Rules;
55 
56 public:
57  Rule(const UUID &uu);
58  Rule(const json &j);
59  Rule(const json &j, const RuleImportMap &import_map);
60  Rule(const UUID &uu, const json &j);
61  Rule(const UUID &uu, const json &j, const RuleImportMap &import_map);
62  UUID uuid;
63  RuleID id = RuleID::NONE;
64  bool enabled = true;
65  bool imported = false;
66  int get_order() const
67  {
68  return order;
69  }
70 
71  virtual json serialize() const;
72  virtual std::string get_brief(const class Block *block = nullptr) const = 0;
73  virtual bool is_match_all() const
74  {
75  return false;
76  }
77 
78  virtual bool can_export() const
79  {
80  return false;
81  }
82 
83  virtual ~Rule();
84 
85  enum class SerializeMode { SERIALIZE, EXPORT };
86 
87 protected:
88  Rule();
89 
90 private:
91  int order = -1;
92 };
93 } // namespace horizon
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
Definition: rule.hpp:33
Definition: rule.hpp:53
Definition: rules.hpp:48
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