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

Detailed Description

DtOwnshipCreationConnector is responsible for the lifecycle of the single locally controlled "new ownship" entity. When the frontend requests a new ownship of a specific type, this connector submits a createEntity call to the VR-Forces backend and tracks the result via a static callback. When the desired entity type changes (or is cleared), it deletes the existing entity and optionally creates a new one.

The connector registers entity-added and entity-removed callbacks on the DtReflectedExtEntityList to detect when the created entity appears in or disappears from the reflected entity list. These callbacks are filtered to the owned entity only.

Backend readiness (started + loaded) and the active backend address are read from the app attribute store via DtAttributeHandleType<> handles published by DtVreBackendConnector. This avoids any direct connector-to-connector pointer dependency.

#include <ownshipCreationConnector.h>

Inheritance diagram for makVre::DtOwnshipCreationConnector:
[legend]

Public Member Functions

 DtOwnshipCreationConnector ()
 
virtual ~DtOwnshipCreationConnector () override
 
virtual void install (makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection, makVrf::DtVrlinkVrfRemoteController *vrfRemoteController, DtReflectedExtEntityList *reflectedExtEntityList)
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual DtVreMessageResult handleCreateNewOwnship (DtVreMessage *message)
 
virtual DtVreMessageResult handleDestroyNewOwnship (DtVreMessage *message)
 
- 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 localEntityCreatedCallback (const DtString &name, const DtEntityIdentifier &id, const DtUUID &uuid, void *usr)
 
static void ownedEntityAddedCallback (DtReflectedExtEntity *obj, void *usr)
 
static void ownedEntityRemovedCallback (DtReflectedExtEntity *obj, void *usr)
 
- Static Public Member Functions inherited from makVre::DtConnector
static std::string extension (DtConnectorType type)
 

Protected Member Functions

virtual void verifyNewOwnship ()
 
virtual void sendCreateNewOwnship ()
 
virtual void sendDeleteNewOwnship ()
 
virtual void handleLocalEntityCreated (const DtString &name, const DtEntityIdentifier &entityId, const DtUUID &uuid)
 
virtual void handleOwnedEntityAdded (const DtReflectedExtEntity *entity)
 
virtual void handleOwnedEntityRemoved (const DtReflectedExtEntity *entity)
 

Protected Attributes

makVrf::DtVrlinkVrfRemoteController * myVrfRemoteController = nullptr
 
DtReflectedExtEntityList * myReflectedExtEntityList = nullptr
 
DtAttributeHandleType< DtSimulationAddress > myVreBackendAttr
 
DtAttributeHandleType< BackendStatusMessage::BackendStatusData > myBackendStatusAttr
 
CreateNewOwnshipMessage * myDesiredCreateEntityMessage
 
DtReflectedExtEntityInfo myCreatedEntityInfo
 
bool myWaitingForOwnshipDelete = false
 
bool myWaitingForOwnshipCreate = false
 
bool myCreatedOwnshipNeedsReposition = false
 
- 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
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ DtOwnshipCreationConnector()

makVre::DtOwnshipCreationConnector::DtOwnshipCreationConnector ( )

Default constructor. Initializes all state to default/null values.

◆ ~DtOwnshipCreationConnector()

virtual makVre::DtOwnshipCreationConnector::~DtOwnshipCreationConnector ( )
overridevirtual

Virtual destructor. Frees myDesiredCreateEntityMessage.

Member Function Documentation

◆ install()

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

Installs the ownship connector with shared infrastructure.

Stores the infrastructure pointers, registers VRE message handlers for CreateNew/DestroyNewOwnship, and registers entity-added/removed callbacks on the reflected ext entity list. Backend readiness and the active backend address are read from the global App attribute tree via DtAttributeHandleType<> handles bound to vreBackendStatus and vreBackendStatus.SimAddress.

Parameters
connectionNon-owning pointer to the protocol-specific VR-Link connection.
vrfRemoteControllerNon-owning pointer to the VRF remote controller; used to call createEntity(), deleteObject(), and sendSetDataMsg()
reflectedExtEntityListNon-owning pointer to the reflected extended entity list; used to register entity-added/removed callbacks

