Assign reference to an accessories data model in constructor

Hi!

I'm new to MPS and I'm totally stuck with quite a simple task.

I have a concept named DataModel which should reference a node of type TypeDefinition - and here I'm fine. But what I want now is to create  a pre-defined TypeDefinition (i.e. accessory model) and reference it in the DataModel's constructor so it is set by default, but the user may override it - and I've no idea how to do it.

Something like this:

typedef Standard Types

  • integer
  • number
  • boolean

datamodel MyModel uses Standard Types <-- I want to initialize it in the constructor.

5 comments
Comment actions Permalink

You must import the accessory model into the behavior model and then use node-ptr or better set ptr to get hold of the desired default TypeDefinition instance and set it as a target of the reference:

this.typeDefRef.set ptr(number);

Vaclav

 

0
Comment actions Permalink

Hi Vaclav,

Thanks for a prompt response. By "import the accessory model into the behavior model" - what does it mean? I've created the accessory model and defined my TypeDefinition there - shall I do something extra to make it available in the behavior? And also, how do I find it by name?

0
Comment actions Permalink

By import I mean pressing Control + M and typing the name of your accessory model. If you want to refer to nodes from another model, you have to import that other model into your current model. It is similar to how in order to use a Java class in Java code you have to import the containing package.

Vaclav

 

0
Comment actions Permalink

Thanks, Vaclav, it's clear now and works just fine. Just curios - after doing that I see no visual changes. Are these imports listed somewhere?

0
Comment actions Permalink

Yes, they are listed in "model properties" - right-click on a model in the Project View and select the bottom-most item.

In addition to model dependencies you will be able to manage imported languages.

Vaclav

 

0

Please sign in to leave a comment.