Horizon
track.hpp
1 #pragma once
2 #include "block/net.hpp"
3 #include "board_package.hpp"
4 #include "common/common.hpp"
5 #include "common/junction.hpp"
6 #include "nlohmann/json_fwd.hpp"
7 #include "util/uuid.hpp"
8 #include "util/uuid_provider.hpp"
9 #include "util/uuid_ptr.hpp"
10 #include <fstream>
11 #include <map>
12 #include <vector>
13 
14 namespace horizon {
15 using json = nlohmann::json;
16 
17 class Track : public UUIDProvider {
18 public:
19  enum class End { TO, FROM };
20 
21  Track(const UUID &uu, const json &j, class Board *brd = nullptr);
22  Track(const UUID &uu);
23 
24  void update_refs(class Board &brd);
25  virtual UUID get_uuid() const;
26  bool coord_on_line(const Coordi &coord) const;
27 
28  UUID uuid;
29  uuid_ptr<Net> net = nullptr;
30  int layer = 0;
31  uint64_t width = 0;
32  bool width_from_rules = true;
33  bool is_air = false;
34 
35  bool locked = false;
36 
37  class Connection {
38  public:
39  Connection()
40  {
41  }
42  Connection(const json &j, Board *brd = nullptr);
43  Connection(Junction *j);
44  Connection(BoardPackage *pkg, Pad *pad);
45  uuid_ptr<Junction> junc = nullptr;
46  uuid_ptr<BoardPackage> package = nullptr;
47  uuid_ptr<Pad> pad = nullptr;
48  bool operator<(const Track::Connection &other) const;
49  bool operator==(const Track::Connection &other) const;
50 
51  void connect(Junction *j);
52  void connect(BoardPackage *pkg, Pad *pad);
53  UUIDPath<2> get_pad_path() const;
54  bool is_junc() const;
55  bool is_pad() const;
56  UUID get_net_segment() const;
57  void update_refs(class Board &brd);
58  Coordi get_position() const;
59  int get_layer() const;
60 
61  json serialize() const;
62  };
63 
64  Connection from;
65  Connection to;
66 
67  json serialize() const;
68 };
69 } // namespace horizon
Definition: track.hpp:17
a class to store JSON values
Definition: json.hpp:161
Interface for objects that have a UUID.
Definition: uuid_provider.hpp:9
Definition: board.hpp:29
Definition: uuid_ptr.hpp:9
Definition: pad.hpp:20
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: block.cpp:9
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
A Junction is a point in 2D-Space.
Definition: junction.hpp:25
Definition: track.hpp:37
Definition: board_package.hpp:17