VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtReflectedEntityConnector Class Reference

Detailed Description

DtReflectedEntityConnector registers callbacks with DtReflectedExtEntityList and DtReflectedControlObjectList to receive notifications when entities and control objects are added or removed from the simulation. It translates these VR-Link events into VR-Engage messages (EntityDiscoveredMessage, EntityRemovedMessage, VrfDiscoverEventMessage, VrfRemoveEventMessage) and queues them for frontend consumption.

It also handles RequestEntitiesByTypeMessage, querying both the entity list and the control object list for matches and responding with RequestEntitiesByTypeResponseMessage.

A single-entry cache (myCachedReflectedEntityInfo) accelerates repeated lookups of UUID and entity type for the most recently accessed entity. The deprecated lookupUUID() and findEntityIdFromUUID() methods wrap DtUUID::objectIdentificationResolver() for backward compatibility; prefer calling the resolver directly in new code.

This connector is fully independent — it does not depend on any other connector and does not publish shared state to the app attribute store.

#include <reflectedEntityConnector.h>

Inheritance diagram for makVre::DtReflectedEntityConnector:
[legend]

Public Member Functions

 DtReflectedEntityConnector ()
 
virtual ~DtReflectedEntityConnector () override
 
virtual void install (makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection, makVrf::DtVrlinkVrfRemoteController *vrfRemoteController, DtReflectedExtEntityList *reflectedExtEntityList, DtReflectedControlObjectList *reflectedControlObjectList)
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual DtVreMessageResult handleRequestEntitiesByType (DtVreMessage *msg)
 
virtual DtReflectedExtEntityInfo * lookupReflectedEntityInfo (const DtEntityIdentifier &entityId)
 
virtual DtUUID lookupUUID (const DtEntityIdentifier &entityId)
 
virtual DtEntityIdentifier findEntityIdFromUUID (const DtUUID &uuid)
 
virtual DtUUID findUUID (DtReflectedExtEntity *reflectedEntity)
 
- Public Member Functions inherited from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector
 DtSimEventConnector ()
 
virtual ~DtSimEventConnector () override
 
virtual void install (makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection)
 
- Public Member Functions inherited from makVre::DtConnector
 DtConnector ()
 
virtual ~DtConnector ()
 
virtual DtConnectorType type ()
 
virtual std::string name ()
 

Static Public Member Functions

static void entityAddedCallback (DtReflectedExtEntity *obj, void *usr)
 
static void entityRemovedCallback (DtReflectedExtEntity *obj, void *usr)
 
static void controlObjectAddedCallback (DtReflectedControlObject *obj, void *usr)
 
static void controlObjectRemovedCallback (DtReflectedControlObject *obj, void *usr)
 
static bool envProcessDiscoveryConditionCallback (DtReflectedObject *envProcess, void *userData)
 
- Static Public Member Functions inherited from makVre::DtConnector
static std::string extension (DtConnectorType type)
 

Protected Member Functions

virtual void handleActionMenuControlObjectDiscovered (DtReflectedControlObject *obj)
 
virtual void handleActionMenuControlObjectRemoved (DtReflectedControlObject *obj)
 
virtual bool processEnvProcessDiscoveryCriteria (DtReflectedEnvironmentProcess *envProcess)
 
virtual void debugFillAllEntities ()
 

Protected Attributes

makVrf::DtVrlinkVrfRemoteController * myVrfRemoteController
 
DtReflectedExtEntityList * myReflectedExtEntityList
 
DtReflectedControlObjectList * myReflectedControlObjectList
 
DtReflectedExtEntityInfo * myCachedReflectedEntityInfo
 
DtAttributeHandle myLocalStatusAttr
 
- Protected Attributes inherited from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector
makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection * myConnection
 
- Protected Attributes inherited from makVre::DtConnector
std::string myName
 
DtConnectorType myType
 
DtAttributeCallbackManager myAttributeCallbacks
 
DtVreMessageHandlerGroup myMessageHandlers
 
using SetAttrFunc = std::function<void(const DtReflectedExtEntity&, DtAttributeHandle&)>
 
using ReadAppearanceFunc = std::function<void(const DtAppearance&, DtAttributeHandle&)>
 
DtAttributeHandleType< std::set< std::string > > myEntityStateStore
 
std::map< std::string, SetAttrFunc > mySetAttrMap
 
std::map< std::string, ReadAppearanceFunc > myReadAppearanceMap
 
virtual void updateReflectedEntityAttributes ()
 
