ref_type : local_ref | remote_ref
local_ref : 'lref' '<' type_name '>'
remote_ref : ref_kind '<' type_name '>'
ref_kind : 'ref' | 'set' | 'bag' | 'list'
relationship_dcl : 'relationship' ref_kind
'<' type_name '>' [ 'inverse' scoped_name ]
[ 'ordered_by' scoped_name ]
References
are similar to pointers in a memory-based language such as Pascal or C.
A
local_reference(
lref
for short) is a pointer to another value in the same object.
The
type_name
can designate any value type.
A
remote_reference
is a set of zero or more pointers to other objects.
The
type_name
must designate an object type (¸interface), called the "target type
of the relationship.
A
ref
points to zero or one objects,
a
set
points to zero or more distinct objects,
and a
bag
or
list
points to zero or more objects that are not necessarily distinct
(that is, a bag or list contains the identity of each object zero or more
times).
Lists are not supported.
A relationship is similar to an attribute of reference type, but it may also be paired with an inverse relationship. A relationships is more restricted than a pointer in C or C++ in that it may only ``point to'' the start of a whole object, and it can only appear as a ``top level'' attribute. If the inverse clause is present, its scoped_name must designate a relationship of the target type, and that relationship must specify this relationship as its inverse. If the scoped_name does not start with T::, where T is the target type (the type_name in the relationship_dcl), a prefix of T:: is implied.
The implementation will guarantee the integrity of inverse relationships. That is, given
interface A {
...
relationship R<B> x inverse y;
...
};
interface B {
...
relationship R<A> y inverse x;
...
};
where
R
is a
rel_kind,
and given objects
oA
and
oB
of types
A
and
B,
respectively,
the invariant is that
oA.x
contains a reference to
oB
if and only if
oB.y
contains a reference to
oA.
The ordered_by clause may be used only with list relationships. The following scoped_name must designate an attribute of the target class whose type supports a `<' comparison. (As with the inverse clause, an initial target_type:: is optional). It indicates that the references in the list should be maintained in order, sorted by the values of the indicated attribute of the objects to which they refer. If this clause is not specified for list relationship, the ordering is the chronological order in which references are added to it.