VR-Exchange 2.9 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
5 - The HLA Broker API

The HLA Broker API is in the libHlaBroker library.

It is built on the Broker API. The HLA Broker Library is the full implementation of the HLA broker. DtHlaBroker (hlaBroker.h) is the central class in libHlaBroker, it is a subclass of DtBroker that connects to an HLA exercise using a VR-Link DtExerciseConn. The DtHlaBroker instance also opens a connection to Qt to process the broker's GUI. This instance is created by DtHlaBrokerApp (hlaBrokerApp.h).

The DtHlaBroker is responsible for creating object and interaction translators, configuring the HLA connection through an DtHlaBrokerInitializer (hlaBrokerInitializer.h) instance, and giving each translator processor time by calling tick().

The DtHlaBroker instance manages DtTranslator (translator.h). There are two types of DtTranslator: DtInteractionTranslator (interactionTrans.h) and DtObjectTranslator (objectTrans.h). The DtHlaBroker creates a translator for each message type. Each translator is responsible for translating its message type to an HLA class and back. This concept maps fairly well for DIS and the RPR FOM, but may not work for more complex FOMs. Therefore, the translator classes are not part of the libBroker API.

Interaction translators register for updates for their interaction type. They translate the updates and pass them to their local federation or the Portal, as appropriate.

Object translators register for object discovery, update, and removal messages, then translate them and publish them to the Portal or federation. A DtBrokerObject (brokerObject.h) is maintained for every object the translator knows about. The broker object contains pointers to the reflected object, the publisher, and other data about the object, such as whether it has been discovered or filtered.

You can create translators in the following ways:

When you create a translator class, you must create a static function called translatorName() that returns a string. For example, the DtEntityTranslator class has this code:

static const char* DtEntityTranslator::translatorName()
{ return "Entity"; };

If you want to override this class, you add the same function to your class:

static const char *DtModEntityTranslator::translatorName()
{return "Entity";};

If you want to add a new type of translator you provide a new name.

static const char *DtAppleTranslator::translatorName() {return "Apple;};

The translator name is displayed on the Translators page of a connection's information dialog box.

Note
You must enable translators

Brokers that want to replace a translator should register their translator with the factory after creating the DtHlaBroker. The broker should then tell the DtHlaBroker instance to load all its translators. For example, code to replace the EntityState translator would look like this:

// Create an HLA broker application. This creates the DtHlaBroker
// instance, and registers all the default translators.
DtHlaBrokerApp brokerApp(hlaInit);
// Registers a new translator creator for entities. Its factory knows
// this class creates entities because the method translatorName()
// returns a string called "Entity"
brokerApp.hlaBroker()->objectTranslatorFactory()->addCreator
// run() calls the creator functions to load all required translators. It
// uses the creators registered in the previous lines of code.
brokerApp.run();

[<< The Broker API] [Home] [Top of Page] [The DIS Broker API >>]


Document ID: Generated on Tue Jun 25 16:45:35 EDT 2024 from SVN revision 267383
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)