GenClass: 5.1 Generic Trees: Child/Parent Searches

Up: GEOS SDK TechDocs | Up | Prev: 5 Generic Trees | Next: 5.2 Manipulating Children Directly
MSG_GEN_FIND_CHILD, MSG_GEN_FIND_CHILD_AT_POSITION, MSG_GEN_FIND_PARENT, MSG_GEN_COUNT_CHILDREN

The following messages provide means of searching the generic tree. It is necessary (in most cases) to check whether a child exists for an object before attempting to delete or access the child. Note that it is bad practice to retrieve optrs using these messages and then some time later send messages manipulating these optrs directly because the tree might change. Instead, use the generic dispatch messages MSG_GEN_CALL_PARENT , MSG_GEN_SEND_TO_CHILDREN , etc.

MSG_GEN_FIND_CHILD

word	MSG_GEN_FIND_CHILD(
        optr child);

This message checks whether the object is a child of the recipient. If so, it returns the child's position. If you wish to find out if a specific child currently exists at a certain position, use MSG_GEN_FIND_CHILD_AT_POSITION .

Source: Unrestricted.

Destination: Any generic object.

Parameters: child The optr of child to search for.

Return: The numbered position (zero-based) of the child, or -1 if the specific child is not found.

Interception: Generally not intercepted.

MSG_GEN_FIND_CHILD_AT_POSITION

optr	MSG_GEN_FIND_CHILD_AT_POSITION(
        word position);

This message returns the optr of the child at position , if any. Pass the message the zero-based (zero indicates the first child) position to check. If no child is found, the message returns zero.

Source: Unrestricted.

Destination: Any generic object.

Parameters: position The position (zero-based) of the child to search for.

Return: The optr of child at position passed, if found. Otherwise returns zero.

Interception: Generally not intercepted.

MSG_GEN_FIND_PARENT

optr	MSG_GEN_FIND_PARENT();

This message returns the parent of the recipient object, if any.

Source: Unrestricted.

Destination: Any generic object.

Return: The optr of the parent object. If no parent is found, this message returns zero.

Interception: Generally not intercepted.

MSG_GEN_COUNT_CHILDREN

word	MSG_GEN_COUNT_CHILDREN();

This message returns the number of children of the recipient.

Source: Unrestricted.

Destination: Any generic object.

Return: The number of children the object has.

Interception: Generally not intercepted.


Up: GEOS SDK TechDocs | Up | Prev: 5 Generic Trees | Next: 5.2 Manipulating Children Directly