diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2016-07-26 23:50:23 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2016-07-26 23:50:23 +0200 |
commit | a8256910d40a0eee85bf539a3f120c9d92485f3f (patch) | |
tree | 83fd119fe43257ca131620656b94a698b23c4329 /include/trygvis | |
parent | 128e53d220d97225803d61d86f8e43439563181d (diff) | |
download | kicad-utils-a8256910d40a0eee85bf539a3f120c9d92485f3f.tar.gz kicad-utils-a8256910d40a0eee85bf539a3f120c9d92485f3f.tar.bz2 kicad-utils-a8256910d40a0eee85bf539a3f120c9d92485f3f.tar.xz kicad-utils-a8256910d40a0eee85bf539a3f120c9d92485f3f.zip |
o Working version with support for Arduino parts.
Diffstat (limited to 'include/trygvis')
-rw-r--r-- | include/trygvis/kicad.h | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/include/trygvis/kicad.h b/include/trygvis/kicad.h index 4cff944..ae67673 100644 --- a/include/trygvis/kicad.h +++ b/include/trygvis/kicad.h @@ -7,16 +7,29 @@ namespace trygvis { namespace kicad { - template<typename T> using opt = std::experimental::optional<T>; +} // namespace kicad +} // namespace trygvis -class component { -public: - std::string ref; - std::string value; +namespace trygvis { +namespace kicad { +namespace netlist { + +struct lib_source { + const std::string lib; + const std::string part; - component(const std::string &ref, const std::string &value) : ref(ref), value(value) { } + lib_source(const std::string &lib, const std::string &part) : lib(lib), part(part) { } +}; + +struct component { + const std::string ref; + const std::string value; + const lib_source _lib_source; + + component(const std::string &ref, const std::string &value, const lib_source &_lib_source) : + ref(ref), value(value), _lib_source(_lib_source) { } }; struct pin { @@ -31,19 +44,21 @@ struct part { class node { public: - std::string ref; - int pin; + const std::string ref; + const int pin; node(const std::string &ref, int pin) : ref(ref), pin(pin) { } }; class net { public: - int code; - std::string name; - std::vector<node> nodes; + const int code; + const std::string name; + const std::vector<node> nodes; net(int code, const std::string &name, const std::vector<node> &nodes) : code(code), name(name), nodes(nodes) { } + + const node * node_for_ref(const std::string &ref) const; }; struct netlist { @@ -51,7 +66,9 @@ struct netlist { std::vector<part> parts; std::vector<net> nets; - opt<const component *> find_component(std::string ref) const; + opt<const component *> find_component(const std::string &ref) const; + + std::vector<const net *> find_usage_of(const std::string &ref) const; }; class kicad_parse_exception : public std::runtime_error { @@ -76,5 +93,6 @@ private: bool debug_; }; +} // namespace netlist } // namespace kicad } // namespace trygvis |