The Values Package

          
OCL is an object language. A value can be either an object, which can change its state in time, or a data type, which can not change its state. The model in Figure 15  shows the values that form the semantic domain of an OCL expression. The basic type is the Value, which includes both objects and data values. There is a special subtype of Value called UndefinedValue, which is used to represent the undefined value for any Type in the abstract syntax.



Figure 16  shows a number of special data values, the collection and tuple values. To distinguish between  instances of the Set, Bag, and Sequence types defined in the standard library, and the classes in this package that represent instances in the semantic domain, the names SetTypeValue, BagTypeValue, and sequenceTypeValue are used, instead of  SetValue, BagValue, and SequenceValue.

The value resulting from an ocl message expression is shown in Figure 17. It links an ocl message value to the snapshot of an object.

Definitions of concepts for the Values package.

The section lists the definitions of concepts in the Values package in alphabetical order.

BagTypeValue

A bag type value is a collection value which is a multiset of values, where each value may occur multiple times in the bag. The values are unordered. In the metamodel, this list of values is shown as an association from CollectionValue (a generalization of BagTypeValue) to Element.

CollectionValue

A collection value is a list of values. In the metamodel, this list of values is shown as an association from  CollectionValue to Element.

Associations


DomainElement

A domain element is an element of the domain of OCL expressions. It is the generic superclass of all classes defined in this chapter, including Value and OclExpEval. It serves the same purpose as ModelElement in the UML meta model.


Element

An element represents a single component of a tuple value, or collection value. An element has an index number, and a value. The purpose of the index number is to uniquely identify the position of each element within the enclosing value, when it is used as an element of a SequenceValue.

LocalSnapshot

A local snapshot is a domain element that holds for one point in time the subvalues of an object value. It is always part  of an ordered list of local snapshots of an object value, which is represented in the metamodel by the associations pred, succ, and history. An object value may also hold a sequence of OclMessageValues, which the object value has sent, and a sequence of OclMessageValues, which the object value has received. Both sequences can change in time, therefore they
are included in a local snapshot. This is represented by the associations in the metamodel called inputQ, and outputQ.

A local snapshot has two attributes, isPost and isPre, that indicate whether this snapshot is taken at postcondition or precondition time of an operation execution. Within the history of an object value it is always possible to find the local snapshot at precondition time that corresponds with a given snapshot at postcondition time. The association pre (shown in Figure 17 ) is redundant, but added for convenience.

Associations
  • bindings
The set of name value bindings that hold the changes in time of the subvalues of the associated object value.
  • outputQ
The sequence of OclMessageValues that the associated ObjectValue at the certain point in time has sent, and are not yet put through to their targets.
  • inputQ
The sequence of OclMessageValues that the associated ObjectValue at the certain point in time has received, but not yet dealt with.
  • pred
The predecessor of this local snapshot in the history of an object value.
  • succ
The successor of this local snapshot in the history of an object value.
  • pre
If this snapshot is a snapshot at postcondition time of a certain operation execution, then pre is the associated snapshot at precondition time of the same operation in the history of an object value.

NameValueBinding

A name value binding is a domain element that binds a name to a value.

ObjectValue

An object value is a value that has an identity, and a certain structure of subvalues. Its subvalues may change over time, although the structure remains the same. Its identity may not change over time. In the metamodel, the structure is shown  as a set of NameValueBindings. Because these bindings may change over time, the ObjectValue is associated with a sequence of LocalSnapshots, that hold a set of NameValueBindings at a certain point in time.

Associations
OclMessageValue

An ocl message value is a value that has as target and as source an object value. An ocl message value has a number of attributes. The name attribute corresponds to the name of the operation called, or signal sent. The isSyncOperation, isAsyncOperation, and isSignal attributes indicate respectively whether the message corresponds to a synchronous operation, an asynchrounous operation, or a signal.

Associations

  • arguments
A sequence of name value bindings that hold the arguments of the message from the source to the target.
  • source
The object value that has sent this signal.
  • target
The object value for which this signal has been intended.
  • returnMessage
The ocl message value that holds the values of the result and out parameters of a synchronous operation call in its arguments. Is only present if this message represents a synchronous operation call.

OclVoidValue

An undefined value is a value that represents void or undefined for any type.

PrimitiveValue

A primitive value is a predefined static value, without any relevant substructure (i.e., it has no parts).

SequenceTypeValue

A sequence type value is a collection value which is a list of values where each value may occur multiple times in the sequence. The values are ordered by their position in the sequence. In the metamodel, this list of values is shown as an association from CollectionValue (a generalization of SequenceTypeValue) to Element. The position of an element in the list is represented by the attribute indexNr of Element.

SetTypeValue

A set type value is a collection value which is a set of elements where each distinct element occurs only once in the set. The elements are not ordered. In the metamodel, this list of values is shown as an association from CollectionValue (a generalization of SetTypeValue) to Element.

