Into

Modules

Documentation

classPiiSwitch

#include <PiiSwitch.h>

An operation that passes objects conditionally depending on a trigger input.

Inherits PiiDefaultOperation

Description

Inputs

triggertrigger input. Type is ignored in AsynchronousMode, and the input can even be left unconnected. In SynchronousMode, the trigger must be a boolean value or a number.
inputXreads in objects of any type. The object read from inputX will be emitted to outputX when triggered. X ranges from 0 to inputCount - 1. input0 can also be accessed as input.

Outputs

outputXemits the last input object whenever a trigger is received. output0 can also be accessed as output.
The default number of input-output pairs is 1.

Properties

int

The number of dynamic inputs (in addition to trigger).

Operation mode.

bool

Turns the trigger input to "always on".

Public types

enum
{ SynchronousMode, AsynchronousMode }

Operation modes.

Constructors and destructor

( )

Public member functions

virtual void
(
  • bool reset
)

Checks the operation for execution.

virtual PiiInputSocket *
( )

Aliases input to input0.

virtual PiiOutputSocket *
( )

Aliases output to output0.

Protected member functions

virtual void
( )

Called by setState() just before the operation changes to a new state.

(
  • int index
)
int
bool
virtual void
( )

Executes one round of processing.

void
(
  • int inputCount
)
void
( )
void
(
  • bool passThrough
)

Property details

  • int dynamicInputCount

    [read, write]

    The number of dynamic inputs (in addition to trigger).

    The default is one.

  • OperationMode operationMode

    [read, write]

    Operation mode.

    The default mode is SynchronousMode.

  • bool passThrough

    [read, write]

    Turns the trigger input to "always on".

    This property only affects AsynchronousMode. Setting its value to true makes the operation pass all incoming objects directly and ignore the trigger input. If the trigger input is not connected (in AsynchronousMode), this property controls can be used to block and release the object flow through this operation. The default value is false.

Enumeration details

  • enum OperationMode

    Operation modes.

    • AsynchronousMode - trigger and the other inputs are not synchronized to each other. The trigger can come from any unrelated source. If passThrough is false, exactly one set of input objects will be passed for each object received from the trigger input. If there are no incoming objects when the trigger arrives, the next incoming objects will be emitted. If passThrough is true, the trigger input will have no effect and all input objects will be passed. Note that the same objects may be sent many times if the trigger input has a higher data rate than the other inputs.

    • SynchronousMode - the trigger signal is used as a "filter". All inputs work in sync: there must be a trigger signal for each set of input objects. If a non-zero number or true is received, the input objects will be passed. Otherwise, the input objects will be ignored.

Function details

  • PiiSwitch

    ()
  • virtual void check

    (
    • bool reset
    )
    [virtual]

    Checks the operation for execution.

    This function creates a suitable flow controller by calling createFlowController(). It then sets the flow controller to the active processor and sets the processor as the input controller for all inputs.

    If you change socket groupings in your overridden implementation, please call PiiDefaultOperation::check() after that. Otherwise, your new groupings will not be in effect.

    Reimplemented from PiiDefaultOperation.

  • virtual PiiInputSocket * input

    ( )
    [virtual]

    Aliases input to input0.

    Reimplemented from PiiBasicOperation.

  • virtual PiiOutputSocket * output

    ( )
    [virtual]

    Aliases output to output0.

    Reimplemented from PiiBasicOperation.

  • virtual void aboutToChangeState

    ( )
    [protected, virtual]

    Called by setState() just before the operation changes to a new state.

    The function will be called independent of the cause of the state change (internal or external). Derived classes may implement this function to perform whatever functionality is needed when a state changes. The default implementation does nothing.

    Reimplemented from PiiBasicOperation.

  • PiiInputSocket * createInput

    (
    • int index
    )
    [protected]
  • int dynamicInputCount

    ()
    [protected]
  • OperationMode operationMode

    ()
    [protected]
  • bool passThrough

    ()
    [protected]
  • 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.

  • void setDynamicInputCount

    (
    • int inputCount
    )
    [protected]
  • void setOperationMode

    ( )
    [protected]
  • void setPassThrough

    (
    • bool passThrough
    )
    [protected]
Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.