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