virtual void updateAttributesForEntity (DtReflectedExtEntity *ree, DtAttributeHandle &entityAttr)
 
virtual void installSetAttrFunctions ()
 
using ConvertExtDataFunc = std::function<void(const DtString&, DtAttributeHandle&)>
 
std::map< DtString, ConvertExtDataFunc > myExtDataConversionMap
 
using ReadStatePropFunc = std::function<void(const DtPropertyInterface&, DtAttributeHandle&)>
 
std::map< DtString, ReadStatePropFunc > myRwToAttrMap
 
using SetPartParamAttrFunc = std::function<void(const DtArticulatedPart&, DtAttributeHandle&)>
 
std::map< std::string, SetPartParamAttrFunc > mySetPartParamAttrMap
 
using ReadResourceParamFunc = std::function<void(const DtSimResource&, DtAttributeHandle&)>
 
std::map< std::string, ReadResourceParamFunc > myReadResourceParamMap
 
boost::signals2::connection myResourceResponseConnection
 
std::unordered_set< std::string > myResourceMonitoringSet
 
virtual void fillResourceAttribute (const DtSimResource &resource, DtAttributeHandle resourceAttr) const
 
virtual void processResourceResponse (const makVrfEvents::DtEvent &evt)
 
using ReadSensorParamFunc = std::function<void(const DtIfSensorData&, DtAttributeHandle&)>
 
std::map< std::string, ReadSensorParamFunc > myReadSensorParamMap
 
std::map< std::string, std::unordered_set< std::string > > mySensorMonitoringMap
 
virtual void processSensorUpdate (const DtIfSensorData &sensorData)
 
static void sensorUpdateCallback (DtSimMessage *msg, void *usr)
 

Additional Inherited Members

- Public Types inherited from makVre::DtConnector
enum  DtConnectorType {
  DIS , HLA13 , HLA1516 , HLA1516E ,
  HLA4
}
 

Member Typedef Documentation

◆ SetAttrFunc

using makVre::DtReflectedEntityConnector::SetAttrFunc = std::function<void(const DtReflectedExtEntity&, DtAttributeHandle&)>
protected

Function pointer for setting a Reflected Entity Attribute from reflected ESR data.

◆ ReadAppearanceFunc

using makVre::DtReflectedEntityConnector::ReadAppearanceFunc = std::function<void(const DtAppearance&, DtAttributeHandle&)>
protected

Appearance readers.

◆ ConvertExtDataFunc

using makVre::DtReflectedEntityConnector::ConvertExtDataFunc = std::function<void(const DtString&, DtAttributeHandle&)>
protected

Extended Data convenience conversions.

Function pointer for setting a type-converted Reflected Entity Attribute from an Extended Data string

◆ ReadStatePropFunc

using makVre::DtReflectedEntityConnector::ReadStatePropFunc = std::function<void(const DtPropertyInterface&, DtAttributeHandle&)>
protected

State Property readers.

Function pointer for setting a Reflected Entity Attribute from a State Property Interface

◆ SetPartParamAttrFunc

using makVre::DtReflectedEntityConnector::SetPartParamAttrFunc = std::function<void(const DtArticulatedPart&, DtAttributeHandle&)>
protected

Articulated part readers.

◆ ReadResourceParamFunc

using makVre::DtReflectedEntityConnector::ReadResourceParamFunc = std::function<void(const DtSimResource&, DtAttributeHandle&)>
protected

Resource readers.

◆ ReadSensorParamFunc

using makVre::DtReflectedEntityConnector::ReadSensorParamFunc = std::function<void(const DtIfSensorData&, DtAttributeHandle&)>
protected

Sensor readers.

Constructor & Destructor Documentation

◆ DtReflectedEntityConnector()

makVre::DtReflectedEntityConnector::DtReflectedEntityConnector ( )

Default constructor. Initializes all pointers to nullptr.

◆ ~DtReflectedEntityConnector()

virtual makVre::DtReflectedEntityConnector::~DtReflectedEntityConnector ( )
overridevirtual

Virtual destructor. Frees myCachedReflectedEntityInfo.

Member Function Documentation

◆ install()

virtual void makVre::DtReflectedEntityConnector::install ( makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection * connection,
makVrf::DtVrlinkVrfRemoteController * vrfRemoteController,
DtReflectedExtEntityList * reflectedExtEntityList,
DtReflectedControlObjectList * reflectedControlObjectList )
virtual

Installs the entity tracking connector with shared infrastructure.

