Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > Transformation Development Kit (TDK) > Customizing an ACS Code Generator DLL > Customizing a TDK code generation transformation patterns model - current TDK models > How TDK code generation transformation patterns models define code generation > Navigating around a TDK code generation transformation patterns model (TDK)
  
Navigating around a TDK code generation transformation patterns model (TDK)
This topic provides information to help you navigate around a TDK Code Generation Transformation Patterns model, that is, follow the generation process. To customize how code is generated, you will have to be able to work out which part of the TDK Code Generation Transformation Patterns model defines how the relevant code is generated.
This topic assumes that you have read the topics in the How TDK Code Generation Transformation Patterns models Define Code Generation section of the Help.
Which 4G generation classes start the generation process?
When you start ACS through the Launch ACS/TDK dialog, you select a root object, which can be the Model, a Package or a Class. The selected root object determines the entry point into the 4G Generation Classes.
The GenerateStart operation that resides in the Generator::Support package in the TDK Code Generation Transformation Patterns model has SDL Script similar to the following example in its Body property:
%for sysRootObject
%current.R_Gen ()
%endfor
The preceding example SDL script calls the 4G Generation Classes that are mapped to the type of the Root Object, that is, those 4G Generation Classes that are mapped to the Model, Package or Class meta class. Irrespective of which 4G Generation Class is used, in the preceding example the Gen rule is called (each 4G Generation Class would have to have a Rule named Gen). The Rule Text of the called Gen rule would then determine what happens next.
Which 4G generation classes are candidates for generating code?
To identify which 4G Generation Classes can be used to generate code for the root item, in the Generator::Structure package open the Mapping class diagram. The Mapping class diagram shows which 4G Generation Classes are mapped to each Meta Class. If only one 4G Generation Class is mapped to a Meta Class, that 4G Generation Class is used to generate code for Modeler items of that type and if multiple 4G Generation Classes are mapped to a Meta Class, each mapped 4G Generation Class is a candidate for generating code for Modeler items of that type.
How do I determine when each 4G generation class candidate is used?
To identify which 4G Generation Class is used for generating code under different conditions, in the Generator::Model2Text::Diagrams package open the Class Diagram that is appropriate to the Modeler item (Studio Metatypes package) or C# code element (C# Metatypes package) being generated.
* 
Code being generated for an Attribute, open the Studio Attribute class diagram.
The Class Diagrams in the Generator::Model2Text::Diagrams package provide the evaluation order for the 4G Generation Classes. Each 4G Generation Class is considered in order, with the When operation determining which 4G Generation Class is used to generate code - if the When operation returns 1, that 4G Generation Class is used to generate code and other 4G Generation Classes in the chain of responsibility are not considered. The Body property of a When operation specifies the criteria for using a 4G Generation Class, based on properties of the Modeler item that is generated.
When operations are defined On Class, the candidate Modeler item is passed by means of the O parameter.
* 
Aid customization of a TDK Code Generation Transformation Patterns model, the first 4G Generation Class in an evaluation order is typically an Attach Point 4G Generation Class. These 4G Generation Classes reside in the Generator::Model2Text::CustomizationAttachPoints package and they do not define any code generation.
How are other items processed
The Rule Text that is processed for a high-level item types, such as the Model or a Package, will inevitably process that item's child items. In Rule Text, child items are process through a Loop Construct that typically iterates over the items in a list that has been populated through an Operation.
In the following example, the Loop Construct calls an Operation named PublicAttributes, which returns a list of owned Public Attributes. The appropriate 4G Generation Classes associated with the Attribute meta class are run against each item in the list, because the type of each item in the list is Attribute. After all the Attributes in the list have been processed, control is returned to the point after the Loop Construct in the Rule Text.
{PublicAttributes.Gen}
How do I find a rule or operation that is called in rule text?
To find a called Rule or Operation, in the Model2Text::Diagrams::C# Metatypes package, open the Class Diagram that shows the 4G Generation Class that owns the calling Rule. Typically the called rule or Operation will appear on that Class Diagram, either on the same 4G Generation Class, or on an inherited 4G Generation Class or 4G Business Class.
If you perform a Usage report for a 4G Generation Class (right-click the Class, point to Report, and then click Usage), the Results pane will list diagrams that show the 4G Generation Class.