From bfeeac6e4889d1e9a1083b3c7efc59652981b168 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 1 Aug 2016 08:20:23 +0200 Subject: o Moving the generation logic to Python, embedding a Python interpreter with the help of pybind11. o Adding install configuration to CMake to make it easier to reuse the project later on. o Splitting out the examples into its own project to make it easier to test the whole installation setup and python/template loading. o Trying to reorganize the code a bit, not very much better yet. --- core/include/trygvis/kicad.h | 102 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 core/include/trygvis/kicad.h (limited to 'core/include') diff --git a/core/include/trygvis/kicad.h b/core/include/trygvis/kicad.h new file mode 100644 index 0000000..0c5005d --- /dev/null +++ b/core/include/trygvis/kicad.h @@ -0,0 +1,102 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace trygvis { +namespace kicad { +template +using opt = std::experimental::optional; +using std::experimental::nullopt; +} // namespace kicad +} // namespace trygvis + +namespace trygvis { +namespace kicad { +namespace netlist { + +struct lib_source { + const std::string lib; + const std::string part; + + 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 { + int num; + std::string name; + std::string type; +}; + +struct part { + std::vector pins; +}; + +class node { +public: + const std::string ref; + const int pin; + + node(const std::string &ref, int pin) : ref(ref), pin(pin) {} +}; + +class net { +public: + 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 { + std::vector components; + std::vector parts; + std::vector nets; + + 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 { +public: + explicit kicad_parse_exception(const std::vector &messages) : + runtime_error("Parse error"), messages(messages) {} + + ~kicad_parse_exception() {} + + const std::vector messages; +}; + +class kicad_net_loader { +public: + kicad_net_loader(); + + virtual ~kicad_net_loader(); + + netlist load(std::string path, std::ostream &err); + + void setDebug(bool debug); + +private: + bool debug_; +}; + +} // namespace netlist +} // namespace kicad +} // namespace trygvis -- cgit v1.2.3