op_id_from_name()
Abstract
Obtains the object ID of an object specified by its parent, type, and name.
Syntax
op_id_from_name (parent_objid, obj_type, obj_name)
| Argument | Type | Description |
|---|---|---|
parent_objid |
Objid |
object ID of the parent object [An object ID can be obtained from several other KPs in this package: op_id_self(), op_id_from_userid(), and op_id_from_name(). Object IDs can also be obtained from the KPs op_intrpt_source(), op_topo_assoc(), and numerous others in the Topo package] |
obj_type |
int |
type of the object-of-interest [This value is an integer code that specifies the type of the object-of-interest (see Table 69 “Object Type Symbolic Constants“ on page 19 and Table 66 “Object Meta-Type Symbolic Constants“ on page 18).] |
obj_name |
const char* |
name of the object-of-interest [This value must match the name of an existing object with the parent and type as specified by the other two arguments, or an error will occur.] |
Return Type
Objid
Object ID of the object matching the specified parent, type, and name, or OPC_OBJID_INVALID if no existing object matches the specified criteria or if a recoverable error occurs.
Example
/* determine the object ID of the desired remote queue */
rem_node_objid = op_id_from_name (0, OPC_OBJTYPE_NODE_FIX, "frnt_end");
rem_queue_objid = op_id_from_name (rem_node_objid, OPC_OBJTYPE_QUEUE, "buffer_a");
/* obtain key state variables of queueing process */
prio_thresh_ptr = (int *) op_ima_obj_svar_get (rem_queue_objid, "prio_thresh");
protocol_version = (char *) op_ima_obj_svar_get (rem_queue_objid, "proto_ver");
/* modify the state variables */
*prio_thresh_ptr = 44;
sprintf (protocol_version, "Ver 5.1")
Details
The three arguments of this KP serve to narrow the set of all simulation objects down to the single object-of-interest. The name of an object and its parent would normally be sufficient to identify a single object, because the Riverbed Modeler editors prevent different objects from sharing the same name within the same context. However, models constructed via EMA do not check for this condition.
Purpose
Provides a mechanism to map object names into object IDs. Unlike op_id_from_userid(), which is restricted to operating on network-domain objects, this KP can also operate on node domain objects. This procedure is typically used to obtain the object ID of a module within a remote or local node, in order to access values of the module’s attributes.
Errors
- Program Abort: Segmentation violation. (due to a malformed
obj_nameargument) - Recoverable Error: Object ID (
<parent_objid>) is out-of-range. - Recoverable Error: Object (
<parent_objid>) has no children. - Recoverable Error: Object (
<parent_objid>) has no child named (<obj_name>) of specified type. - Recoverable Error: Object ID (
<objid>) refers to a restricted object.
Reference
- Use the KP op_id_from_userid() to obtain the object ID of a network object from its user ID
- 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() to obtain child object IDs by type and index
- Use the KP op_topo_parent() to obtain the object ID of the parent of an object
- Use the KP op_ima_obj_hname_get() to get a hierarchial name from an object ID