VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
DtVrfManager Class Reference

DtVrfManager - Generic VRF tick engine and command gateway.

Responsibilities:

The DtVrfManager has NO knowledge of specific processor types. Processors are registered by the WebSocket layer on client connect and removed on client disconnect.

Thread Safety:

Public Member Functions

void initialize (DtRemoteControlInitializer &initializer, const std::string &configFilePath)
 
void shutdown ()
 
bool isInitialized () const
 
void addProcessor (std::shared_ptr< DtProcessor > processor)
 
void removeProcessor (std::shared_ptr< DtProcessor > processor)
 
DtDatasource::DtDataSourceStatus getStatus ()
 
size_t trackedObjectCount () const
 
DtWebServerObjectList & trackedObjects ()
 
tbb::spin_rw_mutex & vrfApiMutex ()
 
const
DtWebServerSubordinateResolver & 
subordinateResolver () const
 
std::vector< DtWebServerObjectPtr > allTrackedObjects () const
 
std::vector
< DtDatasource::DtContactReportSnapshot > 
contactReportsForRoles (const std::vector< std::string > &roleNames) const
 
int entityForceId (const std::string &objectName) const
 
std::string tacticalGraphicOverlay (const std::string &objectName) const
 
size_t capableTaskQueueSize () const
 
Json::Value getScenarioStatus () const
 
uint64_t scenarioStatusGeneration () const
 
void pauseScenario ()
 
void resumeScenario ()
 
bool deleteObject (const std::string &objectName)
 
bool editObject (const std::string &objectName, const Json::Value &body, std::string &errorMessage, bool &isValidationError)
 
std::string createTacticalGraphic (const Json::Value &body, std::string &errorMessage, bool &isValidationError)
 
Json::Value getCommandSummaries (const std::vector< std::string > &filter={})
 
Json::Value getCommandSpec (const std::string &commandType, const std::string &objectName="")
 
Json::Value getRwCommandSpecsConfig ()
 
bool updateRwCommandSpecEntry (const std::string &commandType, const Json::Value &entry)
 
bool issueCommand (const std::string &objectName, const std::string &commandType, const Json::Value &parameters, std::string *errorMessage=nullptr)
 
bool skipTask (const std::string &objectName, std::string *errorMessage=nullptr)
 
void addScenarioChangedListener (std::function< void(const std::string &)> listener)
 

Static Public Member Functions

static DtVrfManager & getInstance ()
 

Protected Member Functions

 DtVrfManager ()
 
 ~DtVrfManager ()
 
 DtVrfManager (const DtVrfManager &)=delete
 
DtVrfManager & operator= (const DtVrfManager &)=delete
 
void initializeVRFAPI (DtRemoteControlInitializer &initializer)
 
void shutdownVRFAPI ()
 
DtDatasource::DtDataSourceStatus queryStatusFromVRF ()
 
void onStatusChanged ()
 
Json::Value queryScenarioStatusFromVRF ()
 
void onStateDataAdded (makVrf::DtStateData *stateData)
 
void onStateDataAboutToBeRemoved (const makVrf::DtStateData *stateData)
 
void onCurrentTaskChanged (const DtUUID &uuid)
 
void syncRoleSpotReportPerspectives ()
 
void tryBindParameterDb ()
 
void vrfUpdateLoop ()
 

Static Protected Member Functions

static void statusChangedCallback (DtSimulationStatus status, void *userData)
 

Protected Attributes

std::atomic< bool > myStatusChanged {false}
 
Json::Value myScenarioStatusCache
 
Json::Value myPrevScenarioStatusStable
 
double myPrevDateAndTimeOfDay {0.0}
 
std::atomic< uint64_t > myScenarioStatusGeneration {0}
 
std::vector< std::function
< void(const std::string &)> > 
myScenarioChangedListeners
 
void * myVrfApi = nullptr
 
tbb::spin_rw_mutex myVrfApiMutex
 
std::thread myVrfThread
 
std::atomic< bool > myRunning {false}
 
std::atomic< bool > myInitialized {false}
 
int myTickRateMs = 100
 
std::unique_ptr< DtExerciseConn > myExerciseConn
 
std::unique_ptr
< makVrf::DtVrlinkVrfRemoteController > 
myRemoteController
 
DtDatasource::DtDataSourceStatus myStatusCache
 
tbb::spin_mutex myDataMutex
 
