Object property |
Post Reply |
Author | |
Saivignesh
Contributor Joined: 01.May.2017 Location: Netherlands Points: 17 |
Post Options
Thanks(0)
Posted: 06.May.2017 at 16:26 |
I will explain my question with an example.
I have the UML class. The class object has operations and attributes (class be engine and attribute be engine capacity). I want to create a new object (say engine specs) and i want a property for engine specs where I want to choose engine capacity via engine class. That is first I must select the UML class (engine) and then it should show all the attributes inside the engine and I should choose engine capacity. Is it possible?
|
|
jpt
MetaCase Joined: 25.Mar.2008 Points: 239 |
Post Options
Thanks(0)
|
The usual pattern is that engine is the element of the metamodel (language definition) which is then instantiated while modeling (language use). When modeling an engine its properties (like capacity) can be specified. Depending on the metamodel you may have also additional engine capacity related constraints like it must be specified or it must be within a certain range etc.
An extended and more advanced approach is creating the modeling language while modeling with another modeling language. For example, you could have language to specify what kind of engine characteristics there can be (like capacity) and then another language to specify those engines and entering capacity etc. Here the former actually created the metamodel and extends the currently used metamodel. An example of this is Graphical GOPRR. I personally would not start with this as the first case but investigate first the planned use process of the language and create sample models with language users first. Finally, and if you want to stick with UML, you may naturally have check in UML Object Diagram that created objects include only those properties the class (defined in UML Class Diagram) the object refers to has defined. A MERL script would first navigate from Object to its Class (and its supertypes) and get data from its Attributes and then crosscheck that the Variables of the Object refer to the same attributes. |
|
Saivignesh
Contributor Joined: 01.May.2017 Location: Netherlands Points: 17 |
Post Options
Thanks(0)
|
Suppose if I have an attribute. How do I write a generator to find the class of the attribute?
|
|
jpt
MetaCase Joined: 25.Mar.2008 Points: 239 |
Post Options
Thanks(0)
|
This is then the 3rd option. As generator relies on the metamodel and since UML was already mentioned I'll follow it below. In Object Diagram of UML objects are specified. The Object has a property that refers to its Class. Accessing that Class for the given Object with MERL is ‘do :Classs {}’ and the check can be adjusted how it checks and reports the outcome. Below is one example:
CheckAttributes() _translators() local 'attTypes' write ' ' do :Class { do :Attributes { id%var ' ' } } close do :Variables { do :Attribute { if not @attTypes =~ id%var%wildsp then 'Error: ' :Value;1 ' is not based on class definition' newline endif } } Comparison could be made based on name (:Name in MERL) only, but with id it also checks other parts of the attribute definition such as datatype and visibility. Most accurate comparison would be when based on the same attribute definition and then comparison would be directly to oid (internal unique identifier). You can also extend the generator to collect to attribute types variable also the possible supertypes of the class with: do ~Spezialization~SuperClass.() {} etc. You can place the above generator to the symbol of Object and then check result as variables are given, or run it in live check generator so the checks are run for each modeling operation, or put it as own check generator that developer can run when needed. Often these checks are also called during code generation but here having instance objects that might not be the case – all depends on your metamodel and use case. Edited by jpt - 08.May.2017 at 13:27 |
|
Post Reply | |
Tweet |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |