gstreamer
Loading...
Searching...
No Matches
gstreamer_example.cc File Reference

Multithreaded example showing how to publish synthetic event data through the gstreamer module. More...

#include "gstreamer.h"
#include "glogger.h"
#include "gdynamicdigitization.h"
#include "gutilities.h"
#include "gthreads.h"
#include <atomic>
#include <ranges>
#include <vector>
#include <memory>
#include <unordered_map>
Include dependency graph for gstreamer_example.cc:

Go to the source code of this file.

Functions

void run_simulation_in_threads (int nevents, int nthreads, const std::shared_ptr< GLogger > &log, const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > &dynamicRoutinesMap, const std::shared_ptr< GOptions > &gopts)
 Run a synthetic multithreaded event loop and publish the results through configured streamers.
 
int main (int argc, char *argv[])
 Entry point for the multithreaded gstreamer example.
 

Variables

const std::string plugin_name = "test_gdynamic_plugin"
 

Detailed Description

Summary: This example creates one streamer map per worker thread, builds synthetic detector hits, digitizes them, publishes them through all configured streamers, and closes all outputs at the end of execution.

Related module documentation:

Typical command-line usage:

./gstreamer_example \
-gstreamer="[{format: ascii, filename: out_ascii}, {format: json, filename: out_json}]" \
-ebuffer=20

Definition in file gstreamer_example.cc.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Responsibilities:

  • define and parse module options through gstreamer::defineOptions()
  • create a logger for the example
  • load the test dynamic digitization routine
  • run the synthetic multithreaded event loop
Parameters
argcNumber of command-line arguments.
argvCommand-line argument vector.
Returns
EXIT_SUCCESS on normal completion.

Definition at line 152 of file gstreamer_example.cc.

◆ run_simulation_in_threads()

void run_simulation_in_threads ( int nevents,
int nthreads,
const std::shared_ptr< GLogger > & log,
const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > & dynamicRoutinesMap,
const std::shared_ptr< GOptions > & gopts )

This function demonstrates the intended ownership and threading model of the gstreamer module:

  • one shared configuration object is used by all workers
  • one atomic counter distributes event numbers across threads
  • each worker creates its own streamer map through gstreamersMapPtr()
  • each streamer instance is used only by the thread that created it

Event construction flow:

  • create an event header for the current thread
  • create one event collection
  • create a small synthetic set of hits for detector "ctof"
  • derive both true-information and digitized representations from the dynamic routine
  • publish the event to every configured streamer

The example intentionally uses a compact synthetic dataset so the control flow remains easy to understand while still exercising the full event publication sequence.

Parameters
neventsTotal number of events to generate across all workers.
nthreadsNumber of worker threads to launch.
logShared logger used for progress and diagnostic messages.
dynamicRoutinesMapDynamic digitization routines keyed by plugin name.
goptsParsed options container used to configure the module and dependent components.

Definition at line 67 of file gstreamer_example.cc.

Variable Documentation

◆ plugin_name

const std::string plugin_name = "test_gdynamic_plugin"

Definition at line 39 of file gstreamer_example.cc.