Horizon
Loading...
Searching...
No Matches
db.hpp
1#pragma once
2#include "common/common.hpp"
3#include "util/placement.hpp"
4#include "util/uuid.hpp"
5#include <list>
6#include <set>
7#include <variant>
8#include "attributes.hpp"
9#include "clipper/clipper.hpp"
10#include "board/plane.hpp"
11#include "eda_data.hpp"
12#include "attribute_util.hpp"
13#include "features.hpp"
14#include "components.hpp"
15#include "symbol.hpp"
16
17namespace horizon {
18class TreeWriter;
19class Padstack;
20class Shape;
21class Polygon;
22class Package;
23class Pad;
24class BoardPackage;
25class LayerProvider;
26} // namespace horizon
27
28namespace horizon::ODB {
29
30class Symbol;
31
32enum class Polarity { POSITIVE, NEGATIVE };
33
34class Step {
35public:
36 std::map<std::string, Features> layer_features;
37 std::optional<Features> profile;
38
39 std::optional<Components> comp_top;
40 std::optional<Components> comp_bot;
41
42 EDAData eda_data;
43
44 Components::Component &add_component(const BoardPackage &pkg);
45
46 void write(TreeWriter &writer) const;
47};
48
49class Matrix {
50public:
51 std::map<std::string, unsigned int> steps; // step name -> column
52
53 class Layer {
54 public:
55 Layer(unsigned int r, const std::string &n) : row(r), name(n)
56 {
57 }
58
59 const unsigned int row;
60 const std::string name;
61
62 enum class Context { BOARD, MISC };
63 Context context;
64
65 enum class Type {
66 SIGNAL,
67 SOLDER_MASK,
68 SILK_SCREEN,
69 SOLDER_PASTE,
70 DRILL,
71 ROUT,
72 DOCUMENT,
73 COMPONENT,
74 MASK,
75 CONDUCTIVE_PASTE,
76 };
77 Type type;
78 struct Span {
79 std::string start;
80 std::string end;
81 };
82 std::optional<Span> span;
83
84 enum class Subtype {
85 COVERLAY,
86 COVERCOAT,
87 STIFFENER,
88 BEND_AREA,
89 FLEX_AREA,
90 RIGID_AREA,
91 PSA,
92 SILVER_MASK,
93 CARBON_MASK,
94 };
95 std::optional<Subtype> add_type;
96
97 Polarity polarity = Polarity::POSITIVE;
98 };
99 std::vector<Layer> layers;
100
101 Layer &add_layer(const std::string &name);
102 void add_step(const std::string &name);
103
104 void write(std::ostream &ost) const;
105
106private:
107 unsigned int row = 1;
108 unsigned int col = 1;
109};
110
111class Job {
112public:
113 Matrix matrix;
114 Matrix::Layer &add_matrix_layer(const std::string &name);
115 Step &add_step(const std::string &name);
116
117 std::string job_name = "board";
118 std::map<std::string, Step> steps;
119
120 using SymbolKey = std::tuple<UUID, int, std::string>; // padstack UUID, layer, content hash
121 std::map<SymbolKey, Symbol> symbols;
122 std::set<std::string> symbol_names;
123
124 std::string get_or_create_symbol(const Padstack &ps, int layer, const LayerProvider &lprv);
125
126 void write(TreeWriter &writer) const;
127};
128
129std::string enum_to_string(Polarity);
130std::string enum_to_string(Matrix::Layer::Type);
131std::string enum_to_string(Matrix::Layer::Context);
132
133
134} // namespace horizon::ODB
Definition board_package.hpp:13
Definition layer_provider.hpp:8
Definition layer.hpp:5
Definition components.hpp:25
Definition eda_data.hpp:17
Definition db.hpp:111
Definition db.hpp:53
Definition db.hpp:49
Definition db.hpp:34
Definition symbol.hpp:13
Definition package.hpp:29
Definition pad.hpp:12
Definition padstack.hpp:19
Polygon used in Padstack, Package and Board for specifying filled Regions.
Definition polygon.hpp:28
For commonly used Pad shapes.
Definition shape.hpp:15
Definition tree_writer.hpp:7