cancel
Showing results for 
Search instead for 
Did you mean: 

*Usage classes

Former Member
0 Kudos

Can someone please help us understand what are the *Usage objects in VC kits (core.gml:ScenarioUsage, etc....). How and where to use them?

Christopher

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

From the Visual Composition Language Spec - "The reuse aspect of a scenario is modeled with a usage concept".

While this sounds abstract and I am a little bit hazy of the concept of re-use in VC, for all practical purposes, the following may help -

Note that scenario, service are components, and component is an atomic entity for re-use.

Taking an example, you want to use Component1 in Component2 (expressing in another way, you want Component2 to be composed of Component1 , etc). The way this is modeled in VC, is that there exists a "usage" of Unit1 - Component1Usage in Component2. This usage has a reference to Component1 via its "target" attribute. It is not possible to directly embed Component1 in Component2 (in terms of model elements) because these are top-level entities.

The usage type of a component is defined by a metadata property - "usageElement"


Class Component inherit Unit;
 
metadata title = 'Component';
...
metadata usageElement = 'core.gml:ComponentUsage';
...

When you drag a Component1 into Component2, VC automatically creates a usage of Component1 in Component2, along with the Component1 diagram itself. Visually, if you consider Component1 to be a "child" of Component2 diagram, the box that you see in Component2 diagram, is a usage of Component1 . When you double-click the usage (a.k.a drill down), what you see now is the diagram of Component1 .

If you create Component1 , the above way, a different Component1 diagram is created everytime you DnD it into Component2. If you DnD Component1 into Component2 twice, two usages are created each pointing to different diagrams of Component1 .

There is also a limited support, AFAIK, of making two usages point to the same diagram. You can, with a combination of COPY and CREATE USAGE operations, create usages that point to the same diagram. But I think it is not yet mature.

Now, if you have a sub-class of Scenario for your own purposes, you usually do not need to define a usage unless you want to create "customizable" or usage-specific properties. VC automatically creates a usage - "ScenarioUsage" defined in core.gml:Scenario class for your scenario (If you do not define a usageElement metadata property, the property of base class is considered).

If you want usage-specific properties, create a sub-class of core.gml:ScenarioUsage and define

metadata usageElement = '<qualifies usage class name>'

in your scenario.

Now when you DnD your scenario in another diagram, the usage you have defined will be created in that diagram, and you will be able to see the properties of your usage in the editor (of course, you need to create the property editor as well).

Hope this helps.

Cheers,

Vinay

Former Member
0 Kudos

Thank you Vinay. That was a very elaborate explanation and clarified the concept very clearly. We are now able to use the Usage classes to control the editors.

Regards,

Christopher

Answers (0)