Chapter 10 PowerDesigner Public Metamodel


Using the metamodel with the Generation Template Language

The GTL uses templates to generate files. A template is a piece of code defined on a given PowerDesigner metaclass and the metaclasses that inherit from this class. It can be used in different contexts for text and potentially code generation.

These templates can be considered as metamodel extensions as they are defined on metamodel classes, they are special kinds of metamodel attributes. The user may define as many templates as he wants for any given metaclass using the following syntax:

<metamodel-classname> / <template-name>

Inheritance

Templates are inherited by all the descendants of the metaclass they are defined for. This mechanism is useful for sharing template code between metaclasses having a common ancestor. For example, if you define a template for an abstract class like BaseObjects, all the classes linked via generalization links to this class inherit from this template.

Collections

The GTL uses macros like foreach_item, for iterating on object collections. The template specified inside the block is translated over all the objects contained in the specified collection. The metamodel provides useful information about the collections of the metaclass on which you define a template containing an iteration macro.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.