Union

From PHENOM Portal Knowledgebase
Revision as of 11:27, 6 February 2024 by Dmitry (talk | contribs) (Created page with "alt=The toggle to switch a view to a union type on the view element's detail page.|thumb|564x564px|The toggle to switch a view to a union type on the view element's detail page. The FACE 3 standard introduced the ability to document union templates – in Phenom, these are represented by union views. Though interpreted as unions in IDL, the FACE standard dictates C struct and C++/Java class representations of these structures;...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The toggle to switch a view to a union type on the view element's detail page.
The toggle to switch a view to a union type on the view element's detail page.

The FACE 3 standard introduced the ability to document union templates – in Phenom, these are represented by union views. Though interpreted as unions in IDL, the FACE standard dictates C struct and C++/Java class representations of these structures; please refer to the FACE Technical Standard documents for details on implementing union type structures in code.

Creating a Union

Unions cannot be created independently, but rather existing Phenom view elements can be converted to be unions. On the view element's Details page, a toggle labeled 'Union' is used to change view element between a union and non-union structure.

Not all views can be changed to be a union type, and so the toggle may appear disabled for some view elements in a model. Which views may be transformed into unions is governed by FACE standard rules.

Non-Composite (Nesting) Views as Unions

For a non-composite view to be converted to a union, three FACE structural requirements must be fulfilled.

The private nesting of a union view within a top level view.

First: a union cannot be a “top level” type, but must rather be defined as a sub-type, nested inside the definition of another structure. In a FACE model, this will appear as a template structure that is not housed in its own template node, but is rather defined as a sub-structure in the specification of another template node. In Phenom, this is represented as a view that is referenced as the type of another view's field - this is what is referred to as "nested attribute". In this case, the field in question should also be marked as "Private", indicating that the nested view is defined in a scope internal to the view in which it is nested.

Selection of an enumeration-based view attribute as a union discriminant.

Second: to become a union, a view must have at least one attribute or field that references an enumeration as its platform type. In a FACE model, this enumerated field will be selected by the query related to the union template to serve as the discriminant over which the union is switched. In Phenom, when a user toggles a view to be a union, a drop-down appears next to the switch allowing the selection of the discriminant. This drop-down lists all of the current view's attributes the Platform Type property of which references a platform enumeration element.

The projected characteristic uniformity among view attributes required of union types.

Third: to be eligible for conversion to a union, all of the projections in the view must project the same element. In a FACE model, this is the same rule that applies to all non-composite templates. In Phenom, this requirement can be satisfied by ensuring that the first element of each attribute's projection path is the same for the selected view.