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

Classes

struct  DtCatalogEntry
 

Public Member Functions

 DtCommandSpecBuilder (DtScenarioManager &mgr, const std::string &configFilePath="")
 
 ~DtCommandSpecBuilder ()=default
 
Json::Value buildCommandSummaries (const std::vector< std::string > &filter={}) const
 
DtCommandSpecJobHandle buildCommandSpec (const std::string &commandType, const std::string &objectName="")
 
void tick ()
 
bool isHiddenCommand (const std::string &commandType) const
 
bool isHiddenRwCommand (const std::string &commandType) const
 
Json::Value buildRwCommandSpecsConfig () const
 
bool updateCommandSpecEntry (const std::string &commandType, const Json::Value &entry)
 

Protected Member Functions

std::shared_ptr
< DtCommandSpecJobBuilder > 
commandSpecJobFromOverrideFile (const std::string &commandType, const std::string &objectName) const
 
std::shared_ptr
< DtCommandSpecJobBuilder > 
commandSpecFromScriptedTaskMetaData (const std::string &commandType, const std::string &objectName) const
 
std::shared_ptr
< DtCommandSpecJobBuilder > 
commandSpecJobFromRwFactory (const std::string &commandType, const std::string &objectName) const
 

Private Member Functions

void initializeCatalog ()
 
void loadCommandSpecFile (const std::string &filePath)
 

Static Private Member Functions

static std::string groupFromMetaData (const DtScriptedTaskMetaData &metaData)
 
static DtCatalogEntry catalogEntryFromScriptedTaskMetaData (const DtScriptedTaskMetaData &metaData)
 
static DtCatalogEntry combineCatalogEntries (const DtCatalogEntry &a, const DtCatalogEntry &b)
 

Private Attributes

std::vector< DtCatalogEntry > myCatalog
 
std::unordered_map
< std::string, size_t > 
myCatalogIndex
 
std::unordered_map
< std::string, Json::Value > 
myCommandSpecOverrides
 
DtCustomParamBuilderRegistry myCustomParamRegistry
 
DtCatalogParamSpecBuilder myCatalogParamSpecBuilder
 
DtScriptedTaskParamSpecBuilder myParamSpecBuilder
 
DtRwCommandSpecBuilder myRwCommandSpecBuilder
 
DtRemoteControlScriptedTaskManager & myScriptedTaskManager
 
DtScenarioManager & myScenarioManager
 
std::unordered_set< std::string > myRwCommandTypes
 
std::unordered_set< std::string > myVisibleRwCommands
 
bool myCommandSpecFileWasLoaded = false
 
std::string myCommandSpecsFilePath
 
Json::Value myRawFileRoot
 
tbb::mutex myWriteMutex
 
std::vector< std::weak_ptr
< DtCommandSpecJobBuilder > > 
myPendingJobBuilders
 

Static Private Attributes

static constexpr int theSpecTimeoutMs = 5000
 

Constructor & Destructor Documentation

DtCommandSpecBuilder::DtCommandSpecBuilder ( DtScenarioManager &  mgr,
const std::string &  configFilePath = "" 
)
explicit

configFilePath — path to an optional JSON file that may override or supplement the built-in command catalog. Pass an empty string to skip file loading entirely. scriptedTaskManager — optional pointer to the scripted task manager used to build specs from DtScriptedTaskMetaData. May be null if the scripted task system is not available.

DtCommandSpecBuilder::~DtCommandSpecBuilder ( )
default

Member Function Documentation

Json::Value DtCommandSpecBuilder::buildCommandSummaries ( const std::vector< std::string > &  filter = {}) const

Returns a JSON array of lightweight command summaries. If filter is non-empty, only entries whose commandType appears in filter are returned (in filter order). Omit filter to retrieve all entries.

DtCommandSpecJobHandle DtCommandSpecBuilder::buildCommandSpec ( const std::string &  commandType,
const std::string &  objectName = "" 
)

Returns the full parameter spec for a single command type as a job handle. If objectName is non-empty and the command type has entity-specific parameters (e.g. weapon lists), the job may be pending until the VRF back-end responds. Call waitFor() on the returned handle to block until the spec is fully assembled, then read it via result(). If objectName is empty or the command type needs no async data, the returned job is already complete and waitFor() returns immediately. Returns a job whose result() is a null Json::Value if commandType is unknown.

void DtCommandSpecBuilder::tick ( )

Advances all pending DtCommandSpecJobBuilder instances: removes expired or completed jobs, then calls update() on the remaining ones. Call this once per simulation tick from the VRF tick thread.

bool DtCommandSpecBuilder::isHiddenCommand ( const std::string &  commandType) const

Returns true if commandType should be suppressed from the AvailableCommands list sent to web clients.

Scripted tasks: hidden when showInMenu() is false in the task metadata and its not overwritten in the commandSpec RW tasks/sets:

bool DtCommandSpecBuilder::isHiddenRwCommand ( const std::string &  commandType) const

Returns true if commandSpecs.json was loaded and the commandType is not listed there (or is listed with "hidden": true). When commandSpecs.json is absent, all RW tasks/sets are visible.

Json::Value DtCommandSpecBuilder::buildRwCommandSpecsConfig ( ) const

