Tigerstripe M0 Plugin Tutorial
< To: Tigerstripe_Tutorials
Using "standard" generators, Tigerstripe allows you to create output based on the classes that are in your model. In some areas this is known as an "M1" model.
An "M0" model is a set of instances, and in Tigerstripe these are captured in a instance Diagram. By writing an "M0 generatopr", you can create output files based on the content of instance diagrams.
M1 vs M0 generator
The general process for creating M0 generators is exactly the same as for M1 generators. You specify properties and rules as beofre, and the deploy phase is exactly the same. The only major differences are :
Triggering a rule
Once deployed, an M0 generator needs to be enabled in the "Generator settings" tab of the Tigerstripe descriptor editor for the project where your instance diagram lives. Here you specify the property values required by your plugin.
Once enabled, open ayour instance diagram, right click and select the "Generate.." option. This pops up a dialog giving you a couple of options, hit Generater, and the lougin will run over the optons you have chosen (typically "This diagram only". The outout should appear in teh tigerstripe.gen folder as per a standard plugin.
In an instance generator rule context, there are a few additional entries that are of interest(the same basic "class based" collections are still populated). There are 3 new collections of interest, idientified by the following keys :
- artifactInstances - a superset of the above two collections.
The contents of these colections are (at this stage) internal representations of instances, and there is a very poor interface. In a template rule, you can use the access methods listed below, but in a Runnable rule, you will almost certainly end up using java reflection to get access to the instance properties
- $instance.Artifact -> returns the Artifact Class of which this is an instance
- $instance.Variables -> returns a set of Variables that contain any values you have set against this instance - use $variable.name, $ variable.type to get the details, and $variable.value to get the set of values this will need to be further split to get the individual values.