From a8256910d40a0eee85bf539a3f120c9d92485f3f Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 26 Jul 2016 23:50:23 +0200 Subject: o Working version with support for Arduino parts. --- include/trygvis/kicad.h | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'include/trygvis/kicad.h') 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 using opt = std::experimental::optional; +} // 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 nodes; + const int code; + const std::string name; + const std::vector nodes; net(int code, const std::string &name, const std::vector &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 parts; std::vector nets; - opt find_component(std::string ref) const; + opt find_component(const std::string &ref) const; + + std::vector 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 -- cgit v1.2.3