The hierarchy and its effect upon the creation process

This section explains in greater detail how the control of the builder calling process is implemented. To do that, you need to understand the structure of the hierarchy, and the way the DFHTBS components interpret that structure.

Figure 1 shows a more general hierarchy. Node 1 can be considered as a main node: it is at the top of the tree and has two subnodes (2 and 3). However, you could say that node 2 and its subnodes are also a tree: node 2 is the main node, and nodes 4, 5, and 6 are the subnodes. Similarly, with node 3: it has subnodes 7, 8, 9, and 10.

Figure 1. A general hierarchy
Node 1 has subnodes 2 and 3. Subnode 2 has further subnodes, 4, 5 and 6. Subnode 3 has further subnodes, 7, 8, 9 and 10.

The DFHTBS components exploit the idea that a tree consists of a node with trees below it. In fact, DFHTBSBP uses recursion to access the tree of patterns.

Recursion

This section demonstrates how recursion is used to process a much simpler structure than that given in Figure 1. The example shown in Figure 2 is for the DFHTBSP program, which has the following parameters:
Input:
PATTERN, HIGHERNODE, and BUILDER
Inout:
AUDITTRAIL
Output:
NODE and RESPONSE.
The following list outlines the flow in DFHTBSBP. The step references refer to steps in this list.
  1. Add and initialize an action to the AUDITTRAIL (this is used later in steps 5 and 11).
  2. Using parameter PATTERN, find the address of the associated builder.
  3. Call the builder stub with function number 1 (for BUILD) with the following parameters:
    Input:
    HIGHERNODE and BUILDER
    Output:
    NODE.

    The builder uses the BUILDER parameters to create its specific object. Storage is obtained and the parameters are copied into it.

  4. Check that the response from the build is ‘OK’.
  5. Copy the address of the output parameter NODE into the AUDITTRAIL action.
  6. Process all the subpatterns that may be attached to your pattern
  7. Get the next subpattern Pn.
  8. Call DFHTBSBP with the following parameters:
    Input:
    Pn, NODE, and BUILDER
    Inout:
    AUDITTRAIL
    Output:
    SUBNODE and SUBRESPONSE
    Note: In this step, you call yourself again, passing NODE. At the next level of recursion, this appears as HIGHERNODE.
  9. Stop when the last pattern is processed.
  10. Call the builder stub with function number 5 (for CONNECT) with the following parameters:
    Input parameters:
    NODE
    Inout parameters:
    HIGHERNODE

    The builder’s CONNECT entry point now places the address as given by NODE into an offset of HIGHERNODE.

  11. Finally, place the address of the pattern into the AUDITTRAIL action.

Simple recursion example

Consider the following simplified version of the hierarchy as given in Figure 2. The step references refer to steps in the list in Recursion.

Figure 2. Simple example showing recursion
The figure shows the use of recursion to process an example structure as explained in the surrounding text.
  1. Start with pattern P1. Call its associated builder (step 3). This creates node N1.
  2. All the patterns after P1 are processed, the first of which is P2.
  3. Call DFHTBSBP passing P2, N1, BUILDER parameters, and others:
    1. Using the passed pattern (now P2), call the builder. This creates node N2.
    2. Process all patterns after P2; there are no subpatterns, so steps 6 through 9 are not performed.
    3. Call the CONNECT entry of the builder, passing higher node N1 and the node just created, N2. This makes N1 point to N2.
    4. Return to caller.
  4. Get the next pattern, P3.
  5. Call DFHTBSBP passing P3, N1, BUILDER parameters, and others:
    1. Using the passed pattern (now P3), call the builder. This creates node N3.
    2. Process all patterns after P3; there are no subpatterns, so steps 6 through 9 are not performed.
    3. Call the CONNECT entry of the builder passing in higher node N1 and the node just created N3. This makes N1 point to N3.
    4. Return to caller.
  6. Last pattern processed (step 10).
  7. Call the builder associated with P1 to connect node N1 to HIGHERNODE. (This is zero because there is no higher node. Usually, a main builder's CONNECT function either does nothing or adds the TCTTE name and address into the table management tables.)