Horizon
part.hpp
1 #pragma once
2 #include "entity.hpp"
3 #include "package.hpp"
4 #include "util/uuid.hpp"
5 #include "util/uuid_provider.hpp"
6 #include <fstream>
7 #include <map>
8 #include <vector>
9 
10 namespace horizon {
11 using json = nlohmann::json;
12 
13 class Part : public UUIDProvider {
14 private:
15  Part(const UUID &uu, const json &j, Pool &pool);
16  const std::string empty;
17 
18 public:
19  class PadMapItem {
20  public:
21  PadMapItem(const Gate *g, const Pin *p) : gate(g), pin(p)
22  {
23  }
26  };
27  Part(const UUID &uu);
28 
29  static Part new_from_file(const std::string &filename, Pool &pool);
30  UUID uuid;
31 
32  enum class Attribute { MPN, VALUE, MANUFACTURER, DATASHEET, DESCRIPTION };
33  std::map<Attribute, std::pair<bool, std::string>> attributes;
34  std::map<UUID, std::string> orderable_MPNs;
35  const std::string &get_attribute(Attribute a) const;
36  const std::pair<bool, std::string> &get_attribute_pair(Attribute a) const;
37 
38  const std::string &get_MPN() const;
39  const std::string &get_value() const;
40  const std::string &get_manufacturer() const;
41  const std::string &get_datasheet() const;
42  const std::string &get_description() const;
43  std::set<std::string> get_tags() const;
44  UUID get_model() const;
45 
46  std::set<std::string> tags;
47  bool inherit_tags = false;
50  UUID model;
51  bool inherit_model = true;
53 
54  void update_refs(Pool &pool);
55  UUID get_uuid() const;
56 
57  std::map<std::string, std::string> parametric;
58 
59  std::map<UUID, PadMapItem> pad_map;
60  json serialize() const;
61 };
62 } // namespace horizon
horizon::uuid_ptr
Definition: uuid_ptr.hpp:9
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Pin
A Pin represents a logical pin of a Unit.
Definition: unit.hpp:19
horizon::Gate
Definition: gate.hpp:14
horizon::Part::PadMapItem
Definition: part.hpp:19
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