Into

Modules

Documentation

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
(
  • bool reset
)

Check the operation for execution.

bool

Check if the operation has connected inputs.

virtual PiiInputSocket *
( )

Returns a pointer to the input associated with name.

(
  • int index = 0
)

Returns the input a index.

virtual int

Returns the number of input sockets.

( )

Returns a list of all input sockets connected to this operation.

Returns attached inputs as PiiInputSockets.

virtual PiiOutputSocket *
( )

Returns a pointer to the output associated with name.

(
  • int index = 0
)

Returns the output a index.

virtual int

Returns the number of output sockets.

Returns a list of all output sockets connected to this operation.

Returns attached outputs as PiiOutputSockets.

virtual QVariant
( )

Returns the value of a property associated with socket.

virtual State
( )

Returns the current state.

virtual bool
(
  • unsigned long time
)

Returns true.

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 obj to the output at index.

template<class T>
void
(
  • const T & value
  • int index = 0
)

Sends value to the output at index.

void
(
  • int firstOutput = 0
  • int lastOutput = -1
)

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 Paused state because it has received a resume tag to all connected inputs.

virtual void

Signals that this operation has finished execution for example due to end of data.

(
  • int index
)

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.

(
  • int index
)

Removes the input at index.

(
  • int index
)

Removes the input at index.

void

Removes the given socket.

void

Removes the given socket.

void
( )

Sends a control tag to all outputs.

void
(
  • int count
  • int staticInputs = 0
  • const QString & prefix = "input"
  • int firstIndex = 0
)

Maintains a set of numbered inputs at the end of the input list.

void
(
  • int count
  • int staticOutputs = 0
  • const QString & prefix = "output"
  • int firstIndex = 0
)

Maintains a set of numbered inputs at the end of the output list.

void
( )

Sets the state to state.

void
(
  • int firstOutput = 0
  • int lastOutput = -1
)

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.

  • virtual PiiInputSocket * input

    ( )
    [virtual]

    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.

  • virtual QList< PiiAbstractInputSocket * > inputs

    ()
    [virtual]

    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.

  • virtual PiiOutputSocket * output

    ( )
    [virtual]

    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.

  • virtual QList< PiiAbstractOutputSocket * > outputs

    ()
    [virtual]

    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.

  • virtual QVariant socketProperty

    ( )
    [virtual]

    Returns the value of a property associated with socket.

    If name is "name", returns the objectName property of socket. Otherwise returns the named property. If socket is not attached to this operation, returns an invalid QVariant.

    Reimplemented from PiiOperation.

  • virtual State state

    ()
    [virtual]

    Returns the current state.

    Reimplemented from PiiOperation.

  • virtual bool wait

    (
    • unsigned long time
    )
    [virtual]

    Returns true.

    Reimplemented from PiiOperation.

  • 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.

  • void addSocket

    ( )
    [protected]

    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

  • void addSocket

    ( )
    [protected]

    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

  • void emitObject

    ( )
    [protected]

    Sends obj to the output at index.

    A shorthand for output(index)->emitObject(obj).

    See also
  • template<class T>

    void emitObject

    (
    • const T & value
    • int index = 0
    )
    [inline, protected]

    Sends value to the output at index.

    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.

  • void insertInput

    ( )
    [protected]

    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.

  • void insertOutput

    ( )
    [protected]

    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 Paused exception.

  • virtual void operationResumed

    ()
    [protected, virtual]

    Signals that this operation has resumed from Paused state 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 Finished exception.

  • PiiVariant readInput

    (
    • int index
    )
    [protected]

    A convenience function that reads the first object in the input queue of input at index.

  • PiiVariant readInput

    ()
    [protected]

    A convenience function that reads the first object in the input queue of the first input.

  • PiiInputSocket * removeInput

    (
    • int index
    )
    [protected]

    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.

  • PiiOutputSocket * removeOutput

    (
    • int index
    )
    [protected]

    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.

  • void removeSocket

    ( )
    [protected]

    Removes the given socket.

    This function calls removeInput(int).

  • void removeSocket

    ( )
    [protected]

    Removes the given socket.

    This function calls removeOutput(int).

  • void sendTag

    ( )
    [protected]

    Sends a control tag to all outputs.

    Parameters
    ptr

    the control object

  • void setNumberedInputs

    (
    • int count
    • int staticInputs = 0
    • const QString & prefix = "input"
    • int firstIndex = 0
    )
    [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

    (
    • int count
    • int staticOutputs = 0
    • const QString & prefix = "output"
    • int firstIndex = 0
    )
    [protected]

    Maintains a set of numbered inputs at the end of the output list.

    This function works analogously to setNumberedInputs().

  • void setState

    ( )
    [protected]

    Sets the state to state.

    If the current state is equal to state, does nothing. Otherwise, the current state will be set to state and 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.

Notes (0)

Add a note

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