std::vector< std::shared_ptr
< DtProcessor > > 
myProcessors
 
tbb::mutex myProcessorsMutex
 
DtWebServerObjectList myTrackedObjects
 
std::unique_ptr
< DtCommandSpecBuilder > 
myCommandSpecBuilder = nullptr
 
std::unique_ptr
< DtScenarioManager > 
myScenarioManager = nullptr
 
boost::signals2::connection myCurrentTaskChangedConnection
 
DtRoleSpotReportPerspectiveManager myRoleSpotReportPerspectiveMgr
 
std::unique_ptr
< DtWebServerSubordinateResolver > 
mySubordinateResolver
 
uint64_t myCachedRoleDefinitionGeneration = UINT64_MAX
 
DtCapableTaskRequester myCapableTaskRequester
 
std::unique_ptr< DtResourceCache > myResourceCache
 
std::unique_ptr
< DtSpotReportAutoEnabler > 
mySpotReportAutoEnabler
 

Constructor & Destructor Documentation

DtVrfManager::DtVrfManager ( )
protected
DtVrfManager::~DtVrfManager ( )
protected
DtVrfManager::DtVrfManager ( const DtVrfManager &  )
protecteddelete

Member Function Documentation

static DtVrfManager& DtVrfManager::getInstance ( )
static

Singleton accessor.

void DtVrfManager::initialize ( DtRemoteControlInitializer &  initializer,
const std::string &  configFilePath 
)
void DtVrfManager::shutdown ( )
bool DtVrfManager::isInitialized ( ) const
inline

References myInitialized.

void DtVrfManager::addProcessor ( std::shared_ptr< DtProcessor >  processor)

Add a processor to the tick loop. The processor's initialize() is called immediately so it is ready before the next tick. Safe to call from any thread.

void DtVrfManager::removeProcessor ( std::shared_ptr< DtProcessor >  processor)

Remove a processor from the tick loop. The processor's shutdown() is called before it is removed. Safe to call from any thread.

DtDatasource::DtDataSourceStatus DtVrfManager::getStatus ( )
size_t DtVrfManager::trackedObjectCount ( ) const
inline
DtWebServerObjectList& DtVrfManager::trackedObjects ( )
inline

References myTrackedObjects.

tbb::spin_rw_mutex& DtVrfManager::vrfApiMutex ( )
inline

References myVrfApiMutex.

const DtWebServerSubordinateResolver& DtVrfManager::subordinateResolver ( ) const
inline

References mySubordinateResolver.

std::vector<DtWebServerObjectPtr> DtVrfManager::allTrackedObjects ( ) const

Returns a thread-safe snapshot of all currently tracked simulation objects. Acquires a shared read lock on the VRF API mutex.

std::vector<DtDatasource::DtContactReportSnapshot> DtVrfManager::contactReportsForRoles ( const std::vector< std::string > &  roleNames) const

Returns contact report snapshots visible to the given roles. For each role, queries the corresponding DtSpotReportByForceAndUuidPerspective (if one exists) and collects all flushed contact report handlers. Deduplicates across roles by spot-report UUID. Acquires myVrfApiMutex shared; safe to call from WebSocket timer threads.

int DtVrfManager::entityForceId ( const std::string &  objectName) const

Returns the DIS force ID for the entity with the given objectName (UUID string). Returns -1 if the object is not found or the name is not a valid UUID.

std::string DtVrfManager::tacticalGraphicOverlay ( const std::string &  objectName) const

Returns the overlay name for the tactical graphic with the given UUID. Returns an empty string if the object is not found.

size_t DtVrfManager::capableTaskQueueSize ( ) const
inline

Returns the number of entities waiting for a CapableTaskAndSet response. Safe to call from any thread.

References myCapableTaskRequester, and DtCapableTaskRequester::queueSize().

Json::Value DtVrfManager::getScenarioStatus ( ) const

Returns a JSON snapshot of the current scenario status, ready for wire transmission. Safe to call from any thread.

uint64_t DtVrfManager::scenarioStatusGeneration ( ) const

Monotonically increasing counter incremented whenever scenario status changes (excluding simulation time). WebSocket listeners compare this against their own cached value to detect changes without deep comparison.

