VR-Link JAVA API Documentation
 All Classes Namespaces Files Functions Variables Enumerator Pages
7.4 - Using the Code Generator

Table of Contents

This section explains how to load a FOM definition file and generate class and interaction code to support it.

7.4.1 Loading a FOM Definition File

You can load FOM definition files in the XML and OMT formats.

To load a FOM definition file:

  1. Choose File -> Import FOM. The Open File dialog box opens. You can select XML files or OMT files. If you are using HLA Evolved and you need to specify FOM modules, use Import FOM multiple times. If there are any merge errors, they will appear in the footer of the window.
  2. Select the file to open.
  3. Click Open.

7.4.2 Selecting the Objects and Interactions to Generate

The objects and interactions in the FOM definition file are displayed as an expandable tree view (as illustrated below).

To select the objects or interactions that you want to generate:

  1. Select the objects and interactions using one of the following methods:

    • Click the list item you want to select.
    • Shift-click to select a series of contiguous items.
    • Ctrl-click to select multiple non-contiguous items.
    • To select all items, choose Edit -> Select All.

  2. Click the right-pointing arrow. The selected objects are displayed in the Objects/Interactions to Generate window.

    vrlinkcodegenerator.png
    Code Generator with Definition File Loaded
  3. When you add an object or interaction to the right pane, all parent objects or interactions are also added to the right pane, since the parent classes must be generated to support the children. No subordinates are moved. Therefore, if, for example, you want to generate code for the objects in the Objects.BaseEntity.PhysicalEntity.Platform category, you cannot just select Platform. You must select all the objects listed under Platform.
  4. The ObjectRoot and InteractionRoot nodes are used to separate objects and interactions in the display. No code is generated for ObjectRoot or InteractionRoot.

7.4.3 Removing Classes from the Objects to Generate List

When you remove a parent from the right pane, all children are removed.

To remove a class from the Objects/Interactions to Generate list:

  1. Select the class in the list.
  2. Click the left-pointing arrow.

7.4.4 Customizing Encoders and Decoders

The Code Generator lets you customize the encoders and decoders for object attributes and interaction parameters before you generate the code.

To customize an object or interaction class's encoders and decoders:

  1. In the Objects/Interactions to Generate pane, double-click the class whose encoders and decoders you want to customize (or right-click and select Customize). The Customize Encoders and Decoders window opens. It lists the attributes for the object or interaction.

  2. In the list of attributes, select the one you want to edit. The default encoder and decoder code is displayed on the Encoding and Decoding tabs.

    encodingtab.png
    Customize Encoders and Decoders Window
  3. Select the Encoding tab.

  4. Edit the function body as desired. (Only the function body is editable; the header should never change.)

  5. Select the Decoding tab.

  6. Edit the function body as desired.

  7. Click Save Changes.
Note
If you edit an encoder, you should almost always make corresponding changes to the decoder (and vice versa). There may be rare cases where you would not make matching changes, but this is not the normal or expected practice.
When you edit an attribute, an asterisk (*) is added to its name to show that it has changed. The asterisk is removed when you save the changes.
When you save an edited attribute, it is highlighted in green. This lets you know that it no longer uses the default code.

7.4.5 Configuring Code Generation Preferences

You can set the following preferences in the ./data/config/codeGenConfig.xml configuration file, the GUI, or both:

To configure code generation preferences:

  1. Choose Configuration -> Preferences. The Preferences dialog box opens.

    codegenprefs.png
    Preferences Dialog Box
  2. To specify a namespace, select Use Namespace and type a name for the namespace.
  3. To specify any of the other options, select the relevant check box.
  4. Click OK.

7.4.6 Choosing an Output Directory

You must tell the code generator where to write its output. If you do not specify an output directory using this procedure, the first time you generate code you are prompted for an output directory. Thereafter, the code generator continues to use that output directory until you tell it to use a different one.

To specify an output directory:

  1. Choose Configuration -> Choose Output Directory. A selection window opens.
  2. Select the output directory.
  3. Click Select Folder.

7.4.7 Generating Objects and Interactions

To generate the code, choose Build -> Generate, or click the Generate button.

[<< Code Generator Projects] [Home] [Top of Page] [The Generated Code >>]


Document ID: Generated on Thu Sep 19 02:12:35 EDT 2024 from SVN revision 269601
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)