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);
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  UUID net_segment = UUID();
31  int layer = 0;
32  uint64_t width = 0;
33  bool width_from_rules = true;
34  bool is_air = false;
35 
36  bool locked = false;
37 
38  class Connection {
39  public:
40  Connection()
41  {
42  }
43  Connection(const json &j, Board &brd);
44  Connection(Junction *j);
45  Connection(BoardPackage *pkg, Pad *pad);
46  uuid_ptr<Junction> junc = nullptr;
47  uuid_ptr<BoardPackage> package = nullptr;
48  uuid_ptr<Pad> pad = nullptr;
49  bool operator<(const Track::Connection &other) const;
50  bool operator==(const Track::Connection &other) const;
51 
52  void connect(Junction *j);
53  void connect(BoardPackage *pkg, Pad *pad);
54  UUIDPath<2> get_pad_path() const;
55  bool is_junc() const;
56  bool is_pad() const;
57  UUID get_net_segment() const;
58  void update_refs(class Board &brd);
59  Coordi get_position() const;
60  int get_layer() const;
61 
62  json serialize() const;
63  };
64 
65  Connection from;
66  Connection to;
67 
68  json serialize() const;
69 };
70 } // 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:28
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:7
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:38
Definition: board_package.hpp:17