void DtVrfManager::pauseScenario ( )
void DtVrfManager::resumeScenario ( )
bool DtVrfManager::deleteObject ( const std::string &  objectName)
bool DtVrfManager::editObject ( const std::string &  objectName,
const Json::Value &  body,
std::string &  errorMessage,
bool &  isValidationError 
)

Applies one or more attribute/geometry edits to an existing tactical graphic by building a single DtIfModifyVrfObject from the supplied JSON body.

Parameters
objectNameUUID string of the object to edit.
bodyJSON object containing any subset of: Coordinates ([[lat,lon,alt],...]), ForceIdentifier (int>=0), Marking (string), OverlayName (string), Active (bool), Label (string).
errorMessagePopulated on failure with a human-readable reason.
isValidationErrorSet true for client input errors (maps to 400), false for server-side failures (maps to 404).
Returns
true on success; false on failure (errorMessage and isValidationError set).
std::string DtVrfManager::createTacticalGraphic ( const Json::Value &  body,
std::string &  errorMessage,
bool &  isValidationError 
)

Create a new tactical graphic (overlay object) from the JSON request body. Validates all required fields, generates a UUID, and sends a fire-and-forget create message to the sim. On failure, errorMessage is populated with a human-readable reason and isValidationError indicates whether the failure was a client input error (HTTP 400) or an unexpected server error (HTTP 500).

Returns
The pre-assigned UUID string of the new object, or empty string on failure.
Json::Value DtVrfManager::getCommandSummaries ( const std::vector< std::string > &  filter = {})

Returns a JSON array of lightweight command summaries for building menus/toolbars. If filter is non-empty, only the listed commandTypes are returned.

Json::Value DtVrfManager::getCommandSpec ( const std::string &  commandType,
const std::string &  objectName = "" 
)

Returns the full parameter spec for a single command type. objectName is optional; when supplied, entity-specific choice lists are populated. Returns a null Json::Value if commandType is unknown.

Json::Value DtVrfManager::getRwCommandSpecsConfig ( )

Returns a JSON array of all registered RW command types merged with any existing configuration from commandSpecs.json. Intended for the configure web UI — includes hidden status and all stored fields.

bool DtVrfManager::updateRwCommandSpecEntry ( const std::string &  commandType,
const Json::Value &  entry 
)

Upserts the commandSpecs.json entry for commandType in memory and on disk. The supplied entry JSON entirely replaces any existing entry.

Returns
True on success; false if the write fails (logged as a warning).
bool DtVrfManager::issueCommand ( const std::string &  objectName,
const std::string &  commandType,
const Json::Value &  parameters,
std::string *  errorMessage = nullptr 
)

Dispatches a command to the named entity.

Parameters
errorMessageIf non-null and the call fails, populated with a human-readable reason (bad UUID, unknown command type, wrong parameter type, etc.).
Returns
True if the command was accepted and dispatched.
bool DtVrfManager::skipTask ( const std::string &  objectName,
std::string *  errorMessage = nullptr 
)

Sends a skip-task request to the named entity.

Parameters
objectNameUUID string identifying the simulation object.
errorMessageIf non-null and the call fails, populated with a human-readable reason.
Returns
True if the request was dispatched; false if the UUID is invalid or the object is not found in the tracked object list.
void DtVrfManager::addScenarioChangedListener ( std::function< void(const std::string &)>  listener)

Registers a callback that is invoked on the VRF update thread whenever the scenario name changes (a new scenario is loaded or the current one is unloaded). The argument is the raw scenario path string as reported by VRF; it is empty when no scenario is loaded. Must be called from main() before the VRF update loop starts.

DtVrfManager& DtVrfManager::operator= ( const DtVrfManager &  )
protecteddelete
void DtVrfManager::initializeVRFAPI ( DtRemoteControlInitializer &  initializer)
protected
void DtVrfManager::shutdownVRFAPI ( )
protected
DtDatasource::DtDataSourceStatus DtVrfManager::queryStatusFromVRF ( )
protected
void DtVrfManager::onStatusChanged ( )
protected
static void DtVrfManager::statusChangedCallback ( DtSimulationStatus  status,
void *  userData 
)
staticprotected
Json::Value DtVrfManager::queryScenarioStatusFromVRF ( )
protected

Query current scenario status from VRF; called on the VRF tick thread.

void DtVrfManager::onStateDataAdded ( makVrf::DtStateData *  stateData)
protected
void DtVrfManager::onStateDataAboutToBeRemoved ( const makVrf::DtStateData *  stateData)
protected
void DtVrfManager::onCurrentTaskChanged ( const DtUUID &  uuid)
protected

