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
|
virtual PiiAbstractInputSocket
*
|
( )
Returns a pointer to this socket as PiiAbstractInputSocket,
if this socket is either an |
|
virtual PiiAbstractOutputSocket
*
|
( )
Returns a pointer to this socket as PiiAbstractOutputSocket,
if this socket is either an |
|
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
|
(
Searches the queue for an object whose type ID matches
|
|
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
|
(
Jumps the queue. |
|
(
Returns the object at |
|
|
(
Returns a reference to the object at |
|
|
int
|
( )
Returns the capacity of the input queue. |
|
int
|
( )
Returns the number of objects currently in the input queue. |
|
void
|
Puts |
|
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
|
(
Sets the group id. |
|
void
|
Sets an object in the queue. |
|
void
|
(
Sets the |
|
void
|
(
Sets the input queue capacity. |
|
virtual PiiInputSocket *
|
( )
Returns a pointer to this socket as a PiiSocket. |
|
virtual Type
|
( )
Returns |
|
unsigned int
|
(
Returns the type ID of the object at |
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
nameas theobjectNameproperty of this class. -
~PiiInputSocket
()Destroys the socket.
-
Returns a pointer to this socket as PiiAbstractInputSocket, if this socket is either an
Inputor aProxy.Otherwise returns zero.
Reimplemented from PiiSocket.
-
Returns a pointer to this socket as PiiAbstractOutputSocket, if this socket is either an
Outputor aProxy.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().
-
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
trueif the input is connected to a PiiOutputSocket either directly or through a PiiProxySocket,falseotherwise. -
bool isEmpty
()Checks if there queue is empty.
Returns
trueif there are no objects in the queue,falseotherwise. -
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
trueif the socket can be left unconnected,falseotherwise -
void jump
(- int oldIndex
- int newIndex
Jumps the queue.
This function moves the object at
oldIndexto a new place, identified bynewIndex, shifting intermediate objects back. -
PiiVariant objectAt
(- int index
Returns the object at
indexin 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
indexin 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
objinto 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
optionalflag. -
void setQueueCapacity
(- int queueCapacity
Sets the input queue capacity.
-
Returns a pointer to this socket as a PiiSocket.
This is the preferred way of performing a cross-cast, even if
dynamic_castwould work in most cases.Reimplemented from PiiAbstractSocket.
-
Returns
Input.Reimplemented from PiiSocket.
-
unsigned int typeAt
(- int index
Returns the type ID of the object at
indexin the input queue.
Add a note
Not a single note added yet. Be the first, add yours.