◆ tick()

virtual void makVre::DtOwnshipCreationConnector::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::DtOwnshipCreationConnector::shutdown ( )
overridevirtual

Shuts down the connector.

Removes VRE message handlers and entity-added/removed callbacks, and frees the desired-create message.

Reimplemented from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector.

◆ handleCreateNewOwnship()

virtual DtVreMessageResult makVre::DtOwnshipCreationConnector::handleCreateNewOwnship ( DtVreMessage * message)
virtual

Ownship message handlers.

Handles a request to create a new ownship entity of the specified type

Parameters
messagePointer to a CreateNewOwnshipMessage
Returns
HANDLED

Copies the desired entity specification to myDesiredCreateEntityMessage, then calls verifyNewOwnship() to initiate creation if the backend is ready.

◆ handleDestroyNewOwnship()

virtual DtVreMessageResult makVre::DtOwnshipCreationConnector::handleDestroyNewOwnship ( DtVreMessage * message)
virtual

Handles a request to destroy the current new ownship entity.

Parameters
messagePointer to a DestroyNewOwnshipMessage
Returns
HANDLED

Sets the desired entity type to nullType, then calls verifyNewOwnship() to initiate deletion of the current entity if one exists.

◆ localEntityCreatedCallback()

static void makVre::DtOwnshipCreationConnector::localEntityCreatedCallback ( const DtString & name,
const DtEntityIdentifier & id,
const DtUUID & uuid,
void * usr )
static

Static VR-Link callbacks.

Invoked by VRF when a locally requested entity has been created

Parameters
nameDisplay name assigned by VRF to the new entity
idDIS entity identifier of the new entity
uuidUUID assigned to the new entity
usrPointer to the owning DtOwnshipCreationConnector instance

References makVre::DtConnector::name().

◆ ownedEntityAddedCallback()

static void makVre::DtOwnshipCreationConnector::ownedEntityAddedCallback ( DtReflectedExtEntity * obj,
void * usr )
static

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

Parameters
objPointer to the added entity; filtered to owned entity only
usrPointer to the owning DtOwnshipCreationConnector instance

◆ ownedEntityRemovedCallback()

static void makVre::DtOwnshipCreationConnector::ownedEntityRemovedCallback ( DtReflectedExtEntity * obj,
void * usr )
static

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

Parameters
objPointer to the removed entity; filtered to owned entity only
usrPointer to the owning DtOwnshipCreationConnector instance

◆ verifyNewOwnship()

virtual void makVre::DtOwnshipCreationConnector::verifyNewOwnship ( )
protectedvirtual

Verifies whether the current entity matches the desired state and acts accordingly.

If the backend is not started/loaded, returns immediately. Otherwise compares myDesiredCreateEntityMessage entity type against myCreatedEntityInfo.myEntityType and issues a create or delete command as needed.

◆ sendCreateNewOwnship()

virtual void makVre::DtOwnshipCreationConnector::sendCreateNewOwnship ( )
protectedvirtual

Sends a createEntity request to the VRF backend.

Asserts that no create or delete is already in progress and that the backend exists. Calls myVrfRemoteController->createEntity() with the parameters from myDesiredCreateEntityMessage. Sets myWaitingForOwnshipCreate = true.

◆ sendDeleteNewOwnship()

virtual void makVre::DtOwnshipCreationConnector::sendDeleteNewOwnship ( )
protectedvirtual

Sends a deleteObject request to the VRF backend for the current ownship.

Asserts that no create or delete is already in progress and that an owned UUID exists. Calls myVrfRemoteController->deleteObject(). Sets myWaitingForOwnshipDelete = true.

◆ handleLocalEntityCreated()

virtual void makVre::DtOwnshipCreationConnector::handleLocalEntityCreated ( const DtString & name,
const DtEntityIdentifier & entityId,
const DtUUID & uuid )
protectedvirtual

Called when VRF confirms the locally requested entity was created.

