classPiiLookupTable
#include <PiiLookupTable.h>
An operation that maps integers into arbitrary data.
Inherits PiiDefaultOperation
Description
Inputs
Outputs
index, the corresponding look-up table entry will be
emitted.
Properties
|
Default value to be used for index over/underflows. |
|
|
int
|
The number of outputs. |
|
QVariantList
|
The look-up table. |
Constructors and destructor
|
( )
|
Public member functions
|
virtual void
|
(
Checks the operation for execution. |
|
( )
|
|
|
int
|
|
|
void
|
|
|
void
|
(
|
|
void
|
(
|
|
QVariantList
|
( )
|
Protected member functions
|
virtual void
|
( )
Executes one round of processing. |
Property details
-
PiiVariant defaultValue
[read, write]Default value to be used for index over/underflows.
If there is no look-up table entry for an input index, this value will be substituted. If the default value is not set and an over/underflow occurs, a run-time exception will be generated.
-
int dynamicOutputCount
[read, write]The number of outputs.
Must be greater than zero. The default value is one.
-
QVariantList table
[read, write]The look-up table.
The look-up table is represented as a list of variants. Each entry may be either a PiiVariant or a QVariantList. In the first case,
table[index]will be emitted through all outputs wheneverindexis received. If the list elements are QVariantLists,table[0][index]will be emitted throughoutput0etc.PiiOperation* lut = engine.createOperation("PiiLookupTable"); // Map 0 to true and 1 to false. Emit the boolean value through all outputs. lut->setProperty("table", QVariantList() << Pii::createQVariant(true) << Pii::createQVariant(false)); QVariantList tbl; // Map 0 to 0 and 1 to -1 in output0 tbl.append(QVariantList() << Pii::createQVariant(0) << Pii::createQVariant(-1)); // Map 0 to "zero" and 1 to "one" in output1 tbl.append(QVariantList() << Pii::createQVariant(QString("zero")) << Pii::createQVariant(QString("one"))); lut->setProperty("table", tbl);
If the number of look-up lists is less than the number of outputs (see outputCount), the last valid value will be used for all extra outputs. If multiple lists are provided, each must be of the same length. Invalid lists will be ignored. If list values are not PiiVariants, they will be substituted with zeros. This will most likely cause a run-time exception, so be careful.
By default, the look-up table contains nothing.
Function details
-
PiiLookupTable
() -
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.
-
PiiVariant defaultValue
() -
int dynamicOutputCount
() -
void setDefaultValue
-
void setDynamicOutputCount
(- int count
-
void setTable
(- const QVariantList & table
-
QVariantList table
() -
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.