[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, Ed,

Yes, that's a good way to do the uniqueness condition, but there is still the covering condition to consider:  the other requirement was to check that all concrete subclasses of AbstractModel are instantiated in the containedModel collection.

Cheers,

Christian


On Fri, 2009-09-11 at 22:50 +0100, Ed Willink wrote:
Hi Gilbert, Christain

I think the double argument forAll idiom should suit

context AbstractModel
inv: containedModel->forAll(a, b |
	a <> b implies a.oclType() <> b.oclType())

	Regards

		Ed Willink

Christian W. Damus wrote:
> Hi, Gilbert,
> 
> How about something like this:
> 
>   context CompositionModel
>   inv: let epkg : ecore::EPackage = self.eClass().ePackage,
>             supertype : ecore::EClass = 
> epkg.getEClassifier("AbstractModel"),
>             concreteTypes : Set(ecore::EClass) = 
> epkg.eClassifiers->select(c |
>                     not c.isAbstract and 
> supertype.isSuperClassOf(c))->asSet()
>         in
>     containedModel->unique(eClass()) and
>     containedModel.eClass()->asSet() = concreteTypes
> 
> The idea is to find all of the concrete subclasses of AbstractModel and 
> then check that the elements in the containedModel collection are all of 
> different types and that all of the concrete types are instantiated.  
> Thus, unique instances of every type.
> 
> HTH,
> 
> Christian
> 
> 
> On Fri, 2009-09-11 at 17:05 +0200, Gilbert Mirenque wrote:
>> And how could I realize it that generically all sub types of
>> AbstractModel will be checked? I can't do the test for every type
>> because it can be that the metamodel will be extended.