op_topo_object_count()
Abstract
Obtains the number of objects of the specified meta-type.
Syntax
op_topo_object_count (objmtype)
| Argument | Type | Description |
|---|---|---|
objmtype |
int |
object meta-type [This value is an integer code that specifies the object type of the object-of-interest (see Table 69 “Object Type Symbolic Constants“ on page 19).] |
Return Type
int
Number of objects of the specified 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_addr); state (INIT); enter execs.
/* Get the number of nodes. */
num_nodes = op_topo_object_count (OPC_OBJTYPE_NODE_FIX);
/* Set up the address distribution. */
address_dist = op_dist_load (“uniform_int”, 0, num_nodes - 1);
/* Initialize the ICI used for address announcement. */
ici_ptr = op_ici_create (“sdr_addr”);
Details
None.
Purpose
Provides a way to obtain the number of objects of a given type, regardless of their location in the object hierarchy. This is useful when a process needs to obtain or assign attributes that belong to objects of one type. For example, a process might need to set the bit error rate of all bus links to 0.0 at the beginning of the simulation. The KP op_topo_object_count() will provide the upper bound for the loop that will call op_topo_object() to obtain each bus link’s object ID and then call op_ima_obj_attr_set() to set the bit error rate attribute value.
Errors
- Recoverable Error: Object meta-type (<objmtype>) is unrecognized.
Reference
- Use the KP op_topo_object()) to obtain the object ID of an object
- Use the KP op_topo_assoc_count() to determine the number of input or output associations
- Use the KP op_topo_child_count() to determine the number of children an object has