Stores the infrastructure pointers, registers entity-added/removed callbacks on the reflected extended entity list, control-object-added/removed callbacks on the reflected control object list, and sets the environment process discovery condition. Also registers a handler for RequestEntitiesByTypeMessage.

Parameters
connectionNon-owning pointer to the protocol-specific VR-Link connection.
vrfRemoteControllerNon-owning pointer to the VRF remote controller; retained for potential controller-level queries
reflectedExtEntityListNon-owning pointer to the reflected extended entity list; used to register entity-added/removed callbacks and answer type queries
reflectedControlObjectListNon-owning pointer to the reflected control object list; used to register control-object-added/removed callbacks, set the discovery condition, and answer type queries

◆ tick()

virtual void makVre::DtReflectedEntityConnector::tick ( double dt)
overridevirtual

Performs periodic processing (currently a no-op)

Parameters
dtThe elapsed time in seconds since the last tick

Reimplemented from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector.

◆ shutdown()

virtual void makVre::DtReflectedEntityConnector::shutdown ( )
overridevirtual

Shuts down the connector.

Removes the RequestEntitiesByType message handler, removes entity-added/removed callbacks from the reflected entity list, and removes control-object-added/removed callbacks from the reflected control object list.

Reimplemented from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector.

◆ handleRequestEntitiesByType()

virtual DtVreMessageResult makVre::DtReflectedEntityConnector::handleRequestEntitiesByType ( DtVreMessage * msg)
virtual

Message handlers.

Handles a request to find entities matching a specific type pattern

Parameters
msgPointer to a RequestEntitiesByTypeMessage
Returns
HANDLED

Iterates over the reflected entity list and the reflected control object list, collecting entities whose type matches the requested pattern. Queues a RequestEntitiesByTypeResponseMessage with all matches.

◆ entityAddedCallback()

static void makVre::DtReflectedEntityConnector::entityAddedCallback ( DtReflectedExtEntity * obj,
void * usr )
static

Static VR-Link entity callbacks.

Invoked by VR-Link when an entity is added to the reflected list

Parameters
objPointer to the added entity
usrPointer to the owning DtReflectedEntityConnector instance

Constructs and queues an EntityDiscoveredMessage carrying the entity's id, type, force, marking text, and VRF object label.

◆ entityRemovedCallback()

static void makVre::DtReflectedEntityConnector::entityRemovedCallback ( DtReflectedExtEntity * obj,
void * usr )
static

Invoked by VR-Link when an entity is removed from the reflected list.

Parameters
objPointer to the removed entity
usrPointer to the owning DtReflectedEntityConnector instance

Queues an EntityRemovedMessage and clears myCachedReflectedEntityInfo if it held data for the removed entity.

◆ controlObjectAddedCallback()

static void makVre::DtReflectedEntityConnector::controlObjectAddedCallback ( DtReflectedControlObject * obj,
void * usr )
static

Static VR-Link control object callbacks.

Invoked by VR-Link when a control object is added to the reflected list

Parameters
objPointer to the added control object
usrPointer to the owning DtReflectedEntityConnector instance

For scenario event objects (DtScenarioEventsType): extracts the scenario event caption and UUID and queues a VrfDiscoverEventMessage. For action menu objects (entity types 16.0.0.1, bullseye, 17.0.0.2): delegates to handleActionMenuControlObjectDiscovered().

◆ controlObjectRemovedCallback()

static void makVre::DtReflectedEntityConnector::controlObjectRemovedCallback ( DtReflectedControlObject * obj,
void * usr )
static

Invoked by VR-Link when a control object is removed from the reflected list.

Parameters
objPointer to the removed control object
usrPointer to the owning DtReflectedEntityConnector instance

For scenario event objects: queues a VrfRemoveEventMessage. For action menu objects: delegates to handleActionMenuControlObjectRemoved().

◆ envProcessDiscoveryConditionCallback()

static bool makVre::DtReflectedEntityConnector::envProcessDiscoveryConditionCallback ( DtReflectedObject * envProcess,
void * userData )
static

Discovery condition callback for environment processes.

Parameters
envProcessPointer to the reflected object being evaluated as an environment process
userDataPointer to the owning DtReflectedEntityConnector instance
Returns
true if the environment process meets the discovery criteria

Delegates to processEnvProcessDiscoveryCriteria() on the connector instance.

◆ lookupReflectedEntityInfo()

