GenClass: 7.1 Special Message Passing: Parent and Child Message Passing

Up: GEOS SDK TechDocs | Up | Prev: 7 Special Message Passing | Next: 7.2 Generic Upward Queries
MSG_GEN_CALL_PARENT, MSG_GEN_SEND_TO_PARENT, MSG_GEN_SEND_TO_CHILDREN

Three messages enable you to pass other messages to a generic object's parents and children without having to know the proper optrs. Using these messages, you can perform operations on any generic object's parents and children. If you need return values from an operation being performed by the parent object, use MSG_GEN_CALL_PARENT . If no return values are needed, you may use MSG_GEN_SEND_TO_PARENT .

To pass a message to all of your generic children, use MSG_GEN_SEND_TO_CHILDREN . Note that no comparable MSG_GEN_CALL_CHILDREN exists because it is meaningless to expect return values from multiple objects for a single event.

You may also use the Goc macros genParent and genChildren to send a message to a parent or the generic children of an object.

MSG_GEN_CALL_PARENT

void	MSG_GEN_CALL_PARENT(
        EventHandle		event);

This message delivers an event to the generic parent of the recipient. This message must pass a classed event that the parent object will handle. You should use this message if return values are expected. Always make sure to cast the return (following the call) into the proper type. The most effective way to do this is by enclosing the actual message sent within parentheses. The event will be freed after it is sent.

Source: Unrestricted.

Destination: Any generic object.

Parameters: event The classed event to deliver to parent of this object.

Return: The return value of the classed event (cast to the proper type).

Interception: Generally not intercepted. Custom gadgets may handle to supplement or supersede default functionality.

Code Display 2-28 MSG_GEN_CALL_PARENT

/* The following method retrieves the visual moniker
 * of an object's parent. */
@method MyProcessClass, MSG_GET_MY_PARENTS_MONIKER {
    ChunkHandle parentMoniker;
    EventHandle myEvent;
	/* Encapsulate the message to be handled
	 * by any generic (GenClass) object. */
    myEvent = @record GenClass::MSG_GEN_GET_MONIKER();
/* Calls the parent of EntryNumberTwo with the classed event specified above. Note
 * that the return value is cast to type (MSG_GEN_GET_MONIKER) because
 * MSG_GEN_CALL_PARENT itself returns void. */
    parentMoniker = @call (MSG_GEN_GET_MONIKER) 
			@EntryNumberTwo::MSG_GEN_CALL_PARENT(myEvent);
    return(parentMoniker); /* return the parentMoniker. */
}

MSG_GEN_SEND_TO_PARENT

void	MSG_GEN_SEND_TO_PARENT(
        EventHandle event);

This message sends an encapsulated event to the parent but expects no return values. The event will be freed after it is sent.

Source: Unrestricted.

Destination: Any generic object.

Parameters: event The classed event to deliver to parent of this object.

Interception: Generally not intercepted. Custom gadgets may handle to supplement or supersede default functionality.

MSG_GEN_SEND_TO_CHILDREN

void	MSG_GEN_SEND_TO_CHILDREN(
        EventHandle event);

This message sends an encapsulated event to all children of the generic object receiving it. This message cannot return values. The event will be freed after it is sent.

Source: Unrestricted.

Destination: Any generic object.

Parameters: event The classed event to deliver to all children.

Interception: Generally not intercepted. Custom gadgets may handle to supplement or supersede default functionality.


Up: GEOS SDK TechDocs | Up | Prev: 7 Special Message Passing | Next: 7.2 Generic Upward Queries