3#include <gemc/gfactory/gfactory.h>
7 std::optional<GStreamerDefinition> selected;
9 if (definition.format !=
"sro") {
continue; }
10 if (selected) {
throw std::invalid_argument(
"Configure only one sro output per simulation"); }
11 selected = definition;
13 if (!selected) {
return nullptr; }
16 selected->implementation, options);
17 return std::make_shared<GSROFactory>(std::move(implementation), selected->rootname);
21 : implementation(std::move(plugin)), run_context{0, 0, std::move(output_basename)} {
22 if (!implementation) {
throw std::invalid_argument(
"SRO requires an implementation plugin"); }
26 run_context.run_id = run_id;
27 run_context.event_count = event_count;
29 auto config = implementation->configure_run(run_context);
30 service.begin_run([plugin = implementation, context = run_context](
GSROCrateId crate) {
31 return plugin->create_crate(crate, context);
32 }, std::move(config.timing), config.crate_limits, config.max_pending_events);
36 service.create_crate_thread_if_needed(crate);
39 service.dispatch_payload_to_crate(std::move(payload));
44 service.cancel_run(error);
47 const auto reason = all_events_processed && !interrupted
49 service.finish_run({reason, std::nullopt});
std::shared_ptr< T > LoadAndRegisterObjectFromLibrary(std::string_view name, const std::shared_ptr< GOptions > &gopts)
void cancel_run(std::exception_ptr error)
GSROFactory(std::shared_ptr< GSROImplementation > implementation, std::string output_basename)
void rethrow_if_failed() const
void create_crate_thread_if_needed(GSROCrateId crate)
static std::shared_ptr< GSROFactory > from_options(const std::shared_ptr< GOptions > &options)
Return null when SRO is disabled. Load the selected implementation before workers are created.
void finish_run(bool all_events_processed)
void complete_event(GSROEventId event)
void begin_run(int run_id, GSROEventId event_count)
void dispatch_payload_to_crate(GSROPayload payload)
std::uint32_t GSROCrateId
std::uint64_t GSROEventId
vector< GStreamerDefinition > getGStreamerDefinition(const std::shared_ptr< GOptions > &gopts)
Parse all configured gstreamer output definitions from the options container.
Option and configuration helpers for the gstreamer module.
One worker-produced contribution, transferred by move to its destination crate.