![]() |
VR-Forces Developer's Guide
|
DtScenarioDataManager — manages per-scenario data stored by the web server.
Each scenario gets its own sub-directory under a configured base directory. The sub-directory name is derived from the VRF scenario filename (path is stripped; only the base scenario key is used (e.g. "BombMission" for "BombMission.scnx"). A special "default" folder is used when no scenario is loaded.
Directory layout:
When a scenario is loaded, onScenarioChanged() re-initializes all scenario-scoped subsystems (currently DtRoleDefinitionStore and DtRoleAssignmentStore) to point at the correct data directory. If the scenario-specific folder does not exist, it is created immediately so new role data is saved under that scenario instead of in "default". If the scenario has no saved role definitions yet, both stores use the shared default definition/assignment data until the scenario is saved.
Note: a VRF scenario file literally named "default" (any extension) that would produce the key "default" is a known edge case and is not supported.
Thread safety: onScenarioChanged() is intended to be called from the VRF update thread via a DtVrfManager scenario-changed listener. initialize() must be called from main() before any background threads start.
Public Member Functions | |
| void | initialize (const std::string &scenariosBaseDir) |
| void | onScenarioChanged (const std::string &vrfScenarioPath, const std::string &terrainName) |
| std::string | currentScenarioFolder () const |
Static Public Member Functions | |
| static DtScenarioDataManager & | getInstance () |
Private Member Functions | |
| DtScenarioDataManager ()=default | |
Static Private Member Functions | |
| static std::string | extractFilename (const std::string &path) |
| static char | pathSep () |
Private Attributes | |
| std::string | myScenariosBaseDir |
| std::string | myCurrentScenarioFolder |
|
privatedefault |
|
static |
Returns the process-wide singleton instance.
| void DtScenarioDataManager::initialize | ( | const std::string & | scenariosBaseDir | ) |
Sets the base directory for scenario data and primes all subsystems with the "default" folder. Must be called from main() before background threads start, after DtRoleDefinitionStore is available.
| void DtScenarioDataManager::onScenarioChanged | ( | const std::string & | vrfScenarioPath, |
| const std::string & | terrainName | ||
| ) |
Called whenever the active VRF scenario or terrain changes.
| vrfScenarioPath | The full path to the scenario file as reported by VRF (e.g. "C:\\scenarios\\BombMission.scnx"), or an empty string when no scenario is loaded. |
| terrainName | The terrain name from VRF session status; empty when no terrain is loaded (i.e. no scenario of any kind is active). Re-initializes scenario-scoped subsystems using the scenario-specific data folder (or "default" when no scenario is loaded). When terrainName is empty, the active role configuration is cleared so that no roles are published. |
| std::string DtScenarioDataManager::currentScenarioFolder | ( | ) | const |
Returns the path to the currently active scenario data folder. Useful for diagnostics; empty until initialize() has been called.
|
staticprivate |
Returns the scenario key from a path (e.g. "BombMission" for "BombMission.scnx"). Returns an empty string if the path is empty.
|
staticprivate |
Returns the path separator character for the current platform.
|
private |
|
private |