Sends NewOwnshipCreatedMessage to the frontend, applies a hold-fire ROE, records myCreatedEntityInfo, and calls verifyNewOwnship() to check the result. If the entity type is not yet known (not yet reflected), type resolution is deferred to handleOwnedEntityAdded().

Parameters
nameDisplay name of the created entity
entityIdDIS entity identifier
uuidUUID of the created entity

References makVre::DtConnector::name().

◆ handleOwnedEntityAdded()

virtual void makVre::DtOwnshipCreationConnector::handleOwnedEntityAdded ( const DtReflectedExtEntity * entity)
protectedvirtual

Called when the owned entity appears in the reflected entity list.

If the entity type was unknown at creation time (deferred from handleLocalEntityCreated), fills in the type and clears myWaitingForOwnshipCreate, then calls verifyNewOwnship().

Parameters
entityPointer to the reflected extended entity that was added

◆ handleOwnedEntityRemoved()

virtual void makVre::DtOwnshipCreationConnector::handleOwnedEntityRemoved ( const DtReflectedExtEntity * entity)
protectedvirtual

Called when the owned entity is removed from the reflected entity list.

Handles expected removal (waiting for delete or backend reloading) by clearing myCreatedEntityInfo and calling verifyNewOwnship(). Also handles unexpected removal due to backend shutdown/unload.

Parameters
entityPointer to the reflected extended entity that was removed

Member Data Documentation

◆ myVrfRemoteController

makVrf::DtVrlinkVrfRemoteController* makVre::DtOwnshipCreationConnector::myVrfRemoteController = nullptr
protected

Infrastructure pointers (NON-OWNING — owned by DtConnectorAccessory)

Shared VRF remote controller (NON-OWNING)

Used to call createEntity(), deleteObject(), and sendSetDataMsg().

◆ myReflectedExtEntityList

DtReflectedExtEntityList* makVre::DtOwnshipCreationConnector::myReflectedExtEntityList = nullptr
protected

Reflected extended entity list (NON-OWNING)

Used to register entity-added/removed callbacks.

◆ myVreBackendAttr

DtAttributeHandleType<DtSimulationAddress> makVre::DtOwnshipCreationConnector::myVreBackendAttr
protected

App attribute store handles for reading backend state.

Written by DtVreBackendConnector; read here without any direct connector pointer.

VRE backend simulation address

Published by DtVreBackendConnector as a DtAttributeHandleType<DtSimulationAddress>. Nullid when no backend is running.

Attribute Store KeyvreBackendStatus.SimAddress

◆ myBackendStatusAttr

DtAttributeHandleType<BackendStatusMessage::BackendStatusData> makVre::DtOwnshipCreationConnector::myBackendStatusAttr
protected

Published backend status data.

Attribute Store KeyvreBackendStatus

◆ myDesiredCreateEntityMessage

CreateNewOwnshipMessage* makVre::DtOwnshipCreationConnector::myDesiredCreateEntityMessage
protected

Ownship state.

The entity creation parameters that the frontend has requested

Owned by this connector; initialized to an empty CreateNewOwnshipMessage in the constructor. A nullType entity type signals "no ownship desired".

◆ myCreatedEntityInfo

DtReflectedExtEntityInfo makVre::DtOwnshipCreationConnector::myCreatedEntityInfo
protected

Information about the entity that has been created (or is being tracked)

myEntityId is nullId() when no entity is created. myEntityType is nullType() if the entity exists but type is not yet known.

◆ myWaitingForOwnshipDelete

bool makVre::DtOwnshipCreationConnector::myWaitingForOwnshipDelete = false
protected

True while waiting for VRF to confirm deletion of an ownship entity.

◆ myWaitingForOwnshipCreate

bool makVre::DtOwnshipCreationConnector::myWaitingForOwnshipCreate = false
protected

True while waiting for VRF to confirm creation of an ownship entity.

◆ myCreatedOwnshipNeedsReposition

bool makVre::DtOwnshipCreationConnector::myCreatedOwnshipNeedsReposition = false
protected

True if the newly created ownship needs to be repositioned after creation.


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