Returns a JSON array of all registered RW command types merged with any existing configuration from commandSpecs.json. Types not yet present in the file are returned with only CommandType and DisplayName populated. Intended for the configure web UI.

bool DtCommandSpecBuilder::updateCommandSpecEntry ( const std::string &  commandType,
const Json::Value &  entry 
)

Upserts the entry for commandType in the in-memory raw config and writes the updated commandSpecs.json to disk. The entire entry JSON is replaced (not field-patched). In-memory visibility and catalog state are updated atomically with the file write under myWriteMutex.

Returns
True on success; false if the path is unset or the file cannot be written (a warning is logged in that case).
std::shared_ptr<DtCommandSpecJobBuilder> DtCommandSpecBuilder::commandSpecJobFromOverrideFile ( const std::string &  commandType,
const std::string &  objectName 
) const
protected
std::shared_ptr<DtCommandSpecJobBuilder> DtCommandSpecBuilder::commandSpecFromScriptedTaskMetaData ( const std::string &  commandType,
const std::string &  objectName 
) const
protected
std::shared_ptr<DtCommandSpecJobBuilder> DtCommandSpecBuilder::commandSpecJobFromRwFactory ( const std::string &  commandType,
const std::string &  objectName 
) const
protected
void DtCommandSpecBuilder::initializeCatalog ( )
private
void DtCommandSpecBuilder::loadCommandSpecFile ( const std::string &  filePath)
private
static std::string DtCommandSpecBuilder::groupFromMetaData ( const DtScriptedTaskMetaData &  metaData)
staticprivate

Returns the group string extracted from the first menu location in metaData. The group is the text that precedes "/$(menutext)" in the location string (e.g. "Engagement/$(menutext)..." yields "Engagement"). Returns an empty string when no group can be determined.

static DtCatalogEntry DtCommandSpecBuilder::catalogEntryFromScriptedTaskMetaData ( const DtScriptedTaskMetaData &  metaData)
staticprivate

Extracts the summary catalog fields (CommandType, DisplayName, Group, Icon, Level) from scripted task metadata. This is the single canonical mapping used by both buildCommandSummaries and commandSpecFromScriptedTaskMetaData.

static DtCatalogEntry DtCommandSpecBuilder::combineCatalogEntries ( const DtCatalogEntry &  a,
const DtCatalogEntry &  b 
)
staticprivate

Combines two catalog entries into one, preferring non-empty fields from the first entry and falling back to the second entry when a field is empty. Used to merge scripted task metadata with commandSpecs.json overrides.

Member Data Documentation

std::vector<DtCatalogEntry> DtCommandSpecBuilder::myCatalog
private

Ordered catalog of all known command types and their display metadata.

std::unordered_map<std::string, size_t> DtCommandSpecBuilder::myCatalogIndex
private

Fast lookup from commandType string to index in myCatalog.

std::unordered_map<std::string, Json::Value> DtCommandSpecBuilder::myCommandSpecOverrides
private
DtCustomParamBuilderRegistry DtCommandSpecBuilder::myCustomParamRegistry
private
DtCatalogParamSpecBuilder DtCommandSpecBuilder::myCatalogParamSpecBuilder
private
DtScriptedTaskParamSpecBuilder DtCommandSpecBuilder::myParamSpecBuilder
private
DtRwCommandSpecBuilder DtCommandSpecBuilder::myRwCommandSpecBuilder
private
DtRemoteControlScriptedTaskManager& DtCommandSpecBuilder::myScriptedTaskManager
private
DtScenarioManager& DtCommandSpecBuilder::myScenarioManager
private
std::unordered_set<std::string> DtCommandSpecBuilder::myRwCommandTypes
private

Set of all RW task/set type strings registered in the VRF factory at construction time. Does not contain any scripted tasks, as they dont follow the same factory pattern.

std::unordered_set<std::string> DtCommandSpecBuilder::myVisibleRwCommands
private

Command types explicitly allowed by commandSpecs.json ("hidden" absent or false). Only populated when myCommandSpecFileWasLoaded is true. Can contain both RW and scripted tasks.

bool DtCommandSpecBuilder::myCommandSpecFileWasLoaded = false
private

True once a commandSpecs.json file has been successfully parsed.

std::string DtCommandSpecBuilder::myCommandSpecsFilePath
private

Path passed to the constructor; used for write-back by updateCommandSpecEntry.

Json::Value DtCommandSpecBuilder::myRawFileRoot
private

Entire parsed commandSpecs.json root. Pre-initialised to {"commands":[]} so that updateCommandSpecEntry can write a valid file even when no commandSpecs.json existed at startup.

tbb::mutex DtCommandSpecBuilder::myWriteMutex
mutableprivate

Serialises concurrent configure writes and the config read endpoint.

constexpr int DtCommandSpecBuilder::theSpecTimeoutMs = 5000
staticprivate

Timeout used when waiting for async command spec data.

std::vector<std::weak_ptr<DtCommandSpecJobBuilder> > DtCommandSpecBuilder::myPendingJobBuilders
private

Weak references to in-progress job builders. Only jobs that were not yet complete at creation time are tracked here. tick() prunes expired and completed entries and drives update() on the remainder.


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)