openlvc / portico

Portico is an open source, cross-platform, fully supported HLA RTI implementation. Designed with modularity and flexibility in mind, Portico is a production-grade RTI for the Simulation and Training Community, so come say hi!
http://www.porticoproject.org
151 stars 81 forks source link

RPRv2 FOM modules fail to parse with new datatype system #256

Closed michaelrfraser closed 6 years ago

michaelrfraser commented 6 years ago

Problem Statement

Before we introduced datatype parsing, the FOM parse and merge process followed the following sequence:

For each FOM module
    Parse individual FOM module into an ObjectModel
Merge ObjectModels into combined ObjectModel
Inject Standard MIM into combined ObjectModel

As part of the NIST work we introduced datatype parsing to the FOM parser. Datatypes may reference other types in their declaration (E.g. a FixedRecordDatatype declares fields, each which has their own type.

As there is no garuantee that these dependent datatypes have been declared in the xml before the containing type is declared, we introduced a linking system, whereby containing types are constructed with placeholders for their dependent types. Once the FOM is parsed, these placeholders are resolved to their concrete IDatatype in memory.

As a result the FOM parsing process became:

For each FOM module
    Parse individual FOM module into an ObjectModel
    Link all datatype placeholders with their concrete types
Merge ObjectModels into combined ObjectModel
Inject Standard MIM into combined ObjectModel

When we developed the datatype parsing system, we worked under the assumption that all FOM modules were standalone in their own right - e.g. the datatypes has declarations for all datatypes that are referenced in the module.

However in the modular RPR FOM this is not the case. For example:

As such, the module RPR-Enumerations_v2.0.xml will fail to parse as the linking step will not be able to find the definition of RPRunsignedInteger16BE.

This problem also manifests when assigning datatypes to Attribute and Parameter metadata instances. In the RPR FOM the attribute/parameter datatypes may not have been declared in the same file.

What needs to happen

If the RPRv2 modular FOM is a reflection of reality, then we need to defer when the linking phase occurs until after all FOMs have been parsed. For example:

For each FOM module
    Parse individual FOM module into an ObjectModel
Merge ObjectModels into combined ObjectModel
Inject Standard MIM into combined ObjectModel
Link all datatype placeholders in the combined ObjectModel with their concrete types

Under the previous model, linking was only required for datatypes as we could be certain that all datatypes were in place when we came to process attributes and parameters. However now as there is no garuntee that all datatypes are available at parsing time, we must defer link attribute and parameter datatypes also.

michaelrfraser commented 6 years ago

Note: RPR v2 FOM modules can be downloaded from https://www.sisostds.org/DigitalLibrary.aspx?Command=Core_Download&EntryId=43284

michaelrfraser commented 6 years ago

PR submitted at https://github.com/openlvc/portico/pull/257

michaelrfraser commented 6 years ago

Merged into master