[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.mdt.ocl] Re: How to check the types of containment?

Hi, Gilbert,

You can either wait for the MDT OCL release that the excellent new committer team is working on that will support OCL 2.1 spec with with the new oclType() operation:

  context CompositionModel
  inv: containedModel->unique(oclType())

(assuming your containment reference is named "containedModel") or, with the latest release, you can use set the "implicit root class" parser option to EObject and do this:

  context CompositionModel
  inv: containedModel->unique(eClass())

Either way, you are checking that the members of the collection are of unique classes.

HTH,

Christian

 
On Fri, 2009-09-11 at 12:55 +0200, Gilbert Mirenque wrote:
Hello,
imagine I have class defined (CompositionModel) in my meta model which
has a containment reference (1..*) to an abstract class (AbstractModel).
I have several concrete classes (ModelA, ModelB, ...) inheriting from
that abstract class. Now I want to write an ocl constraint for
CompositionModel expressing that every concrete class can only be
contained once in the CompositionModel class. How can I express this? I
have to count the contained types for every ModelA, ModelB, ... anyway.
Can you help me?

best regards,
Gilbert