Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
export_plan.hpp
Go to the documentation of this file.
1#pragma once
2
9
10#include <cstdint>
11#include <functional>
12#include <span>
13#include <string>
14#include <utility>
15#include <vector>
16
17namespace pulp::interchange {
18
21 std::string name;
22 std::vector<std::uint8_t> bytes;
23};
24
26 std::vector<ExportArtifact> artifacts;
27};
28
39
46
56 std::vector<Concept> accepted_losses;
57};
58
68class ExportPlan {
69 public:
70 Format format() const noexcept { return format_; }
71 const timeline::Project& project() const noexcept { return project_; }
72 const ConceptCensus& census() const noexcept { return census_; }
73
77 std::span<const Concept> representable() const noexcept { return representable_; }
78
79 const LossManifest& losses() const noexcept { return losses_; }
82 bool is_lossless() const noexcept { return losses_.empty(); }
83
85 std::vector<Concept> required_consent() const;
86
87 private:
88 friend ExportPlan plan_export(const timeline::Project&, Format, const CensusLimits&);
90 : format_(format), project_(std::move(project)) {}
91
92 Format format_{};
93 timeline::Project project_;
94 ConceptCensus census_;
95 std::vector<Concept> representable_;
96 LossManifest losses_;
97};
98
103 const CensusLimits& limits = {});
104
108std::string loss_manifest_json(const ExportPlan& plan);
109
113 std::function<runtime::Result<ExportArtifacts, ExportError>(const ExportPlan&)>;
114
122 public:
123 using Function =
124 std::function<runtime::Result<ExportArtifacts, ExportError>(const ExportPlan&)>;
125
128 : format_(format), function_(std::move(function)) {}
129
130 explicit operator bool() const noexcept { return static_cast<bool>(function_); }
131 Format format() const noexcept { return format_; }
132
133 private:
136
137 Format format_{};
138 Function function_;
139};
140
144run_export(const ExportPlan& plan, const ExportOptions& options, const ExportWriter& writer);
145
149run_export(const ExportPlan& plan, const ExportOptions& options,
150 const FormatBoundExportWriter& writer);
151
152} // namespace pulp::interchange
Which interchange concepts a document uses, how often, and where.
Definition census.hpp:28
A document measured against one format's capability table: what survives, and what it costs.
Definition export_plan.hpp:68
const LossManifest & losses() const noexcept
Definition export_plan.hpp:79
bool is_lossless() const noexcept
True when no model-detectable concept needs a lossy format row.
Definition export_plan.hpp:82
Format format() const noexcept
Definition export_plan.hpp:70
std::span< const Concept > representable() const noexcept
Concept kinds present in the document that the format supports in isolation.
Definition export_plan.hpp:77
const ConceptCensus & census() const noexcept
Definition export_plan.hpp:72
std::vector< Concept > required_consent() const
The concepts a caller must accept for run_export to proceed.
const timeline::Project & project() const noexcept
Definition export_plan.hpp:71
friend ExportPlan plan_export(const timeline::Project &, Format, const CensusLimits &)
Measure a document against a format.
A format-bound byte writer that can only be invoked by run_export.
Definition export_plan.hpp:121
friend runtime::Result< ExportArtifacts, ExportError > run_export(const ExportPlan &, const ExportOptions &, const FormatBoundExportWriter &)
Execute through a format-bound writer.
Format format() const noexcept
Definition export_plan.hpp:131
FormatBoundExportWriter(Format format, Function function)
Definition export_plan.hpp:127
std::function< runtime::Result< ExportArtifacts, ExportError >(const ExportPlan &)> Function
Definition export_plan.hpp:123
Everything one export costs the document.
Definition loss.hpp:37
Result<T, E> — either holds a T or an E, never both.
Definition result.hpp:76
Immutable root of a Timeline document and its monotonic identity domain.
Definition model.hpp:1079
What the product grants a device: the quota table indexed by capability tier and live thermal state.
Definition aax_editor.hpp:31
Definition census.hpp:13
ExportErrorCode
Definition export_plan.hpp:29
@ NoWriterRegistered
No writer was supplied for the format.
Definition export_plan.hpp:33
@ UnacceptedLoss
The plan loses concepts the caller did not list in accepted_losses.
Definition export_plan.hpp:31
@ WriterFormatMismatch
The supplied writer belongs to a different interchange format.
Definition export_plan.hpp:37
@ WriterFailed
The writer ran and failed on its own terms.
Definition export_plan.hpp:35
runtime::Result< ExportArtifacts, ExportError > run_export(const ExportPlan &plan, const ExportOptions &options, const ExportWriter &writer)
Execute a plan.
ExportPlan plan_export(const timeline::Project &project, Format format, const CensusLimits &limits={})
Measure a document against a format.
Format
Interchange formats with a committed capability declaration.
Definition capability_tables.hpp:38
std::function< runtime::Result< ExportArtifacts, ExportError >(const ExportPlan &)> ExportWriter
The released v0.759 writer seam.
Definition export_plan.hpp:112
std::string loss_manifest_json(const ExportPlan &plan)
Serialize the canonical loss manifest carried by every plan and export result.
STL namespace.
Result<T, E> — success / failure union for fallible operations.
Bounds on how much evidence one census retains.
Definition census.hpp:16
What one export produced.
Definition export_plan.hpp:20
std::vector< std::uint8_t > bytes
Definition export_plan.hpp:22
std::string name
Definition export_plan.hpp:21
Definition export_plan.hpp:25
std::vector< ExportArtifact > artifacts
Definition export_plan.hpp:26
Definition export_plan.hpp:40
std::vector< Concept > concepts
The concepts the error is about. Populated for UnacceptedLoss.
Definition export_plan.hpp:44
ExportErrorCode code
Definition export_plan.hpp:41
std::string message
Definition export_plan.hpp:42
Definition export_plan.hpp:47
std::vector< Concept > accepted_losses
Per-concept consent: every concept the plan reports as lost must appear here or the export refuses.
Definition export_plan.hpp:56