unsetSetContext > Semantics of Dynamic View Type Specifications > References
 
References
A representation attribute can be a reference to another representation object. In the following example, the owner attribute attached to the item representation, which is associated with Node, is a reference to the tree representation, which is associated with the target of the domain relation.
subscribe origin Domain:
represent Tree tree:...
subscribe Node:
represent TreeItem item:
Ref<Tree> owner=domain->tree;
...
*A reference is always specified with the type of a representation object. In the above example, the tree reference is of type Tree. You can associate an editing function with a reference using the macro ILS_RP_ATTR_REF.
*A reference is always associated with a unary Server runtime relation and with the name of a representation. In the example above, the reference attribute owner is associated with the runtime relation domain declared on the server runtime type Node.
The following member functions are used to notify a modification to a reference attribute to the server:
IlsBoolean onUpdate(IlsRpAttributeId id,const IlsRpObject& objRef);
IlsBoolean::onUpdate(IlsRpAttributeId,IlsRpObject& objRef,
IlsRpAttributeId);
IlsBoolean onNullifyRef(IlsRpAttributeId id);
These functions require that the runtime relation associated with the reference attribute declare a modifier. In this case, when called on the representation object that owns the reference, these functions request the server to replace the relation target with the Server object associated with the representation object objRef (functions onUpdate) or simply to remove the target (function onNullifyRef).
*A reference can be declared as mandatory. If the value of a Server relation defining a reference is null, the representation object that holds this reference is not created. In the following example, the item representation object that is associated with Node is not created if the domain relation has no target, or if this target is not associated with a tree representation.
subscribe origin Domain:
represent Tree tree:...
subscribe Node:
represent TreeItem item:
mandatory Ref<Tree> owner=domain->tree;
...
If you specify representations that use references, you must ensure that the order in which propagation is performed and representations are created is correct.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.