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 <fstream>
9 #include <map>
10 #include <vector>
11 
12 namespace horizon {
13 using json = nlohmann::json;
14 
15 class Connection {
16 public:
17  Connection(const json &j, class Block *block);
18  Connection(Net *n) : net(n)
19  {
20  }
21  uuid_ptr<Net> net;
22 
23  json serialize() const;
24 };
25 
39 class Component {
40 public:
41  Component(const UUID &uu, const json &j, class IPool &pool, class Block *block = nullptr);
42  Component(const UUID &uu);
43 
44  UUID get_uuid() const;
45 
46  UUID uuid;
47  const class Entity *entity = nullptr;
48  const class Part *part = nullptr;
49  std::string refdes;
50  std::string value;
51  UUID group;
52  UUID tag;
53  bool nopopulate = false;
54 
59  std::map<UUIDPath<2>, Connection> connections;
60 
64  std::map<UUIDPath<2>, std::set<int>> pin_names; //-2:custom -1:primary 0...:alt
65  std::map<UUIDPath<2>, std::string> custom_pin_names;
66 
67  std::string replace_text(const std::string &t, bool *replaced = nullptr) const;
68 
69  json serialize() const;
70  virtual ~Component()
71  {
72  }
73 
74 private:
75  // void update_refs();
76 };
77 } // namespace horizon
horizon::Component::connections
std::map< UUIDPath< 2 >, Connection > connections
which Nins are connected to which Net the UUIDPath consists of Gate and Pin UUID
Definition: component.hpp:59
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:166
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Component::pin_names
std::map< UUIDPath< 2 >, std::set< int > > pin_names
used to select alternate pin names
Definition: component.hpp:64