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  Track(const UUID &uu, const json &j, class Board *brd = nullptr);
20  Track(const UUID &uu);
21 
22  void update_refs(class Board &brd);
23  virtual UUID get_uuid() const;
24  bool coord_on_line(const Coordi &coord) 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  bool is_air = false;
32 
33  bool locked = false;
34 
35  class Connection {
36  public:
37  Connection()
38  {
39  }
40  Connection(const json &j, Board *brd = nullptr);
41  Connection(Junction *j);
42  Connection(BoardPackage *pkg, Pad *pad);
43  uuid_ptr<Junction> junc = nullptr;
44  uuid_ptr<BoardPackage> package = nullptr;
45  uuid_ptr<Pad> pad = nullptr;
46  bool operator<(const Track::Connection &other) const;
47  bool operator==(const Track::Connection &other) const;
48 
49  void connect(Junction *j);
50  void connect(BoardPackage *pkg, Pad *pad);
51  UUIDPath<2> get_pad_path() const;
52  bool is_junc() const;
53  bool is_pad() const;
54  UUID get_net_segment() const;
55  void update_refs(class Board &brd);
56  Coordi get_position() const;
57  int get_layer() const;
58  Net *get_net();
59 
60  json serialize() const;
61  };
62 
63  Connection from;
64  Connection to;
65 
66  json serialize() const;
67 };
68 } // namespace horizon
horizon::uuid_ptr
Definition: uuid_ptr.hpp:9
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
libzip::uint64_t
zip_uint64_t uint64_t
zip_uint64_t_t typedef.
Definition: zip.hpp:108
horizon::Pad
Definition: pad.hpp:16
horizon::Board
Definition: board.hpp:31
horizon::Net
Definition: net.hpp:16
horizon::Coord< int64_t >
horizon::BoardPackage
Definition: board_package.hpp:17
horizon::Track
Definition: track.hpp:17
horizon::UUIDPath< 2 >
horizon::Junction
A Junction is a point in 2D-Space.
Definition: junction.hpp:25
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:161
horizon::Track::Connection
Definition: track.hpp:35
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
horizon::UUIDProvider
Interface for objects that have a UUID.
Definition: uuid_provider.hpp:9