As described in the section about the physical design, QM™ provides special file items that represent files to be generated on disk. The file items can only exist inside a directory item, which determines the location of the file relative to the QM Model File or the External Package File, for files nested inside External Packages.
Normally, the file items are just "templates" for the files to be created on disk. Such file-templates are called internal files and can be edited in the MDI windows at the center of the QM user interface, which work exactly like any other modern code editor.
You can insert any code (or text) into the file-templates, such as #include
directives, declarations, definitions, comments, and anything else that you would put into hand-crafted code. All this code will then be literally copied over to the files generated on disk. But, the twist here is that you can also direct QM to generate specific parts of the code based on the model items of your choosing, with the granularity ranging from packages and classes, down to specific state machines, states, attributes, and operations.
You achieve this by inserting the special Code-Generation Directives into your file-templates. For example, you can direct QM to generate a class declaration in one place of a file on disk, a class definition in another place, and so on.
QM also supports External Files, which can be edited outside QM tool with any editor you like. Such External Files combine user-code with the generated-code and possibly Code-Generation Directives. This merging of a file-template with generated-code is achieved by clearly delimiting the generated-sections with special comments. Such External Files can be edited inside any editor/IDE of choice and are not editable inside QM. The following listing shows an example of an External File on disk (the comments after the listing explain the interesting lines of code):
1..30
Top-level file comment generated by QM.
NOTE: This code (between the $file${..} vvvvvv
and $endhead${..} ^^^^^^^
should NOT be edited manually.
21..34
user-code (editable)
35
code-generation directive (editable)
37..41
user-code (editable)
43..48
QP version requirement comment generated by QM.
NOTE: This code (between the $skip${..} vvvvvv
and $endskip${..} ^^^^^^^
should NOT be edited manually.
50..65
code generated by QM by expanding the directive $define ${SMs::Calc}
NOTE: This code (between the $define${..} vvvvv
and $enddef${..} ^^^^^^^^
should NOT be edited manually.
"$...vvv"
and "$end...^^^"
should NOT be edited, because they will be re-generated and any edits in these sections would be lost.The file items can only exist inside a directory item, which determines the location of the file relative to the QM Model File. Therefore, to add a new file item, you first need to select the directory item in the Model Explorer. Then right-click on this directory item and select the "Add File" in the popup menu, as shown below:
The following picture shows the Property Sheet of a File Item (see Property Editor):
The most important property of a file item is its name. QM™ automatically recognizes several file types based on the file name extension and applies a special icon for the recognized files. The following table shows the list of recognized file types and icons:
File Name Extension | File Type | File Icon |
---|---|---|
.h | C/C++ header file | |
.hpp | C++ header file | |
.c | C implementation file | |
.cpp | C++ implementation file | |
.cxx | C++ implementation file | |
.cc | C++ implementation file | |
.ino | Arduino sketch | |
.py | Python script | |
.mak | make file | |
makefile | make file | |
Makefile | make file |
The encoding drop-box property of the file item allows you to select one of the few dozens of available character encodings↑ for your file. This option might be interesting if you use special characters outside the basic ASCII character set. (NOTE: the default setting corresponds to the encoder selected in your operating system.)
The "external" check box designates a file as an External File that is not managed by QM, but still participates in the code generation. Such "external" files can be edited with an editor/IDE of choice.
QM™ applies consistently the Unix end-of-line convention↑ (single LF octet at the end of line) to all files saved on disk, regardless of the host operating system. This is done intentionally to generate identical code across diverse hosts, which might be used by various team members potentially using different operating systems.