1 #pragma once
2 #include "common.hpp"
3 #include <map>
4 
5 namespace horizon {
6 class ObjectProperty {
7 public:
8     enum class Type {
9         BOOL,
10         INT,
11         STRING,
12         STRING_RO,
13         STRING_MULTILINE,
14         LENGTH,
15         LAYER,
16         LAYER_COPPER,
17         NET_CLASS,
18         ENUM,
19         DIM,
20         ANGLE,
21         ANGLE90,
22         GROUP,
23         TAG,
24         EXPAND,
25         OPACITY,
26         PRIORITY,
27         SCALE,
28     };
29     enum class ID {
30         NAME,
31         NAME_VISIBLE,
32         PAD_VISIBLE,
33         LENGTH,
34         SIZE,
35         TEXT,
36         REFDES,
37         VALUE,
38         IS_POWER,
39         OFFSHEET_REFS,
40         WIDTH,
41         HEIGHT,
42         FORM,
43         LAYER,
44         DIAMETER,
45         PLATED,
46         FLIPPED,
47         NET_CLASS,
48         WIDTH_FROM_RULES,
49         MPN,
50         SHAPE,
51         PARAMETER_CLASS,
52         POSITION_X,
53         POSITION_Y,
54         ANGLE,
55         MIRROR,
56         PAD_TYPE,
57         FROM_RULES,
58         DISPLAY_DIRECTIONS,
59         USAGE,
60         MODE,
61         DIFFPAIR,
62         LOCKED,
63         DOT,
64         CLOCK,
65         SCHMITT,
66         DRIVER,
67         ALTERNATE_PACKAGE,
68         POWER_SYMBOL_STYLE,
69         PIN_NAME_DISPLAY,
70         PIN_NAME_ORIENTATION,
71         FONT,
72         KEEPOUT_CLASS,
73         DISPLAY_ALL_PADS,
74         GROUP,
75         TAG,
76         EXPAND,
77         OMIT_SILKSCREEN,
78         FIXED,
79         NOPOPULATE,
80         OMIT_OUTLINE,
81         ON_TOP,
82         OPACITY,
83         PRIORITY,
84         SCALE,
85         ALLOW_UPSIDE_DOWN,
86     };
ObjectProperty(Type t,const std::string & l,int o=0,const std::vector<std::pair<int,std::string>> & its={})87     ObjectProperty(Type t, const std::string &l, int o = 0, const std::vector<std::pair<int, std::string>> &its = {})
88         : type(t), label(l), enum_items(its), order(o)
89     {
90     }
91 
92     Type type;
93     std::string label;
94     std::vector<std::pair<int, std::string>> enum_items;
95     int order = 0;
96 };
97 
98 class ObjectDescription {
99 public:
ObjectDescription(const std::string & n,const std::string & n_pl,const std::map<ObjectProperty::ID,ObjectProperty> & props)100     ObjectDescription(const std::string &n, const std::string &n_pl,
101                       const std::map<ObjectProperty::ID, ObjectProperty> &props)
102         : name(n), name_pl(n_pl), properties(props)
103     {
104     }
105 
106     std::string name;
107     std::string name_pl;
108     const std::map<ObjectProperty::ID, ObjectProperty> properties;
109 
110     const std::string &get_name_for_n(size_t n) const;
111 };
112 
113 extern const std::map<ObjectType, ObjectDescription> object_descriptions;
114 } // namespace horizon
115