op_topo_parent()
Abstract
Obtains the object ID of the specified object’s parent.
Syntax
op_topo_parent (child_objid)
| Argument | Type | Description |
|---|---|---|
child_objid |
Objid |
object ID of the child 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().] |
Return Type
Objid
Object ID of the parent object. If argument child_objid is the top subnetwork ID, returns the symbolic constant OPC_OBJID_NULL.
The special value represented by the symbolic constant OPC_OBJID_INVALID will be returned if a recoverable error occurs.
Example
/* Obtain self ID */
myid = op_id_self ();
/* Obtain the attribute values. */
op_ima_obj_attr_get (myid, "address", &my_address);
op_ima_obj_attr_get (myid, "average_interarrival_time", &ia_time);
op_ima_obj_attr_get (myid, "average_service_time", &service_time);
op_ima_obj_attr_get (myid, "ack_service_time", &ack_service_time);
/* Obtain the parent object id and name. */
ppid = op_topo_parent (myid);
op_ima_obj_attr_get (ppid, "name", name);
Details
Successive calls to this KP can be used to move up the object hierarchy. In an example simulation with five levels of objects, a subqueue object ID could be used to obtain the “top” subnet (object ID = 0) using five successive calls to this KP, as shown below:
subq_comp_attr_objid = op_topo_parent (subqueue_objid);
queue_objid = op_topo_parent (subq_comp_attr_objid);
node_objid = op_topo_parent (queue_objid);
subnet_objid = op_topo_parent (node_objid);
top_subnet_objid = op_topo_parent (subnet_objid);
Note that subq_comp_attr_objid is a built-in type of compound attribute. For user-defined compound attributes:
comp_attr_objid = op_topo_parent (generic_objid);
Paths have no parents; hence this KP returns an invalid handle if child_obj_hndl references a path object.
Purpose
Provides a mechanism to move up the object tree when a low level object’s ID is known, and an operation needs to be performed on a higher level object. Typically, this KP is used to obtain the object IDs of the node (or in turn, subnet) that contains the processor or queue running the invoking process. Having obtained the relevant node or subnet object IDs, the values of attributes that have been assigned at these levels can be obtained via the KP op_ima_obj_attr_get().
Errors
- Recoverable Error: Object ID (<child_objid>) is out-of-range.
- Recoverable Error: Object ID (<child_objid>) refers to a restricted object.
Reference
- Use the KP op_id_self() to obtain the object ID of the surrounding processor or queue module
- Use the KP op_topo_child() to obtain the object ID of another object’s child
- 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