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