op_topo_assoc_count()
Abstract
Obtains the number of associations of the reference object that have the specified type and direction.
Syntax
op_topo_assoc_count (objid, direction, objmtype)
| Argument | Type | Description |
|---|---|---|
objid |
Objid |
object ID of the reference object [An object ID can be obtained from several KPs in the Id package: op_id_self(), op_id_from_userid(), and op_id_from_name(). In addition, object IDs can be obtained from prior invocations of the Topo package KPs op_topo_parent(), op_topo_child(), op_topo_assoc(), and op_topo_connect().] |
direction |
int |
direction of associationOPC_TOPO_ASSOC_IN for input associationsOPC_TOPO_ASSOC_OUT for output associations |
objmtype |
int |
object meta-type of association [This value is an integer code that specifies the object type of the association-of-interest (see Table 69 “Object Type Symbolic Constants“ on page 19).] |
Return Type
int
Number of associations of specified direction and type. The special value represented by the symbolic constant OPC_INT_INVALID will be returned if a recoverable error occurs.
Example
Excerpt from: example model (models/std/sdr); process model (sdr); state (INIT); enter execs
/* Set up routing and interface tables. */
num_out_assoc = op_topo_assoc_count (loc_mod_objid, OPC_TOPO_ASSOC_OUT,
OPC_OBJTYPE_STRM);
for (i = 0; i < num_out_assoc; i++)
{
strm_objid = op_topo_assoc (loc_mod_objid, OPC_TOPO_ASSSOC_OUT,
OPC_OBJTYPE_STRM, i);
op_ima_obj_attr_get (strm_objid, "src stream", &strm);
if (strm != 0)
. . .
}
Details
The input and output associations of an object are the objects directly connected to its input and output ports, respectively. Refer to Table 21 Objects and Associated Types for a list of the valid reference object/association type pairs.
Purpose
Provides a mechanism for determining the number of input or output associations an object has. This is useful for setting the bounds on a loop that performs some operation on each association object. In order to obtain the object ID of each association, the KP op_topo_assoc() can be invoked with the reference object ID and the index of the loop.
Errors
- Recoverable Error: Object ID (<objid>) is out-of-range.
- Recoverable Error: Association direction (<dir>) is unrecognized.
- Recoverable Error: Object meta-type (<objmtype>) is unrecognized.
- Recoverable Error: Object type (<objmtype>) doesn’t support associations.
- Recoverable Error: Assoc. direction (<direction>) is not supported by ref. object.
- Recoverable Error: Object ID (<objid>) refers to a restricted object.
Reference
- Use the KP op_topo_assoc() to obtain the object ID of an association
- Use the KP op_ima_obj_attr_get() to obtain the value of an object’s attribute
- Use the KP op_ima_obj_attr_set() to assign the value of an object’s attribute
- Use the KP op_topo_child_count() to determine the number of children an object has
- Use the KP op_topo_object_count() to determine the number of objects of a particular type