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 : public UUIDProvider {
40 public:
41  Component(const UUID &uu, const json &j, class Pool &pool, class Block *block = nullptr);
42  Component(const UUID &uu);
43 
44  virtual UUID get_uuid() const;
45 
46  UUID uuid;
47  const class Entity *entity;
48  const class Part *part = nullptr;
49  std::string refdes;
50  std::string value;
51  UUID group;
52  UUID tag;
53 
58  std::map<UUIDPath<2>, Connection> connections;
59 
63  std::map<UUIDPath<2>, std::set<int>> pin_names; //-2:custom -1:primary 0...:alt
64  std::map<UUIDPath<2>, std::string> custom_pin_names;
65 
66  std::string replace_text(const std::string &t, bool *replaced = nullptr) const;
67 
68  json serialize() const;
69  virtual ~Component()
70  {
71  }
72 
73 private:
74  // void update_refs();
75 };
76 } // namespace horizon
horizon::Component::pin_names
std::map< UUIDPath< 2 >, std::set< int > > pin_names
used to select alternate pin names
Definition: component.hpp:63
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:58
horizon::uuid_ptr
Definition: uuid_ptr.hpp:9
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Entity
Definition: entity.hpp:13
horizon::Net
Definition: net.hpp:16
horizon::Block
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
horizon::Connection
Definition: component.hpp:15
horizon::Component
A Component is an instanced Entity in a Block.
Definition: component.hpp:39
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::Pool
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:21
horizon::Part
Definition: part.hpp:13
horizon::UUIDProvider
Interface for objects that have a UUID.
Definition: uuid_provider.hpp:9