|
libtcspc C++ API
Streaming TCSPC and time tag data processing
|
Event processors.
Processors in libtcspc are usually classes defined in an internal namespace. They are exposed in the API through factory functions named after a verb describing what the processor does and return the processor by value. A few special processor factory functions (e.g., tcspc::merge()) return multiple processors that can be assigned via structured binding. The factory function, by convention, takes the downstream processor as the last parameter and takes ownership of it (or copies it, if lvalue).
All processors are movable but not necessarily copyable.
All processors (except for sinks) have a downstream processor. This downstream processor is moved into the next-upstream processor, so that an assembled processing graph is a single object (often with a very long type name). A few special processors (e.g., tcspc::broadcast(), tcspc::route()) have multiple downstream processors. Also, some special processors (e.g., tcspc::merge(), tcspc::type_erased_processor) do not contain their downstream as a subobject but they always own the downstream processor(s) even if by reference.
Thus a graph of processors can be built, but this must be done from downstream to upstream.
Once built, the processing graph operates in push mode: events are passed from upstream processors to downstream processors by function calls. Each processor is basically a state machine that changes state based on events received, and in some cases emits events to the downstream processor(s). The set of event types accepted by a given processor is determined by C++ type rules based on the processor's handle() member function overload set. The end of the stream of events is signaled down the chain of processors via the flush() member function. Processing may also terminate due to an error (see below).
Processor factory functions never call handle() or flush() on downstream processors. After construction, processors must always be prepared to receive any of their accepted events while processing continues (but they may signal an error if the sequence of events is incorrect). Behavior is undefined if handle() or flush() is called on a processor that has been flushed or has stopped with an error.
Unless specified otherwise, processors operate on a single thread.
Processors implement the following member functions (none of which should be noexcept):
End of processing and error handling
When the input data has reached its end, the flush() function is used to propagate this information down the chain of processors, giving them a chance to propagate any remaining events originating from the events already received.
A processor's handle() and flush() functions may throw an exception under two circumstances:
Warnings
For recoverable errors, some processors emit tcspc::warning_event rather than throwing an exception. The tcspc::stop() and tcspc::stop_with_error() processors can be used to end processing on a warning event.
Context, trackers, and accessors
See tcspc::context.
Guidelines for writing processors
In addition to following what is specified above:
Topics | |
| Core processors | |
| Basic and generic processors. | |
| Buffering processors | |
| Processors for buffering data. | |
| Branching processors | |
| Processors for splitting the processing graph. | |
| Merging processors | |
| Processors for joining branches in the processing graph. | |
| Input and output processors | |
| Processors for reading and writing data from/to file-like streams. | |
| Acquisition processors | |
| Processors for acquiring data from hardware devices. | |
| Decoding processors | |
| Processors for decoding device events. | |
| Timeline processors | |
| Processors for managing and manipulating the absolute timeline. | |
| Timing signal processors | |
| Processors for transforming timing signal events. | |
| Time correlation processors | |
| Processors for time correlation. | |
| Histogramming processors | |
| Processors for histogramming. | |
| Validation processors | |
| Processors for data validation. | |
| Statistics processors | |
| Processors for collecting statistics. | |
| Testing processors | |
| Processors for unit testing of processors. | |