Invoked on the VRF update thread whenever an entity's current task changes. Copies the latest EntityTaskInformation from DtRemoteControlCurrentTaskManager into the corresponding DtWebServerObject.

void DtVrfManager::syncRoleSpotReportPerspectives ( )
protected

Checks whether the active role definition has changed and, if so, rebuilds the per-role DtSpotReportByForceAndUuidPerspective instances on the spot-report manager. Also triggered by a scenario change (myCachedRoleDefinitionGeneration is reset to UINT64_MAX in vrfUpdateLoop on every scenario name transition). Called exclusively from the VRF update thread — no additional locking needed.

void DtVrfManager::tryBindParameterDb ( )
protected

Fully loads available sms parameters, so they are available for querying information afterwards Called once during initialization, after the VRF API is initialized and the first scenario status is received (which indicates that the sim is ready).

void DtVrfManager::vrfUpdateLoop ( )
protected

Member Data Documentation

std::atomic<bool> DtVrfManager::myStatusChanged {false}
protected
Json::Value DtVrfManager::myScenarioStatusCache
protected
Json::Value DtVrfManager::myPrevScenarioStatusStable
protected
double DtVrfManager::myPrevDateAndTimeOfDay {0.0}
protected

Last observed DateAndTimeOfDay; used to detect manual time jumps.

std::atomic<uint64_t> DtVrfManager::myScenarioStatusGeneration {0}
protected
std::vector<std::function<void(const std::string&)> > DtVrfManager::myScenarioChangedListeners
protected
void* DtVrfManager::myVrfApi = nullptr
protected
tbb::spin_rw_mutex DtVrfManager::myVrfApiMutex
mutableprotected

Referenced by vrfApiMutex().

std::thread DtVrfManager::myVrfThread
protected
std::atomic<bool> DtVrfManager::myRunning {false}
protected
std::atomic<bool> DtVrfManager::myInitialized {false}
protected

Referenced by isInitialized().

int DtVrfManager::myTickRateMs = 100
protected
std::unique_ptr<DtExerciseConn> DtVrfManager::myExerciseConn
protected
std::unique_ptr<makVrf::DtVrlinkVrfRemoteController> DtVrfManager::myRemoteController
protected
DtDatasource::DtDataSourceStatus DtVrfManager::myStatusCache
protected
tbb::spin_mutex DtVrfManager::myDataMutex
mutableprotected
std::vector<std::shared_ptr<DtProcessor> > DtVrfManager::myProcessors
protected
tbb::mutex DtVrfManager::myProcessorsMutex
protected
DtWebServerObjectList DtVrfManager::myTrackedObjects
protected
std::unique_ptr<DtCommandSpecBuilder> DtVrfManager::myCommandSpecBuilder = nullptr
protected
std::unique_ptr<DtScenarioManager> DtVrfManager::myScenarioManager = nullptr
protected
boost::signals2::connection DtVrfManager::myCurrentTaskChangedConnection
protected

Connection handle for DtRemoteControlCurrentTaskManager::signal_currentTaskChanged. Disconnected explicitly in shutdownVRFAPI() to avoid dangling callbacks into a partially-torn-down DtVrfManager.

DtRoleSpotReportPerspectiveManager DtVrfManager::myRoleSpotReportPerspectiveMgr
protected

Manages one DtSpotReportByForceAndUuidPerspective per role that is configured to receive contact reports. Accessed only from the VRF update thread.

std::unique_ptr<DtWebServerSubordinateResolver> DtVrfManager::mySubordinateResolver
protected

Referenced by subordinateResolver().

uint64_t DtVrfManager::myCachedRoleDefinitionGeneration = UINT64_MAX
protected

Generation counter cached from DtRoleDefinitionStore::definitionGeneration(). Initialised to UINT64_MAX so that syncRoleSpotReportPerspectives() always performs a rebuild on the first tick.

DtCapableTaskRequester DtVrfManager::myCapableTaskRequester
protected

Referenced by capableTaskQueueSize().

std::unique_ptr<DtResourceCache> DtVrfManager::myResourceCache
protected
std::unique_ptr<DtSpotReportAutoEnabler> DtVrfManager::mySpotReportAutoEnabler
protected

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

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)