classPiiBasicOperation
#include <PiiBasicOperation.h>
A bare bones implementation of the PiiOperation interface.
Inherits PiiOperation
Inherited by PiiDefaultOperation, PiiTriggerSource
Description
This class provides facilities for adding and removing sockets. It changes its state immediately when start(), pause(), stop(), or interrupt() is called. PiiBasicOperation provides no means of handling incoming objects in input sockets.
Constructors and destructor
Public member functions
|
virtual void
|
(
Check the operation for execution. |
|
bool
|
Check if the operation has connected inputs. |
|
virtual PiiInputSocket *
|
Returns a pointer to the input associated with name. |
|
(
Returns the input a |
|
|
virtual int
|
( )
Returns the number of input sockets. |
|
virtual QList< PiiAbstractInputSocket
* >
|
( )
Returns a list of all input sockets connected to this operation. |
|
QList<
PiiInputSocket * >
|
( )
Returns attached inputs as PiiInputSockets. |
|
virtual PiiOutputSocket *
|
Returns a pointer to the output associated with name. |
|
(
Returns the output a |
|
|
virtual int
|
( )
Returns the number of output sockets. |
|
virtual QList< PiiAbstractOutputSocket
* >
|
( )
Returns a list of all output sockets connected to this operation. |
|
QList<
PiiOutputSocket *
>
|
( )
Returns attached outputs as PiiOutputSockets. |
|
virtual QVariant
|
Returns the value of a property associated with socket. |
|
virtual State
|
( )
Returns the current state. |
|
virtual bool
|
(
Returns |
Protected member functions
|
virtual void
|
Called by setState() just before the operation changes to a new state. |
|
void
|
Adds an output to the end of the output list. |
|
void
|
Adds an input to the end of the input list. |
|
void
|
Sends |
|
template<class T>
void
|
(
Sends |
|
void
|
(
Sends an end tag to outputs between (and including) firstOutput and lastOutput. |
|
void
|
Adds a new input socket. |
|
void
|
Adds a new output socket. |
|
void
|
( )
Interrupts pending emissions in all output sockets. |
|
virtual void
|
( )
Signals that this operation has paused because it has received a pause tag from a previous operation in the processing pipeline. |
|
virtual void
|
( )
Signals that this operation has resumed from |
|
virtual void
|
( )
Signals that this operation has finished execution for example due to end of data. |
|
(
A convenience function that reads the first object in the input
queue of input at |
|
|
( )
A convenience function that reads the first object in the input queue of the first input. |
|
|
(
Removes the input at |
|
|
(
Removes the input at |
|
|
void
|
Removes the given socket. |
|
void
|
Removes the given socket. |
|
void
|
Sends a control tag to all outputs. |
|
void
|
Maintains a set of numbered inputs at the end of the input list. |
|
void
|
Maintains a set of numbered inputs at the end of the output list. |
|
void
|
Sets the state to |
|
void
|
(
Sends a start tag to outputs between (and including) firstOutput and lastOutput. |
Function details
-
PiiBasicOperation
()[protected] -
~PiiBasicOperation
() -
virtual void check
(- bool reset
[virtual]Check the operation for execution.
If any non-optional sockets is not connected, an exception is thrown.
If you override this function, remember to call the parent's check() function in your own implementation.
Parameters
- reset
-
if
true, all sockets are cleared.
Reimplemented from PiiOperation.
-
bool hasConnectedInputs
()Check if the operation has connected inputs.
-
Returns a pointer to the input associated with name.
Returns
a pointer to the input socket or 0 if no socket matches name
Reimplemented from PiiOperation.
-
PiiInputSocket * inputAt
(- int index = 0
Returns the input a
index.No overflow checking will be performed.
-
virtual int inputCount
()[virtual]Returns the number of input sockets.
The default implementation returns inputs().size().
Reimplemented from PiiOperation.
-
Returns a list of all input sockets connected to this operation.
The order in which the sockets are returned should be "intuitive", but no strict restrictions are imposed.
Reimplemented from PiiOperation.
-
QList< PiiInputSocket * > inputSockets
()Returns attached inputs as PiiInputSockets.
-
Returns a pointer to the output associated with name.
Returns
a pointer to the output socket or 0 if no socket matches name
Reimplemented from PiiOperation.
-
PiiOutputSocket * outputAt
(- int index = 0
Returns the output a
index.No overflow checking will be performed.
-
virtual int outputCount
()[virtual]Returns the number of output sockets.
The default implementation returns outputs().size().
Reimplemented from PiiOperation.
-
Returns a list of all output sockets connected to this operation.
Analogous to inputs().
Reimplemented from PiiOperation.
-
QList< PiiOutputSocket * > outputSockets
()Returns attached outputs as PiiOutputSockets.
-
Returns the value of a property associated with socket.
If name is "name", returns the
objectNameproperty of socket. Otherwise returns the named property. If socket is not attached to this operation, returns an invalid QVariant.Reimplemented from PiiOperation.
-
Returns the current state.
Reimplemented from PiiOperation.
-
virtual bool wait
(- unsigned long time
[virtual]Returns
true.Reimplemented from PiiOperation.
-
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.
-
Adds an output to the end of the output list.
This is a convenience function that calls insertOutput(socket, -1).
Parameters
- socket
-
a pointer to the socket to add to this operation's list of output
-
Adds an input to the end of the input list.
This is a convenience function that calls insertInput(socket, -1).
Parameters
- socket
-
a pointer to the socket to add to this operation's list of inputs
-
Sends
objto the output atindex.A shorthand for output(index)->emitObject(obj).
See also
-
template<class T>
void emitObject
(- const T & value
- int index = 0
[inline, protected]Sends
valueto the output atindex.A shorthand for output(index)->emitObject(value).
See also
-
void endMany
(- int firstOutput = 0
- int lastOutput = -1
[protected]Sends an end tag to outputs between (and including) firstOutput and lastOutput.
-
Adds a new input socket.
Sockets are returned by inputs() in the order they were added.
Parameters
- socket
-
a pointer to an input socket
- index
-
insert the socket at this position. -1 means last.
-
Adds a new output socket.
Analogous to insertInput().
-
void interruptOutputs
()[protected]Interrupts pending emissions in all output sockets.
This is a utility function that can be called from sub-classes' interrupt().
-
virtual void operationPaused
()[protected, virtual]Signals that this operation has paused because it has received a pause tag from a previous operation in the processing pipeline.
This function informs all connected operations that the operation has paused by sending a pause tag to all outputs. It finally throws an exception (PiiExecutionException::Paused).
One may override this function to prepare for pausing. The difference in this and the aboutToChangeState() function is that this function will becalled before the operation passes pause tags to output sockets. If the default implementation is not called, the overridden function must throw a
Pausedexception. -
virtual void operationResumed
()[protected, virtual]Signals that this operation has resumed from
Pausedstate because it has received a resume tag to all connected inputs.This function resolves the state of all input groups and resumes the corresponding synchronized outputs by calling PiiOutputSocket::resume().
One may override this function to restore from pause. The difference in this and the aboutToChangeState() function is that this function will becalled before the operation passes resume tags to output sockets.
-
virtual void operationStopped
()[protected, virtual]Signals that this operation has finished execution for example due to end of data.
This function informs all connected operations that the operation has finished by sending a stop tag to all outputs. It finally throws an exception (PiiExecutionException::Finished).
One may override this function to perform cleanup before stopping. The difference in this and the aboutToChangeState() function is that this function will be called before the operation passes stop tags to output sockets. It is therefore possible to send objects to outputs, if needed. If the default implementation is not called, the overridden function must throw a
Finishedexception. -
A convenience function that reads the first object in the input queue of input at
index. -
A convenience function that reads the first object in the input queue of the first input.
-
Removes the input at
index.The socket will be removed from the socket list and returned. To actually break the connection to this socket, one needs to explicitly disconnect or delete the socket:
delete operation.removeInput(0);
Returns
a pointer to the removed socket, or 0 if the index is out of bounds.
-
Removes the input at
index.The socket will be removed from the socket list and returned. To actually break the connections from this socket, one needs to explicitly disconnect or delete the socket:
delete operation.removeOutput(0);
Returns
a pointer to the removed socket, or 0 if the index is out of bounds.
-
Removes the given socket.
This function calls removeInput(int).
-
Removes the given socket.
This function calls removeOutput(int).
-
Sends a control tag to all outputs.
Parameters
- ptr
-
the control object
-
void setNumberedInputs
[protected]Maintains a set of numbered inputs at the end of the input list.
// Add one static socket in the beginning of the input list addSocket(new PiiInputSocket("first")); // Add three inputs (input0, input1, input2) after the first one. setNumberedInputs(3, 1); // Remove the last two inputs setNumberedInputs(1, 1);
Parameters
- count
-
the number of inputs, numbered sequentially from firstIndex to firstIndex + count - 1.
- staticInputs
-
retain this many inputs at the beginning.
- prefix
-
a common prefix for input names.
- firstIndex
-
the index of the first numbered input
-
void setNumberedOutputs
[protected]Maintains a set of numbered inputs at the end of the output list.
This function works analogously to setNumberedInputs().
-
Sets the state to
state.If the current state is equal to
state, does nothing. Otherwise, the current state will be set tostateand a stateChanged signal will be emitted.This function is a primitive utility function that is not protected with the state lock. Subclasses must acquire the lock where needed.
-
void startMany
(- int firstOutput = 0
- int lastOutput = -1
[protected]Sends a start tag to outputs between (and including) firstOutput and lastOutput.
Add a note
Not a single note added yet. Be the first, add yours.