op_id_to_type()

Abstract

Obtains the type of the specified object.

Syntax

op_id_to_type (objid)
Argument Type Description
objid Objid object ID of the object-of-interest
[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]

Return Type

int

Type of the specified object.

[This value is an integer code which represents one of the possible object types; it can be compared to the constants in Table 69 “Object Type Symbolic Constants“ on page 19.]

Example

/* determine the object ID of the surrounding node */
node_objid = op_topo_parent (op_id_self ());
/* determine the number of outgoing links (of any type) the node is connected to */
num_out_links = op_topo_assoc_count (node_objid, OPC_TOPO_ASSOC_OUT,
	OPC_OBJMTYPE_LINK);
/* loop through each outgoing link */
for (ol = 0; ol < num_out_links; ol++)
	{
	/* obtain object ID of outgoing link */
	ol_objid = op_topo_assoc (node_objid, OPC_TOPO_ASSOC_OUT, OPC_OBJMTYPE_LINK, ol);
	/* switch based on specific type of outgoing link */
	switch (op_id_to_type (ol_objid))
		{
		case OPC_OBJTYPE_LKBUS: /* ... */ break;

		case OPC_OBJTYPE_LKDUP: /* ... */ break;

		case OPC_OBJTYPE_LKSIMP: /* ... */ break;
		}

Details

None.

Purpose

Provides a mechanism to determine an object’s type based on its object ID. This is usually necessary when an object ID is obtained by a process, and it needs to determine the type of the object to tailor its processing. This is typically needed when a generically-written process is attempting to determine its local interconnection topology using KPs in the Topo package which provide the object IDs of input and output associations of the surrounding module or node.

Errors

  • Recoverable Error: Object ID (<objid>) is out-of-range.
  • Recoverable Error: Object ID (<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_parent() to obtain the object ID of an object’s parent
  • Use the KP op_topo_assoc() to obtain the object ID of an object’s association
  • Use the KP op_topo_assoc_count() to determine the number of associations of a given type

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com