Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1#pragma once
2
9
10#include <compare>
11#include <cstdint>
12#include <string>
13#include <utility>
14#include <vector>
15
17
24
35
36enum class Editability : std::uint8_t { editable, opaque };
37
45
58public:
60 enum class State : std::uint8_t { unknown = 0, restricted = 1, allowed = 2 };
61
63 constexpr Redistribution() = default;
64
66 [[nodiscard]] static constexpr Redistribution granted() {
68 }
69 [[nodiscard]] static constexpr Redistribution restricted() {
71 }
72 [[nodiscard]] static constexpr Redistribution unknown() { return Redistribution{}; }
73
74 [[nodiscard]] constexpr State state() const { return state_; }
75 [[nodiscard]] constexpr bool is_granted() const { return state_ == State::allowed; }
76 [[nodiscard]] constexpr bool is_restricted() const { return state_ == State::restricted; }
77 [[nodiscard]] constexpr bool is_unknown() const { return state_ == State::unknown; }
78
79 friend constexpr bool operator==(const Redistribution&, const Redistribution&) = default;
80
81private:
82 constexpr explicit Redistribution(State state) : state_(state) {}
83
84 State state_ = State::unknown;
85};
86
89enum class RequiredFor : std::uint8_t { play, rebuild, remix, publish };
90
107
110struct FileEntry {
112 std::string role;
114 std::string path;
115 std::string sha256;
116 std::uint64_t bytes = 0;
117 std::string media_type;
120 bool executable_data = false;
122};
123
126 std::string role;
127 std::string id;
128 std::string sha256;
129 std::uint64_t bytes = 0;
130 std::string media_type;
133 std::string provider;
134 bool required = true;
136};
137
149 enum class Kind : std::uint8_t { file, dependency };
150
153 std::string id;
154
155 [[nodiscard]] static ComponentRef to_file(std::string path) {
156 return ComponentRef{Kind::file, std::move(path)};
157 }
158 [[nodiscard]] static ComponentRef to_dependency(std::string id) {
159 return ComponentRef{Kind::dependency, std::move(id)};
160 }
161
164 friend bool operator==(const ComponentRef&, const ComponentRef&) = default;
165 friend std::strong_ordering operator<=>(const ComponentRef&, const ComponentRef&) = default;
166};
167
180
181} // namespace pulp::authoring_capsule
Permission to pass a component's bytes on.
Definition component.hpp:57
constexpr bool is_unknown() const
Definition component.hpp:77
State
unknown is first so that every zero-initialization lands on it.
Definition component.hpp:60
@ restricted
Definition component.hpp:60
constexpr bool is_granted() const
Definition component.hpp:75
static constexpr Redistribution granted()
An explicit grant. Spelling this is the act; there is no other way in.
Definition component.hpp:66
constexpr State state() const
Definition component.hpp:74
friend constexpr bool operator==(const Redistribution &, const Redistribution &)=default
static constexpr Redistribution restricted()
Definition component.hpp:69
static constexpr Redistribution unknown()
Definition component.hpp:72
constexpr Redistribution()=default
The only implicit state. Silence is not a grant.
constexpr bool is_restricted() const
Definition component.hpp:76
Definition archive.hpp:24
Editability
Definition component.hpp:36
@ opaque
Definition component.hpp:36
@ editable
Definition component.hpp:36
SourceAvailability
Definition component.hpp:25
@ local_only
Bytes exist only on the exporting machine and were deliberately omitted.
Definition component.hpp:31
@ omitted
Deliberately absent under the selected export policy.
Definition component.hpp:33
@ external
Bytes are named by digest and fetched from a declared provider.
Definition component.hpp:29
@ included
Bytes travel in the capsule.
Definition component.hpp:27
Disclosure
Definition component.hpp:38
@ public_
Definition component.hpp:39
@ redacted
Definition component.hpp:42
@ not_recorded
Definition component.hpp:43
@ recipient_scoped
Definition component.hpp:40
@ private_
Definition component.hpp:41
RequiredFor
Operations a component is required for.
Definition component.hpp:89
@ publish
Definition component.hpp:89
@ rebuild
Definition component.hpp:89
@ play
Definition component.hpp:89
@ remix
Definition component.hpp:89
Completeness
Derived from the component rows.
Definition component.hpp:170
@ play_only
The admitted rendition plays; canonical editable inputs are incomplete.
Definition component.hpp:178
@ partial
Inspectable or editable, but not fully rebuildable or playable.
Definition component.hpp:176
@ resolvable
Required components are absent but have stable identities and resolvers.
Definition component.hpp:174
@ self_contained
Every required byte is present and may be redistributed.
Definition component.hpp:172
Canonicality
Definition component.hpp:18
@ receipt
Definition component.hpp:22
@ derived_output
Definition component.hpp:20
@ preview
Definition component.hpp:21
@ canonical_input
Definition component.hpp:19
Definition component.hpp:91
bool attribution_required
Definition component.hpp:104
Redistribution redistribution
Defaults to unknown because Redistribution has no other default.
Definition component.hpp:97
Editability editability
Definition component.hpp:94
std::string license_expression
SPDX expression, or a LicenseRef-… for a custom licence.
Definition component.hpp:99
std::string creator
Definition component.hpp:102
std::vector< RequiredFor > required_for
Definition component.hpp:105
SourceAvailability source_availability
Definition component.hpp:93
Canonicality canonicality
Definition component.hpp:92
std::string source_uri
Definition component.hpp:103
Disclosure disclosure
Definition component.hpp:95
std::string license_notice_sha256
Digest of the notice text that must travel with the component.
Definition component.hpp:101
A reference to one component row, for a result that must name components it does not own.
Definition component.hpp:148
std::string id
The files[] row's archive path, or the dependencies[] row's id.
Definition component.hpp:153
friend bool operator==(const ComponentRef &, const ComponentRef &)=default
Ordered and compared by kind then identifier, so a list of these has a total order that does not depe...
static ComponentRef to_dependency(std::string id)
Definition component.hpp:158
Kind
Definition component.hpp:149
@ file
Definition component.hpp:149
@ dependency
Definition component.hpp:149
Kind kind
Definition component.hpp:151
static ComponentRef to_file(std::string path)
Definition component.hpp:155
friend std::strong_ordering operator<=>(const ComponentRef &, const ComponentRef &)=default
A component whose bytes are not in the archive.
Definition component.hpp:125
std::string role
Definition component.hpp:126
bool required
Definition component.hpp:134
std::string sha256
Definition component.hpp:128
std::string id
Definition component.hpp:127
ComponentPolicy policy
Definition component.hpp:135
std::string media_type
Definition component.hpp:130
std::string provider
Allowlisted HTTPS provider or content-addressed library locator.
Definition component.hpp:133
std::uint64_t bytes
Definition component.hpp:129
One row of the archive closure.
Definition component.hpp:110
bool executable_data
True when the bytes are code the consuming product could execute.
Definition component.hpp:120
std::string path
Normalized safe relative path inside the archive.
Definition component.hpp:114
ComponentPolicy policy
Definition component.hpp:121
std::string sha256
Definition component.hpp:115
std::uint64_t bytes
Definition component.hpp:116
std::string media_type
Definition component.hpp:117
std::string role
Profile-defined semantic role, e.g. "dsp.source".
Definition component.hpp:112