op_topo_child_count()

Abstract

Obtains the number of child objects of the requested type contained within the specified parent object.

Syntax

op_topo_child_count (parent_objid, child_type)
Argument Type Description
parent_objid Objid object ID of the parent 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().]
child_type int type of the children-of-interest
[This value is an integer code that specifies the object type of the children-of-interest (see Table 69 “Object Type Symbolic Constants“ on page 19).]

Return Type

int

Number of child objects of the specified type contained within the parent object. The special value represented by the symbolic constant OPC_INT_INVALID will be returned if the parent object does not support children of the requested object type or the parent object ID is invalid.

Example

/* determine the type of the interrupt */
if (op_intrpt_type () == OPC_INTRPT_REMOTE)
	{
	/* cold reboot: total loss of queued packets */
	if (op_intrpt_code () == COLD_REBOOT)
		{
		/* record the number of packets lost */
		num_lost_packets += op_q_stat (OPC_QSTAT_PKSIZE);
		/* flush the queue of its contents */
		op_q_flush ();
		}
	/* prioritize: loop through and sort all subqueues */
	else if (op_intrpt_code () == PRIORITIZE)
		{
		op_ima_obj_attr_get (op_id_self(), "subqueue", &subq_objid);
		num_subqs = op_topo_child_count (subq_objid, OPC_OBJTYPE_SUBQ);
		for (i = 0; i < num_subqs; i++)
			op_subq_sort (i);
		}
	}

Details

The simulation objects that usually contain children are:

  • subnets: children are subnets, nodes, links, and taps
  • nodes: children are modules, streams and statistic wires
  • queues: children are subqueue compound attributes
  • receivers: children are receiver channel compound attribute objects
  • transmitters: children are transmitter channel compound attribute objects
  • compound attributes: children are generic subobjects, subqueues, receiver channels, and transmitter channels

The simulation objects that usually do not contain children are:

  • simplex and duplex point-to-point links
  • bus links
  • bus link taps
  • processors
  • antennas

Paths have no children and do not belong to any subnet; hence this function returns zero if parent_object references a path object or child_type equals OPC_OBJTYPE_PATH.

Examples of cases when the above have children are when the user defines an extended compound attribute for an object, and when the user adds a model attribute to a processor, link, or tap.

Purpose

Provides a mechanism for determining the number of children contained within a parent object, which is useful for setting the bounds on a loop that will perform some operation on each child. In order to obtain the object ID of each child within the parent, the KP op_topo_child() can be invoked with the parent object ID, the same symbolic constant defining the object type, and the index of the loop.

Errors

  • Recoverable Error: Object ID (<parent_objid>) is out-of-range.
  • Recoverable Error: Object meta-type (<child_type>) is unrecognized.
  • Recoverable Error: Object ID (<parent_objid>) refers to a restricted object.

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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