The QM™ code generation process consists of replacing the code-generation directives in the file templates in the model with the corresponding pieces of auto-generated code in the files generated on disk. All other code fragments surrounding the code-generation directives in the file-templates are simply copied to the files on disk. The picture below illustrates the process:
To work effectively with the code-generation directives in QM™, you need to understand the difference between declarations and definitions in C or C++.
A declaration introduces a name and describes its type, be it a type name (struct/class/typedef), object (variable), or a function. A declaration is what the C or C++ compiler needs to accept references to that name. These are declarations:
extern
only for declarations of variables.A definition actually instantiates/implements the symbol. It's what the linker needs in order to link references to those entities. These are definitions corresponding to the above declarations:
The general syntax of the code-generating directives in the QM file templates is:
$<directive>
can be followed by zero or more spaces before the ${<model-item>}
specification.where $<directive>
is one of:
$declare ${<model-item>}
)$declare1 ${<model-item>}
)$define ${<model-item>}
)$define1 ${<model-item>}
)and <model-item>
denotes a Fully-Qualified Name of the model item to expand.
Ship
residing inside the package AOs
will be specified inside a code-generating directive as AOs::Ship
.$<directive>(<model-item>)
The fully-qualified item names can be, of course, typed by hand in the QM file templates. However, to avoid errors, the Model Explorer allows you to drag-n-drop a model item onto a file-template to create a fully-qualified item name, as illustrated in the animation below: