Horizon
component.hpp
1 #pragma once
2 #include "common/common.hpp"
3 #include "nlohmann/json_fwd.hpp"
4 #include "net.hpp"
5 #include "util/uuid.hpp"
6 #include "util/uuid_path.hpp"
7 #include "util/uuid_ptr.hpp"
8 #include "util/uuid_vec.hpp"
9 #include <fstream>
10 #include <map>
11 #include <vector>
12 #include <set>
13 
14 namespace horizon {
15 using json = nlohmann::json;
16 
17 class Connection {
18 public:
19  Connection(const json &j, class Block *block);
20  Connection(Net *n) : net(n)
21  {
22  }
23  uuid_ptr<Net> net;
24 
25  json serialize() const;
26 };
27 
41 class Component {
42 public:
43  Component(const UUID &uu, const json &j, class IPool &pool, class Block *block = nullptr);
44  Component(const UUID &uu);
45 
46  UUID get_uuid() const;
47 
48  UUID uuid;
49  const class Entity *entity = nullptr;
50  const class Part *part = nullptr;
51  std::string refdes;
52  std::string value;
53  UUID group;
54  UUID tag;
55  bool nopopulate = false;
56 
57  UUIDVec href;
58 
59  enum class NopopulateFromInstance { SET, CLEAR, UNSET };
60  NopopulateFromInstance nopopulate_from_instance = NopopulateFromInstance::UNSET;
61 
62  bool get_nopopulate() const;
63 
64  const std::string &get_prefix() const;
65 
70  std::map<UUIDPath<2>, Connection> connections;
71 
75  std::map<UUIDPath<2>, std::set<int>> pin_names; //-2:custom -1:primary 0...:alt
76  std::map<UUIDPath<2>, std::string> custom_pin_names;
77 
78  std::string replace_text(const std::string &t, bool *replaced = nullptr) const;
79 
80  json serialize() const;
81  virtual ~Component()
82  {
83  }
84 
85 private:
86  // void update_refs();
87 };
88 } // namespace horizon
A block is one level of hierarchy in the netlist.
Definition: block.hpp:29
A Component is an instanced Entity in a Block.
Definition: component.hpp:41
std::map< UUIDPath< 2 >, std::set< int > > pin_names
used to select alternate pin names
Definition: component.hpp:75
std::map< UUIDPath< 2 >, Connection > connections
which Nins are connected to which Net the UUIDPath consists of Gate and Pin UUID
Definition: component.hpp:70
Definition: component.hpp:17
Definition: entity.hpp:13
Definition: ipool.hpp:14
Definition: net.hpp:11
Definition: part.hpp:14
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: uuid_ptr.hpp:8
a class to store JSON values
Definition: json.hpp:177
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62