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
11namespace horizon {
12using json = nlohmann::json;
13
14class Part {
15private:
16 Part(const UUID &uu, const json &j, class IPool &pool);
17 const std::string empty;
18
19public:
20 class PadMapItem {
21 public:
22 PadMapItem(const class Gate *g, const class Pin *p) : gate(g), pin(p)
23 {
24 }
27 };
28 Part(const UUID &uu);
29
30 static Part new_from_json(const json &j, IPool &pool);
31 static Part new_from_file(const std::string &filename, IPool &pool);
32 static unsigned int get_app_version();
33 UUID uuid;
34
35 enum class Attribute { MPN, VALUE, MANUFACTURER, DATASHEET, DESCRIPTION };
36 std::map<Attribute, std::pair<bool, std::string>> attributes;
37 std::map<UUID, std::string> orderable_MPNs;
38 const std::string &get_attribute(Attribute a) const;
39 const std::pair<bool, std::string> &get_attribute_pair(Attribute a) const;
40
41 const std::string &get_MPN() const;
42 const std::string &get_value() const;
43 const std::string &get_manufacturer() const;
44 const std::string &get_datasheet() const;
45 const std::string &get_description() const;
46 std::set<std::string> get_tags() const;
47 UUID get_model() const;
48
49 std::set<std::string> tags;
50 bool inherit_tags = false;
53 UUID model;
54 bool inherit_model = true;
56
57 void update_refs(IPool &pool);
58 UUID get_uuid() const;
59
60 std::map<std::string, std::string> parametric;
61 class Column {
62 public:
63 Column(const std::string &d, const std::string &v) : display_name(d), value(v)
64 {
65 }
66 const std::string display_name;
67 const std::string value;
68 };
69 std::map<std::string, Column> parametric_formatted;
70
71 std::map<UUID, PadMapItem> pad_map;
72
73 enum class FlagState { SET, CLEAR, INHERIT };
74 enum class Flag { EXCLUDE_BOM, EXCLUDE_PNP, BASE_PART };
75 std::map<Flag, FlagState> flags;
76 bool get_flag(Flag fl) const;
77
78 enum class OverridePrefix { NO, YES, INHERIT };
79 OverridePrefix override_prefix = OverridePrefix::NO;
80 std::string prefix;
81 const std::string &get_prefix() const;
82
83 unsigned int get_required_version() const;
84
85 FileVersion version;
86
87 json serialize() const;
88};
89} // namespace horizon
Definition: gate.hpp:10
Definition: ipool.hpp:14
Definition: part.hpp:61
Definition: part.hpp:20
Definition: part.hpp:14
A Pin represents a logical pin of a Unit.
Definition: unit.hpp:16
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