Horizon
Loading...
Searching...
No Matches
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#include "util/item_set.hpp"
11
12namespace horizon {
13using json = nlohmann::json;
14
15class Part {
16private:
17 Part(const UUID &uu, const json &j, class IPool &pool);
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;
51 std::shared_ptr<const class Entity> entity;
52 std::shared_ptr<const class Package> package;
53 UUID model;
54 bool inherit_model = true;
55 std::shared_ptr<const class Part> base;
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 std::string display_name;
67 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 OverridePrefix get_override_prefix() const;
83
84 ItemSet get_pool_items_used() const;
85
86 unsigned int get_required_version() const;
87
88 FileVersion version;
89
90 json serialize() const;
91};
92} // namespace horizon
Definition gate.hpp:9
Definition ipool.hpp:15
Definition part.hpp:61
Definition part.hpp:20
Definition part.hpp:15
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