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

Datatype parsing support and access for portico #209

Closed michaelrfraser closed 6 years ago

michaelrfraser commented 6 years ago

This PR adds datatype parsing and referencing support to portico.

Extended Rti1516eDtxAmbassador methods to query datatypes are:

public IDatatype getAttributeDatatype( ObjectClassHandle whichClass, AttributeHandle theHandle )
        throws AttributeNotDefined,
               InvalidAttributeHandle,
               InvalidObjectClassHandle,
               FederateNotExecutionMember,
               NotConnected,
               RTIinternalError

public IDatatype getParameterDatatype( InteractionClassHandle whichClass, 
                                   ParameterHandle theHandle )
        throws InteractionParameterNotDefined,
               InvalidParameterHandle,
               InvalidInteractionClassHandle,
               FederateNotExecutionMember,
               NotConnected,
               RTIinternalError

Access to these methods is through an RtiAmbassador created by the "portico-dtx" RtiFactory. In code, creation and access would look as such:

RtiFactory factory = RtiFactoryFactory.getRtiFactory( "portico-dtx" );
Rti1516eDtxAmbassador dtxRtiAmb = (Rti1516eDtxAmbassador)factory.getRtiAmbassador();

//  ... Create/Join federation execution etc ...

IDatatype attributeType = dtxAmbassador.getAttributeDatatype( someOCHandle, someACHandle );
IDatatype parameterType = dtxAmbassador.getParameterDatatype( someICHandle, somePCHandle );

I have also added a suite of unit tests to test the parsing and linking of datatypes, and have tested the parser against all test reference FOMs (RPR, Restaurant, Standard MIM etc).

timpokorny commented 6 years ago

Dammit. Changed branch name to match local convention but that has closed the PR. Bringing it back.

timpokorny commented 6 years ago

Base PR completed with some minor changes:

Main change was in the way that the extension is exposed. I have resurrected the old JLC naming convention of RTIambassadorEx and extended the default namespace (ohhhh!) so avoid having to case down to some special internal implementation. Will expose all custom extension methods here as an easy entry point. Made an impl side class with the extension methods and updated so that we only ever create instances of it. As such, we're only ever returning one implementation ever and it's entirely up to end-user to choose which view they want of it.

Also added a getFOM() method to the RTIambassadorEx so that users can access the ObjectModel directly to avoid any chicken-and-egg situations when trying to extract data types for an unknown object model.

Only open question is whether we should also expose the FOM parser as a standalone thing as well. Can leave that for a separate task.