company logo

Property handle hierarchies

Property handles can be opened in a hierarchical order as shown below. The top property handle must be opened with a Database or ObjectSpace handle as parent. Subordinated property handles are opened with a property handle as parent. Each property handle can be the parent of any number of subordinated property handles.

Considering a Person object in the sample database, you will find the children property. Since the children property refers to a collection of Person s, again, persons in the children collection may have got children again.

Property handles opened in a hierarchical order, as shown below, will always reflect exactly one access path through the instance tree defined by the reference properties in the hierarchy, i.e. selecting a person in the top person property handle creates the set of children for the subordinated children property handle. Changing the selected instance in the top property handle person , automatically changes the collection represented in the subordinated children property handle to the set of children for the newly selected person on top.

Selecting a person in the children property handle will immediately provide a set of grandchildren in the lowest property handle, i.e. the children of the child selected from the set of children for the top most person.

void HandleHierarchy ( ObjectSpace &os ) {

  Property     person(os,"Person::Persons",Read);

  Property     children(person,"children");

  Property     grandChildren(children,"children");

  Value        name(grandChildren,"name");

  Value        firstName(grandChildren,"first_name");

  

  while ( person.next(true) )

    while ( children.next(true) )

      while ( grandChildren.next(true) )

        printf("Grand child: %s %s",name.toString(),firstName.toString());

}

Notes:

Property and value handles in this example refer to internal access nodes (see nect subtopic), which will be shared between all property handles created this way, i.e. after creating e.g. two property handles for children this way, changing the selection in one property handle will change the selection in the other children property handle as well, since both refer to the same (internal) access node.