StaticValue

A static value is a value that will not change over time1.


TupleValue

A tuple value (also known as record value) combines values of different types into a single aggregate value. The components of a tuple value are described by tuple parts each having a name and a value. In the metamodel, this is shown as an association from TupleValue to NameValueBinding.

Associations
Value

A part of the semantic domain.

Well-formedness rules for the Values Package

BagTypeValue

No additional well-formedness rules.

CollectionValue

No additional well-formedness rules.

DomainElement

No additional well-formedness rules.

Element

No additional well-formedness rules.

EnumValue

No additional well-formedness rules.

LocalSnapshot

[1]  Only one of the attributes isPost and isPre may be true at the same time.

    context LocalSnapshot
    inv: isPost implies isPre = false
    inv: ispre implies isPost = false

[2] Only if a snapshot is a postcondition snapshot it has an associated precondition snapshot.

    context LocalSnapshot
    inv: isPost implies pre->size() = 1
    inv: not isPost implies pre->size() = 0
    inv: self.pre->size() = 1 implies self.pre.isPre = true

NameValueBinding

No additional well-formedness rules.

ObjectValue

[1] The history of an object is ordered. The first element does not have a predecessor, the last does not have a successor.

    context ObjectValue
    inv: history->oclIsTypeOf( Sequence(LocalSnapShot) )
    inv: history->last().succ->size = 0
    inv: history->first().pre->size = 0

OclMessageValue

[1] Only one of the attributes isSyncOperation, isAsyncOperation, and isSignal may be true at the same time.

    context OclMessageValue
    inv: isSyncOperation implies isAsyncOperation = false and isSignal = false
    inv: isAsyncOperation implies isSyncOperation = false and isSignal = false
    inv: isSignal implies isSyncOperation = false and isAsyncOperation = false

[2] The return message is only present if, and only if the ocl message value is a synchronous operation call.

    context OclMessageValue
    inv: isSyncOperation implies returnMessage->size() = 1
    inv: not isSyncOperation implies returnMessage->size() = 0

OclVoidValue

No additional well-formedness rules.

PrimitiveValue

No additional well-formedness rules.

SequenceTypeValue

[1] All elements belonging to a sequence value have unique index numbers.

    self.element->isUnique(e : Element | e.indexNr)

SetTypeValue

[1] All elements belonging to a set value have unique values.

    self.element->isUnique(e : Element | e.value)

StaticValue

No additional well-formedness rules.

TupleValue

[1] All elements belonging to a tuple value have unique names.

self.elements->isUnique(e : Element | e.name)

Value

No additional well-formedness rules.

Additional operations for the Values Package

LocalSnapshot

[1] The operation allPredecessors returns the collection of all snapshots before a snapshot, allSuccessors returns the collection of all snapshots after a snapshot.

    context LocalSnapshot
    def: let allPredecessors() : Sequence(LocalSnapshot) =
         if pred->notEmpty then
            pred->union(pred.allPredecessors())
        else
            Sequence {}
        endif
    def: let allSuccessors() : Sequence(LocalSnapshot) =
        if succ->notEmpty then
            succ->union(succ.allSuccessors())
        else
            Sequence {}
        endif

ObjectValue

[1] The operation getCurrentValueOf results in the value that is bound to the name parameter in the latest snapshot in the history of an object value. Note that the value may be the UndefinedValue.

    context ObjectValue::getCurrentValueOf(n: String): Value
    pre: -- none
    post: result = history->last().bindings->any(name = n).value

[2] The operation outgoingMessages results in the sequence of OclMessageValues that have been in the output queue of  the object between the last postcondition snapshot and its associated precondition snapshot.

    context OclExpEval::outgoingMessages() : Sequence( OclMessageValue )
    pre: -- none
    post:
    let end: LocalSnapshot =
            history->last().allPredecessors()->select( isPost = true )->first() in
    let start: LocalSnapshot = end.pre in
    let inBetween: Sequence( LocalSnapshot ) =
            start.allSuccessors()->excluding( end.allSuccessors())->including( start ) in
                result = inBetween.outputQ->iterate (
                    -- creating a sequence with all elements present once
                    m : oclMessageValue;
                    res: Sequence( OclMessageValue ) = Sequence{}
                    |           if not res->includes( m )
                                then res->append( m )
                                else res
                                endif )
    endif

TupleValue

[1] The operation getValueOf results in the value that is bound to the name parameter in the tuple value.

    context TupleValue::getValueOf(n: String): Value
  pre: -- none
  post: result = elements->any(name = n).value

 Overview of the Values package


Figure 18  shows an overview of the inheritance relationships between the classes in the Values package.





1. As StaticValue is the counterpart of the DataType concept in the abstract syntax, the name DataValue would be preferable. Because this name is used in the UML 1.4 specification to denote a model of a data value, the name StaticValue is used here.