For this weekend I decided not to play around with VI Scripting but do learn some LVOOP.
What I would like to do is to get the following design into LVOOP, taken from the UML specs:
--
7.3.14 Element (from Kernel)
[..]
Associations
• ownedComment: Comment[*]
The Comments owned by this element. Subsets Element::ownedElement.
• / ownedElement: Element[*]
The Elements owned by this element. This is a derived union.
• / owner: Element [0..1]
The Element that owns this element. This is a derived union.
7.3.33 NamedElement (from Kernel, Dependencies)
[..]
Generalizations
• “Element (from Kernel)” on page 64
[..]
Attributes
• name: String [0..1]
The name of the NamedElement.
• / qualifiedName: String [0..1]
A name that allows the NamedElement to be identified within a hierarchy of nested Namespaces. It is constructed
from the names of the containing namespaces starting
[..]
[2] When there is a name, and all of the containing namespaces have a name, the qualified name is constructed from the
names of the containing namespaces.
(self.name->notEmpty() and self.allNamespaces()->select(ns | ns.name->isEmpty())->isEmpty()) implies
self.qualifiedName = self.allNamespaces()->iterate( ns : Namespace; result: String = self.name |
ns.name->union(self.separator())->union(result))
--
So in everyday-geek-speak:
* The element class needs a reference to an object of type element (the owner). I'm not really sure how to solve this (DVR's?). I can get this not breaking the arrow by using a parent class of element (ElementParent.lvclass) and using this as part of the private data.
* If I now try to make the qualified name, I need
a) to cast the Owner to the Element child class (ok)
b) to recurse through the GetQualifiedName method. (Here I get errors thrown).
How would you code up a design like this?
Felix