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