1.78 class hyper

A hyper object is a named binary link between two objects. Where slot-references and attribute relations are uni-directed, a hyper may be regarded a two-way object->attribute. Hypers are used for two purposes:

1.78.1 Instance variables

hyper <-> backward_name: name
Hyper-name seen from the hyper<-to object. By default the name is the same in both directions. See hyper<-forward_name.
hyper <-> forward_name: name
Name of the hyper as seen from object hyper<-from.
hyper <- from: object
The variables hyper<-from and hyper<-to define the two objects related by the hyper-link. object<-hypered may be used to find hyper-links from the related objects.
hyper <- to: object
Inherits description from: hyper-from

1.78.2 Send methods

hyper ->_save_relation: file
Consider saving relation (object->save_in_file). A hyper is saved only if both hyper<-from and hyper<-to are saved.
hyper ->initialise: from=object, to=object, forward=[name], backward=[name]
Create a hyper-link from hyper<-from to hyper<-to. Seen from hyper<-from, the link is named hyper<-forward_name, seen from hyper<-to it is called hyper<-backward_name.

This method will invoke object->attach_hyper on both objects to register the hyper.

hyper ->unlink:
Destroy the hyper object and disconnect it from the related objects using object->delete_hyper. See also hyper->unlink_from and hyper->unlink_to.
hyper ->unlink_to:
hyper<-to side is being unlinked.
hyper ->unlink_from:
Called from the object-management system if the hyper<-from (hyper->unlink_from) or the hyper<-to (hyper->unlink_to) side of the hyper is being destroyed. Both methods simply destroy the hyper object.

These methods may be redefined, but always should destroy the hyper by calling free/1. The example below defines a subclass between a whole and a part, where destruction of the whole automatically destroys the part.

:- pce_begin_class(part_hyper, hyper).

unlink_from(H) :->
        get(H, to, Part),
        free(Part),
        free(H).

:- pce_end_class.

A simple example using the code above:

?- send(new(V1, view(hello)), open),
   send(new(P1, picture(world)), open),
   new(_, part_hyper(V1, P1, part, whole)).

V1 = @435643
P1 = @465732

Now the following call will delete both windows:

?- send(@435643, free).