Horizon
track.hpp
1 #pragma once
2 #include "block/net.hpp"
3 #include "board_package.hpp"
4 #include "common/common.hpp"
5 #include "board_junction.hpp"
6 #include "nlohmann/json_fwd.hpp"
7 #include "util/uuid.hpp"
8 #include "util/uuid_ptr.hpp"
9 
10 namespace horizon {
11 using json = nlohmann::json;
12 
13 class Track {
14 public:
15  Track(const UUID &uu, const json &j, class Board *brd = nullptr);
16  Track(const UUID &uu);
17 
18  void update_refs(class Board &brd);
19  UUID get_uuid() const;
20  bool coord_on_line(const Coordi &coord) const;
21  bool is_parallel_to(const Track &other) const;
22 
23  UUID uuid;
24  uuid_ptr<Net> net = nullptr;
25  int layer = 0;
26  uint64_t width = 0;
27  bool width_from_rules = true;
28 
29  bool locked = false;
30 
31  class Connection {
32  public:
33  Connection()
34  {
35  }
36  Connection(const json &j, Board *brd = nullptr);
38  Connection(BoardPackage *pkg, Pad *pad);
39  uuid_ptr<BoardJunction> junc = nullptr;
40  uuid_ptr<BoardPackage> package = nullptr;
41  uuid_ptr<Pad> pad = nullptr;
42  Coordi offset;
43  bool operator<(const Track::Connection &other) const;
44  bool operator==(const Track::Connection &other) const;
45 
46  void connect(BoardJunction *j);
47  void connect(BoardPackage *pkg, Pad *pad);
48  UUIDPath<2> get_pad_path() const;
49  bool is_junc() const;
50  bool is_pad() const;
51  void update_refs(class Board &brd);
52  Coordi get_position() const;
53  LayerRange get_layer() const;
54  Net *get_net();
55 
56  json serialize() const;
57  };
58 
59  Connection from;
60  Connection to;
61 
62  json serialize() const;
63 };
64 } // namespace horizon
Definition: board_junction.hpp:6
Definition: board_package.hpp:13
Definition: board.hpp:47
Definition: layer_range.hpp:7
Definition: net.hpp:11
Definition: pad.hpp:12
Definition: track.hpp:31
Definition: track.hpp:13
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: uuid_ptr.hpp:8
a class to store JSON values
Definition: json.hpp:177
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62