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 #include <fstream>
10 #include <map>
11 #include <vector>
12 
13 namespace horizon {
14 using json = nlohmann::json;
15 
16 class Track {
17 public:
18  Track(const UUID &uu, const json &j, class Board *brd = nullptr);
19  Track(const UUID &uu);
20 
21  void update_refs(class Board &brd);
22  UUID get_uuid() const;
23  bool coord_on_line(const Coordi &coord) const;
24  bool is_parallel_to(const Track &other) const;
25 
26  UUID uuid;
27  uuid_ptr<Net> net = nullptr;
28  int layer = 0;
29  uint64_t width = 0;
30  bool width_from_rules = true;
31 
32  bool locked = false;
33 
34  class Connection {
35  public:
36  Connection()
37  {
38  }
39  Connection(const json &j, Board *brd = nullptr);
41  Connection(BoardPackage *pkg, Pad *pad);
42  uuid_ptr<BoardJunction> junc = nullptr;
43  uuid_ptr<BoardPackage> package = nullptr;
44  uuid_ptr<Pad> pad = nullptr;
45  bool operator<(const Track::Connection &other) const;
46  bool operator==(const Track::Connection &other) const;
47 
48  void connect(BoardJunction *j);
49  void connect(BoardPackage *pkg, Pad *pad);
50  UUIDPath<2> get_pad_path() const;
51  bool is_junc() const;
52  bool is_pad() const;
53  void update_refs(class Board &brd);
54  Coordi get_position() const;
55  LayerRange get_layer() const;
56  Net *get_net();
57 
58  json serialize() const;
59  };
60 
61  Connection from;
62  Connection to;
63 
64  json serialize() const;
65 };
66 } // namespace horizon
Definition: board_junction.hpp:6
Definition: board_package.hpp:15
Definition: board.hpp:43
Definition: layer_range.hpp:7
Definition: net.hpp:11
Definition: pad.hpp:15
Definition: track.hpp:34
Definition: track.hpp:16
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
zip_uint64_t uint64_t
zip_uint64_t_t typedef.
Definition: zip.hpp:108
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62