Horizon
block.hpp
1 #pragma once
2 #include "bus.hpp"
3 #include "component.hpp"
4 #include "nlohmann/json_fwd.hpp"
5 #include "net.hpp"
6 #include "net_class.hpp"
7 #include "pool/pool.hpp"
8 #include "util/uuid.hpp"
9 #include "bom_export_settings.hpp"
10 #include <fstream>
11 #include <map>
12 #include <set>
13 #include <vector>
14 
15 namespace horizon {
16 using json = nlohmann::json;
17 
26 class Block {
27 public:
28  Block(const UUID &uu, const json &, Pool &pool);
29  Block(const UUID &uu);
30  static Block new_from_file(const std::string &filename, Pool &pool);
31  Net *get_net(const UUID &uu);
32  UUID uuid;
33  std::string name;
34  std::map<UUID, Net> nets;
35  std::map<UUID, Bus> buses;
36  std::map<UUID, Component> components;
37  std::map<UUID, NetClass> net_classes;
38  uuid_ptr<NetClass> net_class_default = nullptr;
39 
40  BOMExportSettings bom_export_settings;
41  std::map<const class Part *, BOMRow> get_BOM(const BOMExportSettings &settings) const;
42 
43  Block(const Block &block);
44  void operator=(const Block &block);
45 
46  void merge_nets(Net *net, Net *into);
47 
51  void vacuum_nets();
52 
58  Net *extract_pins(const std::set<UUIDPath<3>> &pins, Net *net = nullptr);
59 
60  void update_connection_count();
61 
62  void update_diffpairs();
63 
68  Net *insert_net();
69 
70  json serialize();
71 
72 private:
73  void update_refs();
74 };
75 } // namespace horizon
a class to store JSON values
Definition: json.hpp:161
Net * extract_pins(const std::set< UUIDPath< 3 >> &pins, Net *net=nullptr)
Takes pins specified by pins and moves them over to net.
Definition: block.cpp:231
Definition: bom_export_settings.hpp:10
Stores a sequence of up to 3 UUIDs.
Definition: uuid_path.hpp:13
Net * insert_net()
creates new net
Definition: block.cpp:107
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
Definition: uuid_ptr.hpp:9
void vacuum_nets()
deletes unreferenced nets
Definition: block.cpp:146
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:19
Definition: block.cpp:9
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
Definition: net.hpp:16