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 
32  bool locked = false;
33 
34  class Connection {
35  public:
36  Connection()
37  {
38  }
39  Connection(const json &j, Board *brd = nullptr);
40  Connection(Junction *j);
41  Connection(BoardPackage *pkg, Pad *pad);
42  uuid_ptr<Junction> 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(Junction *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  UUID get_net_segment() const;
54  void update_refs(class Board &brd);
55  Coordi get_position() const;
56  int get_layer() const;
57  Net *get_net();
58 
59  json serialize() const;
60  };
61 
62  Connection from;
63  Connection to;
64 
65  json serialize() const;
66 };
67 } // 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:44
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:165
horizon::Track::Connection
Definition: track.hpp:34
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