Modeling Services > Dynamic Modeling Services > How to Use Dynamic Objects > Dynamic Relations
 
Dynamic Relations
A dynamic object has a set of dynamic relations as declared to the server model interpreter. Rogue Wave® Server instantiates a subclass of IlsDynRelation according to:
*the relation type (ownership, use or inverse);
*the multiplicity (unary or n-ary);
*the implementation (pointer, list, set, or sorted list).
Set-relations can only store identified objects whose identifier is non-null.
Sorted Relations
Dynamic relations can be implemented as sorted lists. This implementation can be used for aggregation or utilization relations to store objects sorted on their identifier.
To implement this feature, use the ilog.server.implementation="sortedList" property in the XMI description of the corresponding role.
The class IlsDynRelation provides the necessary API to manipulate the relation.
Example
void EditionFunction(IlsViewed& obj)
{
IlsDynObject* dynObj = IlsDynObject::Narrow("Domain", &obj);
if (dynObj) {
IlsDynRelation* nodes = dynObj->getDynRelation("nodes");
if (nodes) {
IlsDynRelationIterator i(*nodes);
IlsViewed* target = 0;
while (i>>target) {
IlsDynObject* node = IlsDynObject::Narrow("Node", *target);
...
}
}
}
}
Note: In the case of ownership relations (IlsOwnsNServerRelation and IlsOwnsSetServerRelation), when you try to add an object that is already the target of another ownership relation, that object is first cut from its previous relation before being assigned to the new relation. The cut method is invoked with ILS_OWNERSHIP as the argument. If you want to avoid this behavior, you must override the cut method on the target type. See Chapter 4 for more information on the “cut” function.

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