Previous Table of Contents Next


5.5 Expressions Metamodel

   The Expressions package depends on the following packages:

   org.omg::CWM::ObjectModel::Core

   The CWM Expressions metamodel provides basic support for the definition of expression trees within the CWM. The intent of the Expressions metamodel is to provide a place for other CWM packages (such as Transformation) and CWM compliant tools to record shared expressions in a common form that can be used for interchange and lineage tracking.

   ModelElement

   (fromCore)


   


ExpressionNode

   


argument

   type

   



{ordered}

   




   



ElementNode

   


FeatureNode


   






   Figure 5-7 Expressions metamodel

   The expression concept in the CWM Foundation takes a functional view of expression trees, resulting in the ability of relatively few expression types to represent a broad range of expressions. Every function or traditional mathematical operator that appears in an expression hierarchy is represented as a FeatureNode. For example, the arithmetic plus operation “a + b? can be thought of as the function “sum(a, b).? The semantics of a particular function or operation are left to specific tool implementations and are not captured by the CWM.

   The hierarchical nature of the CWM’s representation of expressions is achieved by the recursive nature of the OperationArgument association. This association allows the sub-hierarchies within an expression to be treated as actual parameters of their parent nodes.

   By way of example, the following instance diagram shows one representation of a CWM expression tree for the well-known Einstein equation E = mc2. To better understand how the equation is mapped into the expression tree, the formula can be rewritten in a functional notation as

   Assign(E, Multiply(m, Power(c, 2)))

   This functional form of the equation is then mapped into a set of expression tree instances as shown in Figure 5-8.

   Alternatively, if sharing and lineage tracking of elements within the expression are not required, the expression could be stored using an Attribute of type ExpressionNode by assigning the string “E = mc2? as the Attribute’s expression::body value. For flexibility, use of the expression attribute within an expression hierarchy is allowed, but the precise semantics of such situations are not defined by CWM.

   NodeFeature Assign :

    : FeatureNode

   Operation


   Operation


   base : : FeatureNode NodeFeature c :Parameter

   Attribute

   BehavioralFeatureParameter


OperationArgument exponent : Parameter

   Figure 5-8 A CWM expression tree for the formula E = mc2