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