Horizon
package.hpp
1 #pragma once
2 #include "common/arc.hpp"
3 #include "common/common.hpp"
4 #include "common/hole.hpp"
5 #include "common/junction.hpp"
6 #include "common/layer_provider.hpp"
7 #include "common/line.hpp"
8 #include "common/object_provider.hpp"
9 #include "common/polygon.hpp"
10 #include "common/text.hpp"
11 #include "common/keepout.hpp"
12 #include "common/dimension.hpp"
13 #include "nlohmann/json_fwd.hpp"
14 #include "package/package_rules.hpp"
15 #include "package/pad.hpp"
16 #include "util/uuid.hpp"
17 #include "util/uuid_provider.hpp"
18 #include "util/warning.hpp"
19 #include "parameter/program_polygon.hpp"
20 #include <fstream>
21 #include <map>
22 #include <set>
23 #include <vector>
24 
25 namespace horizon {
26 using json = nlohmann::json;
27 
28 class Package : public ObjectProvider, public LayerProvider, public UUIDProvider {
29 public:
31  friend Package;
32 
33  protected:
34  std::map<UUID, Polygon> &get_polygons() override;
35 
36  private:
37  ParameterProgram::CommandHandler get_command(const std::string &cmd) override;
38  class Package *pkg = nullptr;
39 
40  public:
41  MyParameterProgram(class Package *p, const std::string &code);
42  };
43 
44  class Model {
45  public:
46  Model(const UUID &uu, const std::string &filename);
47  Model(const UUID &uu, const json &j);
48 
49  UUID uuid;
50  std::string filename;
51 
52  int64_t x = 0;
53  int64_t y = 0;
54  int64_t z = 0;
55 
56  int roll = 0;
57  int pitch = 0;
58  int yaw = 0;
59 
60  json serialize() const;
61  };
62 
63  Package(const UUID &uu, const json &j, class Pool &pool);
64  Package(const UUID &uu);
65  static Package new_from_file(const std::string &filename, class Pool &pool);
66 
67  json serialize() const;
68  Junction *get_junction(const UUID &uu) override;
69  Polygon *get_polygon(const UUID &uu) override;
70  std::pair<Coordi, Coordi> get_bbox() const;
71  const std::map<int, Layer> &get_layers() const override;
72  std::pair<bool, std::string> apply_parameter_set(const ParameterSet &ps);
73  void expand();
74  void update_warnings();
75  int get_max_pad_name() const;
76 
77  UUID get_uuid() const override;
78 
79  Package(const Package &pkg);
80  void operator=(Package const &pkg);
81 
82  UUID uuid;
83  std::string name;
84  std::string manufacturer;
85  std::set<std::string> tags;
86 
87  std::map<UUID, Junction> junctions;
88  std::map<UUID, Line> lines;
89  std::map<UUID, Arc> arcs;
90  std::map<UUID, Text> texts;
91  std::map<UUID, Pad> pads;
92  std::map<UUID, Polygon> polygons;
93  std::map<UUID, Keepout> keepouts;
94  std::map<UUID, Dimension> dimensions;
95 
96  ParameterSet parameter_set;
97  MyParameterProgram parameter_program;
98  PackageRules rules;
99 
100  std::map<UUID, Model> models;
101  UUID default_model;
102  const Model *get_model(const UUID &uu = UUID()) const;
103 
104  const class Package *alternate_for = nullptr;
105 
106  std::vector<Warning> warnings;
107 
108  void update_refs(class Pool &pool);
109 
110 private:
111  void update_refs();
112 };
113 } // namespace horizon
horizon::Polygon
Polygon used in Padstack, Package and Board for specifying filled Regions.
Definition: polygon.hpp:27
horizon::PackageRules
Definition: package_rules.hpp:10
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Package::MyParameterProgram
Definition: package.hpp:30
horizon::ParameterProgramPolygon
Definition: program_polygon.hpp:8
horizon::LayerProvider
Definition: layer_provider.hpp:7
horizon::Junction
A Junction is a point in 2D-Space.
Definition: junction.hpp:25
horizon::Package
Definition: package.hpp:28
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:161
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
libzip::int64_t
zip_int64_t int64_t
zip_int64_t typedef.
Definition: zip.hpp:103
horizon::Pool
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:21
horizon::UUIDProvider
Interface for objects that have a UUID.
Definition: uuid_provider.hpp:9
horizon::Package::Model
Definition: package.hpp:44
horizon::ObjectProvider
Interface for classes that store objects identified by UUID (e.g. Line or Junction)
Definition: object_provider.hpp:10