Into

Modules

Documentation

classPiiIdGenerator

#include <PiiIdGenerator.h>

On operation for generating running IDs.

Inherits PiiDefaultOperation

Description

The operation can be used for example for generating file names. The generated id has a format [PREFIX]INDEX[SUFFIX], where [PREFIX] is a string set by the property prefix, INDEX is a running index converted to string generated internally in the operation and [SUFFIX] is a string set by the property suffix. INDEX has at least the width set by the property indexWidth. The extra zeroes are added to fullfill this requirement. The default value for the width is 6. For example if the value of the property prefix were "image", value of the property suffix ".jpg" and the current value of the internal index is 11, the generated id will be "image000011.jpg"

Inputs

triggerany object. Informs that a new id must be generated.

Outputs

idgenerated id as a string having a format [PREFIX]INDEX[SUFFIX]

Properties

int

Defines the minimum width for the INDEX section of the id.

int

Defines the next index for the id.

Prefix for the id.

Suffix for the id.

Constructors and destructor

Public member functions

int
int
( )
( )
void
(
  • int indexWidth
)
void
(
  • int nextIndex
)
void
( )
void
( )
( )

Protected member functions

virtual void
(
  • bool reset
)

Checks the operation for execution.

virtual void
( )

Executes one round of processing.

Property details

  • int indexWidth

    [read, write]

    Defines the minimum width for the INDEX section of the id.

    Extra zeroes are added before other numbers in order to fullfill the minimum width requirement. If for example the value of indexWidth were 4, and the value of the current index were 11, the value of the property prefix "image" and value of the property suffix ".jpg" the generated id would be "image0011.jpg". The default value is 6. If the value is zero, no extra zeroes are added in the index section. The negative values can cause indeterminate results and should be avoided.

  • int nextIndex

    [read, write]

    Defines the next index for the id.

    The default value is zero. The value is not zeroed, when the operation is interrupted, and re-executed. executing the operation after it has been interrupted, doesn't zero it.

  • QString prefix

    [read, write]

    Prefix for the id.

  • QString suffix

    [read, write]

    Suffix for the id.

Function details

  • PiiIdGenerator

    ()
  • int indexWidth

    ()
  • int nextIndex

    ()
  • QString prefix

    ()
  • void setIndexWidth

    (
    • int indexWidth
    )
  • void setNextIndex

    (
    • int nextIndex
    )
  • void setPrefix

    ()
  • void setSuffix

    ()
  • QString suffix

    ()
  • virtual void check

    (
    • bool reset
    )
    [protected, 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 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.

Notes (0)

Add a note

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