aboutsummaryrefslogtreecommitdiff
path: root/include/trygvis/kicad.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/trygvis/kicad.h')
-rw-r--r--include/trygvis/kicad.h42
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