KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcm_data.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Andrew Lutsenko, anlutsenko at gmail dot com
5 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef PCM_DATA_H_
22#define PCM_DATA_H_
23
24#include "core/wx_stl_compat.h"
25
26#include <map>
27#include <json_common.h>
29#include <optional>
30#include <string>
31#include <tuple>
32#include <vector>
33#include <wx/string.h>
34
35
36using STRING_MAP = std::map<std::string, wxString>;
37using nlohmann::json;
38
39
42{
48};
49
52{
56};
57
58
61{
67};
68
69
72{
73 wxString name;
75};
76
77
78// MSVC, wxWidgets and nlohmann_json don't play nice together and
79// create linker errors about redefinition of some vector members
80// if an attempt to use vector<wxString> in json is made.
81
84{
85 wxString version;
86 std::optional<int> version_epoch;
87 std::optional<wxString> download_url;
88 std::optional<wxString> download_sha256;
89 std::optional<uint64_t> download_size;
90 std::optional<uint64_t> install_size;
92 std::vector<std::string> platforms;
93 wxString kicad_version;
94 std::optional<wxString> kicad_version_max;
95 std::vector<std::string> keep_on_update;
96
97 // Not serialized fields
98 std::tuple<int, int, int, int> parsed_version; // Full version tuple for sorting
99 bool compatible = true;
100};
101
102
105{
106 wxString name;
107 wxString description;
109 wxString identifier;
111 std::optional<PCM_PLUGIN_CATEGORY> category;
113 std::optional<PCM_CONTACT> maintainer;
114 wxString license;
116 std::vector<std::string> tags;
117 std::vector<std::string> keep_on_update;
118 std::vector<PACKAGE_VERSION> versions;
119};
120
121
124{
125 wxString url;
126 std::optional<wxString> sha256;
128};
129
130
133{
134 wxString name;
136 std::optional<PCM_RESOURCE_REFERENCE> resources;
137 std::optional<PCM_RESOURCE_REFERENCE> manifests;
138 std::optional<PCM_CONTACT> maintainer;
139
140 // Not serialized fields
141 std::vector<PCM_PACKAGE> package_list;
142 // pkg id to index of package from package_list for quick lookup
143 std::unordered_map<wxString, size_t> package_map;
144};
145
146
149{
155 bool pinned;
156
157 // Not serialized fields
159};
160
161
163 { PT_INVALID, "invalid" },
164 { PT_PLUGIN, "plugin" },
165 { PT_FAB, "fab" },
166 { PT_LIBRARY, "library" },
167 { PT_COLORTHEME, "colortheme" },
168 } )
169
171 { PC_INVALID, "invalid" },
172 { PC_GENERAL, "general" },
173 { PC_FAB, "fab" },
174 } )
175
176
178 {
179 { PVS_INVALID, "invalid" },
180 { PVS_STABLE, "stable" },
181 { PVS_TESTING, "testing" },
182 { PVS_DEVELOPMENT, "development" },
183 { PVS_DEPRECATED, "deprecated" },
184 } )
185
186
187// Following are templates and definitions for en/decoding above structs
188// to/from json
189
191
192
193void to_json( json& j, const PACKAGE_VERSION& v );
194void from_json( const json& j, PACKAGE_VERSION& v );
195
196
197void to_json( json& j, const PCM_PACKAGE& p );
198void from_json( const json& j, PCM_PACKAGE& p );
199
200
201void to_json( json& j, const PCM_RESOURCE_REFERENCE& r );
202void from_json( const json& j, PCM_RESOURCE_REFERENCE& r );
203
204
205void to_json( json& j, const PCM_REPOSITORY& r );
206void from_json( const json& j, PCM_REPOSITORY& r );
207
208
209void to_json( json& j, const PCM_INSTALLATION_ENTRY& e );
210void from_json( const json& j, PCM_INSTALLATION_ENTRY& e );
211
212
213#endif // PCM_DATA_H_
const char * name
Definition: DXF_plotter.cpp:57
std::map< wxString, wxString > STRING_MAP
Definition: env_vars.cpp:30
nlohmann::json json
Definition: gerbview.cpp:47
PCM_PLUGIN_CATEGORY
Definition: pcm_data.h:52
@ PC_GENERAL
Definition: pcm_data.h:54
@ PC_FAB
Definition: pcm_data.h:55
@ PC_INVALID
Definition: pcm_data.h:53
NLOHMANN_JSON_SERIALIZE_ENUM(PCM_PACKAGE_TYPE, { { PT_INVALID, "invalid" }, { PT_PLUGIN, "plugin" }, { PT_FAB, "fab" }, { PT_LIBRARY, "library" }, { PT_COLORTHEME, "colortheme" }, }) NLOHMANN_JSON_SERIALIZE_ENUM(PCM_PLUGIN_CATEGORY
PCM_PACKAGE_TYPE
< Supported package types
Definition: pcm_data.h:42
@ PT_COLORTHEME
Definition: pcm_data.h:47
@ PT_INVALID
Definition: pcm_data.h:43
@ PT_PLUGIN
Definition: pcm_data.h:44
@ PT_LIBRARY
Definition: pcm_data.h:46
@ PT_FAB
Definition: pcm_data.h:45
std::map< std::string, wxString > STRING_MAP
Definition: pcm_data.h:36
PCM_PACKAGE_VERSION_STATUS
Definition: pcm_data.h:61
@ PVS_INVALID
Definition: pcm_data.h:62
@ PVS_DEVELOPMENT
Definition: pcm_data.h:65
@ PVS_STABLE
Definition: pcm_data.h:63
@ PVS_TESTING
Definition: pcm_data.h:64
@ PVS_DEPRECATED
Definition: pcm_data.h:66
void to_json(json &j, const PCM_PACKAGE &p)
Definition: pcm_data.cpp:89
void from_json(const json &j, PACKAGE_VERSION &v)
Definition: pcm_data.cpp:68
< Package version metadata Package metadata
Definition: pcm_data.h:84
std::optional< uint64_t > download_size
Definition: pcm_data.h:89
bool compatible
Definition: pcm_data.h:99
std::optional< uint64_t > install_size
Definition: pcm_data.h:90
wxString version
Definition: pcm_data.h:85
PCM_PACKAGE_VERSION_STATUS status
Definition: pcm_data.h:91
std::optional< wxString > kicad_version_max
Definition: pcm_data.h:94
std::optional< wxString > download_url
Definition: pcm_data.h:87
std::optional< wxString > download_sha256
Definition: pcm_data.h:88
std::optional< int > version_epoch
Definition: pcm_data.h:86
std::vector< std::string > platforms
Definition: pcm_data.h:92
wxString kicad_version
Definition: pcm_data.h:93
std::tuple< int, int, int, int > parsed_version
Definition: pcm_data.h:98
std::vector< std::string > keep_on_update
Definition: pcm_data.h:95
wxString name
Definition: pcm_data.h:73
STRING_MAP contact
Definition: pcm_data.h:74
Definition: pcm_data.h:149
wxString repository_name
Definition: pcm_data.h:153
PCM_PACKAGE package
Definition: pcm_data.h:150
uint64_t install_timestamp
Definition: pcm_data.h:154
wxString repository_id
Definition: pcm_data.h:152
wxString current_version
Definition: pcm_data.h:151
bool update_available
Definition: pcm_data.h:158
bool pinned
Definition: pcm_data.h:155
Repository reference to a resource.
Definition: pcm_data.h:105
wxString description
Definition: pcm_data.h:107
wxString description_full
Definition: pcm_data.h:108
wxString identifier
Definition: pcm_data.h:109
wxString license
Definition: pcm_data.h:114
std::vector< std::string > tags
Definition: pcm_data.h:116
STRING_MAP resources
Definition: pcm_data.h:115
std::optional< PCM_CONTACT > maintainer
Definition: pcm_data.h:113
wxString name
Definition: pcm_data.h:106
std::vector< PACKAGE_VERSION > versions
Definition: pcm_data.h:118
std::optional< PCM_PLUGIN_CATEGORY > category
Definition: pcm_data.h:111
PCM_PACKAGE_TYPE type
Definition: pcm_data.h:110
std::vector< std::string > keep_on_update
Definition: pcm_data.h:117
PCM_CONTACT author
Definition: pcm_data.h:112
Package installation entry.
Definition: pcm_data.h:133
PCM_RESOURCE_REFERENCE packages
Definition: pcm_data.h:135
std::optional< PCM_CONTACT > maintainer
Definition: pcm_data.h:138
std::vector< PCM_PACKAGE > package_list
Definition: pcm_data.h:141
wxString name
Definition: pcm_data.h:134
std::optional< PCM_RESOURCE_REFERENCE > manifests
Definition: pcm_data.h:137
std::optional< PCM_RESOURCE_REFERENCE > resources
Definition: pcm_data.h:136
std::unordered_map< wxString, size_t > package_map
Definition: pcm_data.h:143
Repository metadata.
Definition: pcm_data.h:124
std::optional< wxString > sha256
Definition: pcm_data.h:126
uint64_t update_timestamp
Definition: pcm_data.h:127
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(UPDATE_REQUEST, platform, arch, current_version, lang, last_check) struct UPDATE_RESPONSE