virtual DtReflectedExtEntityInfo * makVre::DtReflectedEntityConnector::lookupReflectedEntityInfo ( const DtEntityIdentifier & entityId)
virtual

Entity caching and UUID lookup.

Looks up and caches reflected entity info for the given entity ID

Parameters
entityIdThe entity identifier to look up
Returns
Pointer to DtReflectedExtEntityInfo if the entity exists, nullptr otherwise

Checks myCachedReflectedEntityInfo first. On a cache miss, looks the entity up in myReflectedExtEntityList, updates the cache, and returns the new entry.

◆ lookupUUID()

virtual DtUUID makVre::DtReflectedEntityConnector::lookupUUID ( const DtEntityIdentifier & entityId)
virtual

Returns the UUID for an entity using the single-entry cache.

Parameters
entityIdThe entity identifier to resolve
Returns
The DtUUID for the entity, or DtUUID::nullUUID() if not found
Deprecated
Prefer DtUUID::objectIdentificationResolver() for direct lookups

◆ findEntityIdFromUUID()

virtual DtEntityIdentifier makVre::DtReflectedEntityConnector::findEntityIdFromUUID ( const DtUUID & uuid)
virtual

Resolves a UUID to an entity identifier via the object identification resolver.

Parameters
uuidThe UUID to resolve
Returns
The DtEntityIdentifier for the entity
Deprecated
Prefer DtUUID::objectIdentificationResolver() for direct lookups

◆ findUUID()

virtual DtUUID makVre::DtReflectedEntityConnector::findUUID ( DtReflectedExtEntity * reflectedEntity)
virtual

Extracts the UUID from a reflected entity via the object identification resolver.

Parameters
reflectedEntityThe reflected entity to get the UUID for
Returns
The DtUUID for the entity

◆ handleActionMenuControlObjectDiscovered()

virtual void makVre::DtReflectedEntityConnector::handleActionMenuControlObjectDiscovered ( DtReflectedControlObject * obj)
protectedvirtual

Constructs and queues an EntityDiscoveredMessage for an action menu control object.

Parameters
objPointer to the action menu control object

◆ handleActionMenuControlObjectRemoved()

virtual void makVre::DtReflectedEntityConnector::handleActionMenuControlObjectRemoved ( DtReflectedControlObject * obj)
protectedvirtual

Constructs and queues an EntityRemovedMessage for an action menu control object.

Parameters
objPointer to the action menu control object

◆ processEnvProcessDiscoveryCriteria()

virtual bool makVre::DtReflectedEntityConnector::processEnvProcessDiscoveryCriteria ( DtReflectedEnvironmentProcess * envProcess)
protectedvirtual

Evaluates whether an environment process meets the discovery criteria.

Parameters
envProcessPointer to the environment process to evaluate
Returns
true if the process has a valid entity type and at least one environmental record

◆ updateReflectedEntityAttributes()

virtual void makVre::DtReflectedEntityConnector::updateReflectedEntityAttributes ( )
protectedvirtual

Function pointer for setting a Reflected Entity Attribute from reflected ESR data.

◆ updateAttributesForEntity()

virtual void makVre::DtReflectedEntityConnector::updateAttributesForEntity ( DtReflectedExtEntity * ree,
DtAttributeHandle & entityAttr )
protectedvirtual

Function pointer for setting a Reflected Entity Attribute from reflected ESR data.

◆ installSetAttrFunctions()

virtual void makVre::DtReflectedEntityConnector::installSetAttrFunctions ( )
protectedvirtual

Register SetAttrFunc functions in mySetAttrMap for reading Entity Attributes from reflected ESR data.

Note
Override and extend to add custom set functions for reading additional ESR data.

◆ fillResourceAttribute()

virtual void makVre::DtReflectedEntityConnector::fillResourceAttribute ( const DtSimResource & resource,
DtAttributeHandle resourceAttr ) const
protectedvirtual

Resource readers.

◆ processResourceResponse()

virtual void makVre::DtReflectedEntityConnector::processResourceResponse ( const makVrfEvents::DtEvent & evt)
protectedvirtual

Resource readers.

◆ sensorUpdateCallback()

static void makVre::DtReflectedEntityConnector::sensorUpdateCallback ( DtSimMessage * msg,
void * usr )
staticprotected

Static callback wrapper for sensor update.

Calls user->handleSensorUpdate() with the sensor data extracted from the message.

Parameters
msgThe DtSimMessage containing the sensor update information.
usrPointer to the DtReflectedEntityConnector instance to call the member handler.

