classPiiObjectReplicator
#include <PiiObjectReplicator.h>
An operation that replicates an object received in its
data input.
Inherits PiiDefaultOperation
Description
The operation useful when an object needs to be repeated many
times. A typical situation arises when an image is split into
smaller pieces, each of which is processed separately. Later, the
pieces need to be connected to the name of the original image file,
which is sent by PiiImageFileReader only
once per each image. The solution is to connect the file name to
the data input of a PiiObjectReplicator and
trigger its output with the smaller image pieces.
This operation can lead to lock-ups if not used carefully. If two
branches of a processing pipeline are connected to the
data and trigger inputs, make sure that
data is always received first. Otherwise, if there are
no threaded operations in the pipelines, and if the input queue in
trigger becomes full before data is
received, the whole configuration may hang. The output that sends
data to the two branches should be first connected to
data and then to the other branch.
Inputs
data each time an object is received in this
input. Any type.
Outputs
data. This output will emit the
object whenever an object is received in
trigger.
Constructors and destructor
Protected member functions
|
virtual PiiFlowController *
|
Creates a flow controller for this operation. |
|
virtual void
|
( )
Executes one round of processing. |
Function details
-
PiiObjectReplicator
() -
Creates a flow controller for this operation.
This function is called by the default implementation of check(). A new flow controller will be always be created when the check() function is called. The old controller will be deleted.
The default implementation tries to find an optimal flow controller for the active input configuration:
-
If there are no connected inputs, a null pointer will be returned.
-
If the operation has only one connected input, PiiOneInputFlowController will be used.
-
If there are many inputs, but all are in the same group, PiiOneGroupFlowController will be used.
-
Otherwise, PiiDefaultFlowController will be used. The flow controller will be configured with loose parent-child relationships between groups with a non-negative group id and at least one connected socket. The relationships will be assigned in the order of increasing magnitude. For example, if there are sockets in groups 0, 1, and -1, 0 will be set as the (loose) parent of 1. Group -1 will be independent of the others.
Returns
a pointer to a flow controller. PiiDefaultOperation will take the ownership of the pointer. If you don't want inputs to be controlled, return 0.
See also
Reimplemented from PiiDefaultOperation.
-
-
virtual void process
()[protected, virtual]Executes one round of processing.
This function is invoked by the processor if the necessary preconditions for a new processing round are met. This function does all the necessary calculations to create output objects and sends them to output sockets.
Calls to process(), syncEvent(), and setProperty() are synchronized and cannot occur simultaneously. PiiDefaultOperation ensures this by locking processLock() for reading before calling process().
Note: With time-consuming operations, one should occasionally check that the operation hasn't been interrupted, i.e. that state() returns
Running.Exceptions
- PiiExecutionException
-
whenever an unrecoverable error occurs during a processing round, the operation is interrupted, or finishes execution due to end of input data.
Reimplemented from PiiDefaultOperation.
Add a note
Not a single note added yet. Be the first, add yours.