op_strm_max_index_out()
Abstract
Obtains the maximum index of any output stream connected to the surrounding processor or queue.
Syntax
op_strm_max_index_out ()
| Argument | Type | Description |
|---|---|---|
| no arguments |
Return Type
int
Maximum index of any connected output stream. The value -1 will be returned if the module has no connected output streams, since output stream numbering begins at zero.
Example
/* determine the number of output streams */
num_out_strms = op_strm_max_index_out ();
/* loop through each output stream, dealing out packets in round-robin fashion. */
for (i = 0; i <= num_out_strms; i++)
{
/* Skip the stream if it is not connected. */
if (op_strm_connected (OPC_STRM_OUT, i) == OPC_FALSE)
continue;
/* Obtain a packet from the source buffer. */
op_strm_access (IN_STREAM_SRCBUF);
/* If a packet was made available, forward it to the i_th destination. */
if (op_strm_empty (IN_STREAM_SRCBUF) == OPC_FALSE)
{
pkptr = op_pk_get (IN_STREAM_SRCBUF);
op_pk_send (pkptr, i);
}
}
Details
The value returned by this KP is the highest physical index of all the connected output streams (i.e., the maximum value of the packet stream objects' src stream attributes). If output streams are sparsely connected, then the returned value is not necessarily related to the number of connected output streams. If on the other hand all connected outputs are contiguous, then the returned value is one less than the number of connected streams, since numbering begins at zero. It is always the case however, that the maximum index (returned by this KP) plus one is an upper bound for the number of connected output streams.
Purpose
Provides a mechanism for upper-bounding the number of output streams that are connected to other objects. This is useful when an operation is to be performed on all connected output streams and the process has no built-in knowledge of which streams are connected. In this case, the process can test all output streams up to and including the maximum index, which is returned by this KP, and determine if they are connected by calling the KP op_strm_connected().
Errors
- Program Abort: KP requires process context.
Reference
- Use the KP op_strm_max_index_in() to determine the input stream index of a module
- Use the KP op_strm_connected() to determine if a specific input or output stream is connected