|
|
|
|
|
Re: Obtain all subclasses of a class. [message #699739 is a reply to message #698946] |
Fri, 22 July 2011 08:22 |
Radu Babota Messages: 6 Registered: June 2011 |
Junior Member |
|
|
Hi Ed,
Indeed what I was looking for is to get all classes in a model.
However I have researched ways to do that (like using allInstances(), allContents(), ...) but could not reach the goal.
Here are some links
http://www.eclipse.org/forums/index.php/m/697629/
http://www.eclipse.org/forums/index.php/mv/msg/220102/695762/
http://www.eclipse.org/forums/index.php/mv/tree/21886/
However through trial and error I am able to do the task with following OCL sequence.
Probably it is not the best way but it works. Please comment if there are better ways.
(works for package and subpackages universe given a class reference pClass)
pClass.ePackage.eSubpackages->append(pClass.ePackage).eClassifiers->select(oclIsTypeOf(ecore::EClass))->select(ec:ecore::EClassifier| pClass.isSuperTypeOf(ec.oclAsType(ecore::EClass)))->asOrderedSet()
Regards,
Radu
On 20/07/2011 16:08, Ed Merks wrote:
> Radu,
>
> Comments below.
>
> On 20/07/2011 6:23 AM, Radu Babota wrote:
>>
>> Having a referenced class in an ecore model, I am trying to get all the related classes.
>> Getting superclasses can be done with self.eClass().eAllSuperTypes
>>
>> However I am lost in finding a way to reach the subclasses (or the collection of all classes from which I can select then the subclasses based on supertype relation)
> That's just the point. There is no way to reach all the subclasses in general, for the same reason that in Java you can't find all subclass. I.e., it's an unbounded thing. So you'll need to find a way to reach all the classes that interest you (i.e., determine some arbitrary set of bounds) and from that filter out the ones that aren't subtypes.
>>
>> Any hint would be appreciated.
>> Radu.
|
|
|
Re: Obtain all subclasses of a class. [message #699878 is a reply to message #699739] |
Fri, 22 July 2011 14:14 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Radu,
I suppose that's all the ones in a given class's contain package's
subpackages. I'm not sure it considers the recursive subpackages
(subpackages of subpackages) or the classifiers in the same package. It
certainly won't consider classes in packages in a different containment
tree.
On 22/07/2011 1:25 AM, Radu Babota wrote:
>
> Hi Ed,
>
> Indeed what I was looking for is to get all classes in a model.
> However I have researched ways to do that (like using allInstances(),
> allContents(), ...) but could not reach the goal.
>
> Here are some links
>
> http://www.eclipse.org/forums/index.php/m/697629/
> http://www.eclipse.org/forums/index.php/mv/msg/220102/695762/
> http://www.eclipse.org/forums/index.php/mv/tree/21886/
>
> However through trial and error I am able to do the task with
> following OCL sequence.
> Probably it is not the best way but it works. Please comment if there
> are better ways.
> (works for package and subpackages universe given a class reference
> pClass)
>
> pClass.ePackage.eSubpackages->append(pClass.ePackage).eClassifiers->select(oclIsTypeOf(ecore::EClass))->select(ec:ecore::EClassifier|
> pClass.isSuperTypeOf(ec.oclAsType(ecore::EClass)))->asOrderedSet()
>
>
> Regards,
> Radu
>
> On 20/07/2011 16:08, Ed Merks wrote:
>> Radu,
>>
>> Comments below.
>>
>> On 20/07/2011 6:23 AM, Radu Babota wrote:
>>>
>>> Having a referenced class in an ecore model, I am trying to get all
>>> the related classes.
>>> Getting superclasses can be done with self.eClass().eAllSuperTypes
>>>
>>> However I am lost in finding a way to reach the subclasses (or the
>>> collection of all classes from which I can select then the
>>> subclasses based on supertype relation)
>> That's just the point. There is no way to reach all the subclasses in
>> general, for the same reason that in Java you can't find all
>> subclass. I.e., it's an unbounded thing. So you'll need to find a way
>> to reach all the classes that interest you (i.e., determine some
>> arbitrary set of bounds) and from that filter out the ones that
>> aren't subtypes.
>>>
>>> Any hint would be appreciated.
>>> Radu.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03439 seconds