Horizon
line_net.hpp
1 #pragma once
2 #include "util/uuid.hpp"
3 #include "nlohmann/json_fwd.hpp"
4 #include "common/common.hpp"
5 #include "common/junction.hpp"
6 #include "util/uuid_ptr.hpp"
7 #include "schematic_symbol.hpp"
8 #include "block/net.hpp"
9 #include "block/bus.hpp"
10 #include "power_symbol.hpp"
11 #include "bus_ripper.hpp"
12 #include <vector>
13 #include <map>
14 #include <fstream>
15 
16 namespace horizon {
17 using json = nlohmann::json;
18 
23 class LineNet {
24 public:
25  enum class End { TO, FROM };
26 
27  LineNet(const UUID &uu, const json &j, class Sheet *sheet = nullptr);
28  LineNet(const UUID &uu);
29 
30  void update_refs(class Sheet &sheet);
31  bool is_connected_to(const UUID &uu_sym, const UUID &uu_pin) const;
32  UUID get_uuid() const;
33  bool coord_on_line(const Coordi &coord) const;
34 
35  uuid_ptr<Net> net = nullptr;
36  uuid_ptr<Bus> bus = nullptr;
37  UUID net_segment = UUID();
38 
39 
40  UUID uuid;
41 
42  class Connection {
43  public:
44  Connection()
45  {
46  }
47  Connection(const json &j, Sheet *sheet);
48  uuid_ptr<Junction> junc = nullptr;
49  uuid_ptr<SchematicSymbol> symbol = nullptr;
50  uuid_ptr<SymbolPin> pin = nullptr;
51  uuid_ptr<BusRipper> bus_ripper = nullptr;
52  bool operator<(const Connection &other) const;
53  bool operator==(const Connection &other) const;
54 
55  void connect(Junction *j);
56  void connect(BusRipper *r);
57  void connect(SchematicSymbol *j, SymbolPin *pin);
58  UUIDPath<2> get_pin_path() const;
59  bool is_junc() const;
60  bool is_pin() const;
61  bool is_bus_ripper() const;
62  UUID get_net_segment() const;
63  void update_refs(class Sheet &sheet);
64  Coordi get_position() const;
65  json serialize() const;
66  };
67 
68  Connection from;
69  Connection to;
70 
71 
72  json serialize() const;
73 };
74 } // namespace horizon
horizon::LineNet::Connection
Definition: line_net.hpp:42
horizon::uuid_ptr
Definition: uuid_ptr.hpp:8
horizon::LineNet
LineNet is similar to Line, except it denotes electrical connection.
Definition: line_net.hpp:23
horizon::SchematicSymbol
Definition: schematic_symbol.hpp:17
horizon::Coord< int64_t >
horizon::SymbolPin
Definition: symbol.hpp:19
horizon::Sheet
Definition: sheet.hpp:38
horizon::UUIDPath< 2 >
horizon::Junction
A Junction is a point in 2D-Space.
Definition: junction.hpp:22
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:166
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::BusRipper
Make a Bus member's Net available on the schematic.
Definition: bus_ripper.hpp:20