◆ processSensorUpdate()

virtual void makVre::DtReflectedEntityConnector::processSensorUpdate ( const DtIfSensorData & sensorData)
protectedvirtual

Member handler for sensor data from update callback.

Parameters
sensorDataThe sensor data extracted from the message.

◆ debugFillAllEntities()

virtual void makVre::DtReflectedEntityConnector::debugFillAllEntities ( )
protectedvirtual

Member Data Documentation

◆ myVrfRemoteController

makVrf::DtVrlinkVrfRemoteController* makVre::DtReflectedEntityConnector::myVrfRemoteController
protected

Non-owning pointer to the VRF remote controller.

Note
Retained for potential controller-level queries; does not create or destroy it

◆ myReflectedExtEntityList

DtReflectedExtEntityList* makVre::DtReflectedEntityConnector::myReflectedExtEntityList
protected

Non-owning pointer to the reflected extended entity list.

Note
Used to register entity-added/removed callbacks and to answer type queries

◆ myReflectedControlObjectList

DtReflectedControlObjectList* makVre::DtReflectedEntityConnector::myReflectedControlObjectList
protected

Non-owning pointer to the reflected control object list.

Note
Used to register control-object callbacks, set the discovery condition, and answer control object type queries

◆ myCachedReflectedEntityInfo

DtReflectedExtEntityInfo* makVre::DtReflectedEntityConnector::myCachedReflectedEntityInfo
protected

Single-entry cache for the most recently accessed entity's reflected info.

Note
Owned by this connector; freed in the destructor. Invalidated when the cached entity is removed via entityRemovedCallback().

◆ myLocalStatusAttr

DtAttributeHandle makVre::DtReflectedEntityConnector::myLocalStatusAttr
protected

◆ myEntityStateStore

DtAttributeHandleType<std::set<std::string> > makVre::DtReflectedEntityConnector::myEntityStateStore
protected

Reflected Entity Attribute system.

Provides a mechanism for accessing (nearly) all reflected entity information using DtAttributes. This includes most ESR data members, as well as Resources and Sensor data.

Entity data is stored in DtAttribute::Root()["Entities"][entityId][propertyName]

Attribute store for reflected entity state

◆ mySetAttrMap

std::map<std::string, SetAttrFunc> makVre::DtReflectedEntityConnector::mySetAttrMap
protected

Map of individual Reflected Entity Attribute names with corresponding set functions to read ESR data.

Most getter methods in ESR are mirrored by an Attribute of the same name. e.g. DtReflectedEntity::damageState is found as DtAttribute::Root()["Entities"][entityId]["damageState"]

◆ myReadAppearanceMap

std::map<std::string, ReadAppearanceFunc> makVre::DtReflectedEntityConnector::myReadAppearanceMap
protected

Function pointer for setting a Reflected Entity Attribute from reflected ESR data.

◆ myExtDataConversionMap

std::map<DtString, ConvertExtDataFunc> makVre::DtReflectedEntityConnector::myExtDataConversionMap
protected

Map of State Property names with corresponding functions to read the property and set an Attribute.

◆ myRwToAttrMap

std::map<DtString, ReadStatePropFunc> makVre::DtReflectedEntityConnector::myRwToAttrMap
protected

Map of State Property names with corresponding functions to read the property and set an Attribute.

◆ mySetPartParamAttrMap

std::map<std::string, SetPartParamAttrFunc> makVre::DtReflectedEntityConnector::mySetPartParamAttrMap
protected

Articulated part readers.

◆ myReadResourceParamMap

std::map<std::string, ReadResourceParamFunc> makVre::DtReflectedEntityConnector::myReadResourceParamMap
protected

Resource readers.

◆ myResourceResponseConnection

boost::signals2::connection makVre::DtReflectedEntityConnector::myResourceResponseConnection
protected

Connection for resource response events from the VR-Forces backend.

Connected during initialization and disconnected during shutdown.

◆ myResourceMonitoringSet

std::unordered_set<std::string> makVre::DtReflectedEntityConnector::myResourceMonitoringSet
protected

Resource readers.

◆ myReadSensorParamMap

std::map<std::string, ReadSensorParamFunc> makVre::DtReflectedEntityConnector::myReadSensorParamMap
protected

Sensor readers.

◆ mySensorMonitoringMap

std::map<std::string, std::unordered_set<std::string> > makVre::DtReflectedEntityConnector::mySensorMonitoringMap
protected

Sensor readers.


The documentation for this class was generated from the following file: