Into

Modules

Documentation

classPiiFlowController

#include <PiiFlowController.h>

An interface for algorithms that synchronize object flow in sockets.

Inherited by PiiDefaultFlowController, PiiOneGroupFlowController, PiiOneInputFlowController

Description

Instances of this class are used by PiiDefaultOperation to control the flow of objects through operations.

Classes

class

Syncronization event.

class

An interface for objects that receive synchronization events from the flow controller.

Public types

enum
{ IncompleteState, ProcessableState, SynchronizedState, PausedState, FinishedState, ResumedState }

Flow states.

enum
{ NoObject = 0, NormalObject = 1, EndTag = 2, StartTag = 4, StopTag = 8, PauseTag = 16, ResumeTag = 32 }

Type bit masks for input objects.

Constructors and destructor

(
  • Data * data
)

Construct a new flow controller.

virtual

Public member functions

int

Get the ID of the currently active synchronization group.

virtual FlowState
( )  = 0

Prepare the sockets for processing.

virtual void

Send queued sync events to listener.

Static public member functions

template<class InputIterator>
static QString
(
  • InputIterator begin
  • InputIterator end
  • int queueIndex = 1
)

A utility function that creates a textual dump of incoming objects in a group of sockets.

template<class InputIterator>
static int
(
  • InputIterator begin
  • InputIterator end
)

Check a group of synchronized input sockets.

Protected member functions

Construct a new flow controller.

(
  • Data * data
)
void
(
  • int group
)
static QString
(
  • const char * msg
)

Utility function for translating a message.

Enumeration details

  • enum FlowState

    Flow states.

    • IncompleteState - processing is not possible because no group of synchronized input sockets that could be handled now is completely filled.

    • ProcessableState - processing can be performed because a group of synchronized input is full. There may be more objects to be processed, and the caller should send sync events, process the objects and try prepareProcess() again.

    • SynchronizedState - the operation received a start/end tag. There is nothing to be processed now, but the caller should try prepareProcess() again as with ProcessableState.

    • PausedState - the operation should be paused

    • FinishedState - the operation should fully stop processing

    • ResumedState - the operation was resumed after pause and should continue where ever it was left.

  • enum InputGroupType

    Type bit masks for input objects.

    These values are used by inputGroupTypeMask() when checking the state of a group of synchronized input sockets.

    • NoObject - not all inputs in the group have been filled yet

    • NormalObject - all inputs contain a normal object to be processed.

    • EndTag - all inputs contain a synchronization end tag. This indicates that all objects related to an object at a lower flow level have been received.

    • StartTag - all inputs contain a synchronization start tag. This indicates that a set of objects related to an object at a lower flow level are going to be received.

    • StopTag - all inputs contain a stop tag. If all groups contain stop tags, the operation should be stopped.

    • PauseTag - all inputs contain a pause tag. If all groups contain pause tags, the operation should be paused.

    • ResumeTag - all inputs contain a resume tag. Resume tags are used to restore flow levels after pausing. Their functioning is similar to a start tag.

Function details

  • PiiFlowController

    (
    • Data * data
    )
    [protected]
  • PiiFlowController

    ()
    [protected]

    Construct a new flow controller.

  • virtual ~PiiFlowController

    ()
    [virtual]
  • int activeInputGroup

    ()

    Get the ID of the currently active synchronization group.

  • virtual FlowState prepareProcess

    ()
    [pure virtual]

    Prepare the sockets for processing.

    This function is called by PiiOperationProcessor just before it starts a processing round. If processing can be performed, this function places the necessary objects into the input sockets.

    If you reimplement this function yourself, you must conform to the following:

    • If any of the connected sockets in a group does not contain an object, IncompleteState must be returned.

    • If all inputs contain sync tags, they need to be passed to synchronized outputs (PiiOutputSocket::emitObject()) and SynchronizedState must be returned. The inputs must be released (PiiInputSocket::release()).

    • If all inputs contain stop/pause/resume tags, the operation must be either stopped, paused or resumed. The function must return FinishedState, PausedState, or ResumedState, respectively. The caller is responsible for passing the control objects in these cases. PiiOperationProcessor uses PiiBasicOperation::operationStopped(), PiiBasicOperation::operationPaused(), and PiiBasicOperation::operationResumed() helper functions for this. The inputs must be released.

    • If all inputs in a group contain ordinary objects (PiiYdin::isNonControlType()), move objects to be processed from incoming to outgoing slots with PiiInputSocket::release() and return ProcessableState. Only one group can be processed at once. The caller is responsible for re-invoking this function to make sure all processable groups will be handled. Set the active group to the group id of the active group.

    • If a group of synchronized inputs contains mixed inputs (e.g. ordinary objects and sync tags), a PiiExecutionException must be thrown.

    • Synchronization events (if any) should be queued. The sendSyncEvents(SyncListener*) function empties the queue.

    Returns

    If all inputs contain stop, pause, or resume tags, either FinishedState or PausedState, or ResumedState will be returned. Otherwise, returns ProcessableState when a processing round can be performed and IncompleteState when not. Processing can be performed if a group of synchronized sockets is filled with ordinary objects. If a group is filled with synchronization objects, SynchronizedState will be returned.

    Exceptions
    PiiExecutionException&

    if a synchronization error occurs or the listener's inputInSync() function throws.

  • virtual void sendSyncEvents

    ( )
    [virtual]

    Send queued sync events to listener.

    Empty the event queue. The default implementation does nothing.

  • template<class InputIterator>

    static QString dumpInputObjects

    (
    • InputIterator begin
    • InputIterator end
    • int queueIndex = 1
    )
    [static]

    A utility function that creates a textual dump of incoming objects in a group of sockets.

    Can be used to create descriptive error messages for synchronization errors.

    Parameters
    begin

    an interator to the first input to be checked. Typically, this value is returned by QVector<PiiInputSocket*>::begin(). The iterator must point to a PiiInputSocket*.

    end

    the end of the iterable sequence

    queueIndex

    the index of the object to be dumped. The default value is 1, which dumps the first incoming objects. Use 0 to dump the objects currently at the head of the queue.

  • template<class InputIterator>

    static int inputGroupTypeMask

    (
    • InputIterator begin
    • InputIterator end
    )
    [inline, static]

    Check a group of synchronized input sockets.

    In some rare occasions, it may happen that the type mask is (legally) a composition of PauseTag and NormalObject, or ResumeTag and NormalObject. This function automatically resolves such situations by modifying the object queues in input sockets, if possible. If a resolution is found, the function returns PauseTag or ResumeTag, and leaves some input objects in the queues.

    Parameters
    begin

    an interator to the first input to be checked. Typically, this value is returned by QVector<PiiInputSocket*>::begin(). The iterator must point to a PiiInputSocket*.

    end

    an iterator the the last input to be checked

    Returns

    a logical OR composition of InputGroupType masks. If the returned value is none of the values listed in InputGroupType, the group's synchronization is in error.

  • void setActiveInputGroup

    (
    • int group
    )
    [protected]
  • static QString tr

    (
    • const char * msg
    )
    [inline, protected, static]

    Utility function for translating a message.

Notes (0)

Add a note

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