Into

Modules

Documentation

classPiiInputSocket

#include <PiiInputSocket.h>

Default implementation of an input socket.

Inherits PiiSocket, PiiAbstractInputSocket

Inherited by PiiVisualTrainerInputSocket

Description

This class maintains an input queue whose capacity can be controlled with the queueCapacity property. A producer operation can send objects to the input queue and continue working until the input queue is full. Once this happens, the sending thread must wait until the receiver has processed one or more objects.

At the start of each processing round, the parent operation takes one object from the queue to processing. New objects may then appear at any time until the queue is full again.

Properties

int

The capacity of the input queue.

Constructors and destructor

( )

Constructs a new input socket with the given name.

Destroys the socket.

Public member functions

Returns a pointer to this socket as PiiAbstractInputSocket, if this socket is either an Input or a Proxy.

Returns a pointer to this socket as PiiAbstractOutputSocket, if this socket is either an Output or a Proxy.

bool

Checks if the input queue in this socket still has room for a new object.

virtual PiiInputController *

Returns the input controller.

Returns the first object in the input queue.

Returns a reference to the first object in the input queue.

Q_INVOKABLE int

Returns the group id of this socket.

int
(
  • unsigned int type
  • int startIndex = 0
)

Searches the queue for an object whose type ID matches type.

Q_INVOKABLE bool

Checks if the input is connected.

bool

Checks if there queue is empty.

Q_INVOKABLE bool

Checks if this input socket can be left unconnected in processing.

void
(
  • int oldIndex
  • int newIndex
)

Jumps the queue.

(
  • int index
)

Returns the object at index in the input queue.

(
  • int index
)

Returns a reference to the object at index in the input queue.

int

Returns the capacity of the input queue.

int

Returns the number of objects currently in the input queue.

void
( )

Puts obj into the incoming queue.

void

Releases the last slot in the object queue by shifting incoming objects (if any) one step forwards.

void
( )

Resets the socket.

void

Sets the input controller.

void
(
  • int groupId
)

Sets the group id.

void
( )

Sets an object in the queue.

void
(
  • bool optional
)

Sets the optional flag.

void
(
  • int queueCapacity
)

Sets the input queue capacity.

virtual PiiInputSocket *
( )

Returns a pointer to this socket as a PiiSocket.

virtual Type
( )

Returns Input.

unsigned int
(
  • int index
)

Returns the type ID of the object at index in the input queue.

Property details

  • int queueCapacity

    [read, write]

    The capacity of the input queue.

    The default value is 3, which makes it possible to queue two objects in addition to the one currently being processed. The minimum value for queue capacity is 2. Note that queue capacity can safely be changed only if the parent operation is stopped. Changing the capacity will destroy all objects currently in the queue.

Function details

  • PiiInputSocket

    ( )

    Constructs a new input socket with the given name.

    This constructor sets name as the objectName property of this class.

  • ~PiiInputSocket

    ()

    Destroys the socket.

  • virtual PiiAbstractInputSocket * asInput

    ()
    [virtual]

    Returns a pointer to this socket as PiiAbstractInputSocket, if this socket is either an Input or a Proxy.

    Otherwise returns zero.

    Reimplemented from PiiSocket.

  • virtual PiiAbstractOutputSocket * asOutput

    ()
    [virtual]

    Returns a pointer to this socket as PiiAbstractOutputSocket, if this socket is either an Output or a Proxy.

    Otherwise returns zero.

    Reimplemented from PiiSocket.

  • bool canReceive

    ()

    Checks if the input queue in this socket still has room for a new object.

    This function is a shorthand for queueCapacity() > queueLength().

  • virtual PiiInputController * controller

    ()
    [virtual]

    Returns the input controller.

    Reimplemented from PiiAbstractInputSocket.

  • PiiVariant firstObject

    ()

    Returns the first object in the input queue.

    If the queue is empty an invalid variant will be returned.

     PiiVariant obj(pInput->firstObject());
     if (obj.isValid())
       cout << "We just received an object!" << endl;
    
  • PiiVariant & firstObject

    ()

    Returns a reference to the first object in the input queue.

  • Q_INVOKABLE int groupId

    ()

    Returns the group id of this socket.

  • int indexOf

    (
    • unsigned int type
    • int startIndex = 0
    )

    Searches the queue for an object whose type ID matches type.

    Parameters
    type

    the type ID to look for

    startIndex

    start search at this index

    Returns

    the index of the first object with the given type ID, or -1 if no such object is found.

  • Q_INVOKABLE bool isConnected

    ()

    Checks if the input is connected.

    Returns true if the input is connected to a PiiOutputSocket either directly or through a PiiProxySocket, false otherwise.

  • bool isEmpty

    ()

    Checks if there queue is empty.

    Returns true if there are no objects in the queue, false otherwise.

  • Q_INVOKABLE bool isOptional

    ()

    Checks if this input socket can be left unconnected in processing.

    If an optional input socket is left unconnected, the receiving operation ignores it at in processing.

    Returns

    true if the socket can be left unconnected, false otherwise

  • void jump

    (
    • int oldIndex
    • int newIndex
    )

    Jumps the queue.

    This function moves the object at oldIndex to a new place, identified by newIndex, shifting intermediate objects back.

  • PiiVariant objectAt

    (
    • int index
    )

    Returns the object at index in the input queue.

    If there is no such object, an invalid variant will be returned.

  • PiiVariant & objectAt

    (
    • int index
    )

    Returns a reference to the object at index in the input queue.

  • int queueCapacity

    ()

    Returns the capacity of the input queue.

  • int queueLength

    ()

    Returns the number of objects currently in the input queue.

  • void receive

    ( )

    Puts obj into the incoming queue.

  • void release

    ()

    Releases the last slot in the object queue by shifting incoming objects (if any) one step forwards.

    Once the queue is successfully shifted, the socket signals inputReady().

  • void reset

    ()

    Resets the socket.

    This clears the object queue.

  • void setController

    ( )

    Sets the input controller.

  • void setGroupId

    (
    • int groupId
    )

    Sets the group id.

    Input sockets are organized to groups identified by numeric ids. Sockets with the same group id are assumed to work in parallel. The default synchronization mechanism in Ydin ensures that all synchronous inputs with the same group id contain a readable object when an operation is processed. This makes it possible to read in objects with different flow rates. The default group id is zero, which causes all synchronous inputs to work in parallel.

  • void setObject

    ( )

    Sets an object in the queue.

    There is usually no use for this function as objects are received through output sockets, but the function is provided for completeness.

    Parameters
    index

    the index of the object to set

    object

    the new object

  • void setOptional

    (
    • bool optional
    )

    Sets the optional flag.

  • void setQueueCapacity

    (
    • int queueCapacity
    )

    Sets the input queue capacity.

  • virtual PiiInputSocket * socket

    ()
    [virtual]

    Returns a pointer to this socket as a PiiSocket.

    This is the preferred way of performing a cross-cast, even if dynamic_cast would work in most cases.

    Reimplemented from PiiAbstractSocket.

  • virtual Type type

    ()
    [virtual]

    Returns Input.

    Reimplemented from PiiSocket.

  • unsigned int typeAt

    (
    • int index
    )

    Returns the type ID of the object at index in the input queue.

Notes (0)

Add a note

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