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