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  static std::map<std::string, std::string> peek_project_meta(const std::string &filename);
32  Net *get_net(const UUID &uu);
33  UUID uuid;
34  std::string name;
35  std::map<UUID, Net> nets;
36  std::map<UUID, Bus> buses;
37  std::map<UUID, Component> components;
38  std::map<UUID, NetClass> net_classes;
39  uuid_ptr<NetClass> net_class_default = nullptr;
40 
41  std::map<UUID, std::string> group_names;
42  std::map<UUID, std::string> tag_names;
43  std::map<std::string, std::string> project_meta;
44  std::string get_group_name(const UUID &uu) const;
45  std::string get_tag_name(const UUID &uu) const;
46 
47  BOMExportSettings bom_export_settings;
48  std::map<const class Part *, BOMRow> get_BOM(const BOMExportSettings &settings) const;
49 
50  Block(const Block &block);
51  void operator=(const Block &block);
52 
53  void merge_nets(Net *net, Net *into);
54 
58  void vacuum_nets();
59  void vacuum_group_tag_names();
60 
66  Net *extract_pins(const std::set<UUIDPath<3>> &pins, Net *net = nullptr);
67 
68  void update_connection_count();
69 
70  void update_diffpairs();
71 
76  Net *insert_net();
77 
78  std::string get_net_name(const UUID &uu) const;
79 
80  json serialize();
81 
82 private:
83  void update_refs();
84 };
85 } // namespace horizon
horizon::uuid_ptr
Definition: uuid_ptr.hpp:9
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Block::vacuum_nets
void vacuum_nets()
deletes unreferenced nets
Definition: block.cpp:169
horizon::Net
Definition: net.hpp:16
horizon::Block
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
horizon::UUIDPath
Stores a sequence of up to 3 UUIDs.
Definition: uuid_path.hpp:13
horizon::Block::extract_pins
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:282
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:165
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
horizon::Pool
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:21
horizon::Block::insert_net
Net * insert_net()
creates new net
Definition: block.cpp:130
horizon::BOMExportSettings
Definition: bom_export_settings.hpp:11