Chapter 9 Generation Reference Guide (GTL)


object macro

This macro returns a collection of objects based on the specified scope and condition. Object references are represented as OID; for example: E40D4254-DA4A-4FB6-AEF6-3E7B41A41AD1.

object = .object '(' <collection-scope:simple-template> [',' <filter>] ')'

Parameters

Parameter Type Description
<scope> <simple-template> returning either an object or a collection scope Collection over which we should iterate, the macro will return the first matching object in the collection
<filter> <condition> Filter condition

Example1:

The following macro returns the first attribute in the collection defined on the current classifier whose code starts with a letter comprised between a and e included.

.object(Attributes, (%.1:Code% >= a) and (%.1:Code% <= e))

Example 2:

Define template ::myPackage2 as follows:

.object(ActiveModel.Packages, %Name% == MyPackage2)

Define template OOM.Model::MyTemplate as follows:

.foreach_item(myPackage2.Classes)
%Code%
.next(\n)

In OOM.Model M = { OOM.Package MyPackage1, OOM.Package MyPackage2 { OOM.Class C1, OOM.Class C2} }Template OOM.Model::MyTemplate evaluates to in model M:

C1

C2

Example 3:

ILM.Publication::getConsolDataConnection

.object(Process.DataConnections, %AccessType% == "RO")

This template returns the first read-only data connection for the process associated with the current publication.

 


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