|
VR-Engage
2.3
|
DtVreAssignmentTracker provides a unified view of VR-Engage station assignments, combining confirmed assignments from DtVreStatusListener with pending user edits. It serves as the single source of truth for the Manager Panel UI, providing query methods for displaying assignment state and tracking conflicts when pending assignments would displace existing stations.
#include <vreAssignmentTracker.h>
Classes | |
| struct | PendingAssignment |
Signals | |
| void | assignmentStateChanged () |
| void | stationAdded (std::string stationId) |
| void | stationRemoved (std::string stationId) |
| void | stationAssignmentChanged (std::string stationId) |
Public Member Functions | |
| DtVreAssignmentTracker (DtVreStatusListener &statusListener, QObject *parent=nullptr) | |
| virtual | ~DtVreAssignmentTracker () override |
Pending Assignment Management | |
Methods for creating and clearing pending (uncommitted) assignments. | |
| virtual void | setPendingAssignment (std::string stationId, const DtUUID &entityUUID, const std::string &roleName, bool spectatorMode=false) |
| virtual void | setPendingSpectatorMode (std::string stationId, bool spectatorMode) |
| virtual void | setPendingUnassignment (std::string stationId) |
| virtual void | clearPendingAssignment (std::string stationId) |
| virtual void | clearAllPendingAssignments () |
Query Methods | |
Methods for querying assignment state for UI display. | |
| virtual std::vector< std::string > | getAssignedStations (const DtUUID &entityUUID, const std::string &roleName, bool includePending=true) const |
| virtual std::vector< DtRoleAssignment > | getRoleAssignments (const DtUUID &entityUUID, const std::vector< std::string > &availableRoles) const |
| virtual bool | getStationAssignment (std::string stationId, DtUUID &entityUUID, std::string &roleName, bool &isPending) const |
| virtual bool | hasConflict (std::string stationId) const |
| virtual bool | hasUnresolvedConflicts () const |
| virtual int | getConflictCount () const |
| virtual std::vector< std::string > | getStationsToUnassign () const |
| virtual std::vector< DtPendingAssignmentInfo > | getPendingAssignments () const |
| virtual std::vector< std::string > | getPendingUnassignments () const |
| virtual bool | hasPendingUnassignment (std::string stationId) const |
| virtual DtUUID | getStationEntityUUID (std::string stationId) const |
| virtual std::string | getStationRoleName (std::string stationId) const |
| virtual void | getPendingCounts (int &pendingCount, int &conflictCount) const |
| virtual std::string | getStationName (std::string stationId) const |
| virtual std::string | getStationObjectName (std::string stationId) const |
| virtual bool | isStationSpectator (std::string stationId) const |
| virtual void | setSpectatorPreference (std::string stationId, bool spectatorMode) |
Summary Queries | |
Methods for getting aggregate information about assignments. | |
| virtual int | getAssignedRoleCount (const DtUUID &entityUUID, const std::vector< std::string > &availableRoles) const |
| virtual int | getUnassignedStationCount () const |
| virtual int | getTotalStationCount () const |
| virtual bool | hasPendingChanges () const |
| virtual std::vector< std::string > | getAllStationIds () const |
| virtual bool | isPlaceholderStation (std::string stationId) const |
| virtual std::vector< std::string > | getPlaceholderStationIds () const |
| virtual std::vector< DtPersistedAssignmentRecord > | exportAssignmentsForPersistence () const |
| virtual bool | importAssignmentsForPersistence (const std::vector< DtPersistedAssignmentRecord > &records, const std::function< bool(const DtUUID &)> &entityExists, std::vector< std::string > &warnings, std::string &errorText) |
Static Protected Member Functions | |
Callback Handlers | |
Static callbacks registered with DtVreStatusListener. | |
| static void | onStationAdded (const std::string &id, void *userData) |
| static void | onStationRemoved (const std::string &id, void *userData) |
| static void | onStationChanged (const std::string &id, void *userData) |
Protected Attributes | |
| DtVreStatusListener & | myStatusListener |
| std::map< std::string, PendingAssignment > | myPendingAssignments |
| std::set< std::string > | myPendingUnassignments |
| std::set< std::string > | myRemovedStationIds |
| std::map< std::string, bool > | mySpectatorPreferences |
| unsigned int | myNextPlaceholderStationId = 1 |
| std::map< std::string, DtPlaceholderStation > | myPlaceholderStations |
| std::map< std::string, std::string > | myPlaceholderIdsByName |
Static Protected Attributes | |
| static constexpr const char * | thePlaceholderStationIdPrefix = "PLACE_HOLDER_BASE_" |
Private Member Functions | |
| std::string | allocatePlaceholderStationId () |
| std::string | ensurePlaceholderStation (const DtPersistedAssignmentRecord &record) |
| bool | findLiveStationIdByName (const std::string &stationName, std::string &stationId) const |
| void | wakePlaceholderForLiveStation (std::string liveStationId) |
| void | removePlaceholderStation (std::string stationId) |
| DtVreAssignmentTracker (const DtVreAssignmentTracker &)=delete | |
| DtVreAssignmentTracker & | operator= (const DtVreAssignmentTracker &)=delete |
| makVre::DtVreAssignmentTracker::DtVreAssignmentTracker | ( | DtVreStatusListener & | statusListener, |
| QObject * | parent = nullptr ) |
Constructor.
| statusListener | Reference to the status listener for confirmed assignments |
| parent | Optional parent QObject for Qt memory management |
Creates a tracker that monitors the given status listener for confirmed assignment state. Registers callbacks with the listener to receive notifications when stations are added, removed, or changed.
Referenced by DtVreAssignmentTracker(), and operator=().
|
overridevirtual |
Destructor.
Unregisters callbacks from the status listener.
|
privatedelete |
Copy constructor (deleted)
References DtVreAssignmentTracker().
|
virtual |
Sets a pending assignment for a station.
| stationId | The station ID to assign |
| entityUUID | The entity UUID to assign to |
| roleName | The role name to assign (e.g., "driver", "gunner") |
| spectatorMode | Whether spectator mode should be enabled |
Creates or updates a pending assignment for the specified station. Multiple pending assignments to the same entity+role are allowed. This may create a conflict (2+ non-spectator on same role) that the user must resolve before submitting.
Emits assignmentStateChanged() after updating state.
|
virtual |
Toggles spectator mode on an existing pending assignment.
| stationId | The station ID with the pending assignment |
| spectatorMode | True for spectator, false for normal |
Changes the spectator flag on an existing pending assignment. Has no effect if the station has no pending assignment.
Emits assignmentStateChanged() if the flag was changed.
|
virtual |
Sets a pending unassignment for a station.
| stationId | The station ID to mark for unassignment |
Marks a station with a confirmed assignment for unassignment. On submit, DtIfUnassignRolePlayer is sent to this station. If the station has a pending assignment, it is cleared first.
Emits assignmentStateChanged() after updating state.
|
virtual |
Clears the pending assignment or unassignment for a station.
| stationId | The station ID to clear |
Removes any pending assignment or pending unassignment for the specified station, returning it to its confirmed state. Has no effect if the station has no pending state.
Emits assignmentStateChanged() if state was changed.
|
virtual |
Clears all pending assignments.
Removes all pending assignments, returning all stations to their confirmed state. Typically called after Submit to clear the pending state, or on Revert to discard user edits.
Emits assignmentStateChanged() if any state was changed.
|
virtual |
Gets all stations assigned to a specific role.
| entityUUID | The entity UUID |
| roleName | The role name |
| includePending | If true, includes pending assignments in results |
Returns confirmed station assignments, optionally merged with pending assignments. When includePending is true, pending assignments replace any confirmed assignment for the same station.
|
virtual |
Gets role assignment information for all roles on an entity.
| entityUUID | The entity UUID |
| availableRoles | List of available role names for this entity |
Returns complete assignment information for each role, suitable for populating the entity/role tree view. Each DtRoleAssignment contains both confirmed and pending state, plus conflict indicators.
|
virtual |
Gets the current assignment for a station.
| stationId | The station ID to query |
| entityUUID | Output parameter for entity UUID |
| roleName | Output parameter for role name |
| isPending | Output parameter indicating if assignment is pending |
Returns the effective assignment for a station, preferring pending state over confirmed state when both exist.
|
virtual |
Checks if a station is part of an unresolved conflict (2+ non-spectator stations on the same entity+role)
| stationId | The station ID to check |
|
virtual |
Checks if any entity+role has 2+ non-spectator stations When true, the Submit button is disabled.
|
virtual |
Returns the number of roles with unresolved conflicts.
|
virtual |
Returns confirmed stations that will be unassigned on submit.
Returns confirmed non-spectator stations whose role is being taken by a pending assignment from a different station. Excludes stations that have their own pending reassignment to another role. Excludes spectator stations.
|
virtual |
Gets all pending assignments for submit iteration.
Returns all pending assignments in a form suitable for sending DtIfAssignRolePlayer messages during submit. Does not include pending unassignments (use getPendingUnassignments() for those).
|
virtual |
Gets all stations with pending unassignments.
Returns station IDs that the user explicitly marked for unassignment. On submit, DtIfUnassignRolePlayer is sent to each.
|
virtual |
Checks if a station has a pending unassignment.
| stationId | The station ID to check |
|
virtual |
Gets the confirmed entity UUID for a station.
| stationId | The station ID |
Returns only the confirmed (not pending) entity UUID. Used to construct unassign messages for displaced stations.
|
virtual |
Gets the confirmed role name for a station.
| stationId | The station ID |
Returns only the confirmed (not pending) role name.
|
virtual |
Gets counts of pending changes and conflicts.
| pendingCount | Output for total pending assignment count |
| conflictCount | Output for count of entity+role pairs with unresolved conflicts |
Provides summary counts for the Submit button display.
|
virtual |
Gets the display name for a station.
| stationId | The station ID |
|
virtual |
Gets the saved entity object name for an offline placeholder station.
| stationId | The station ID |
Offline placeholders carry the entity's object name from the saved layout so the station card can label the assignment without depending on the entity UUID round-tripping (a bare-hex UUID from an older save does not reconstruct to a valid DtUUID and cannot be resolved to a name).
|
virtual |
Gets whether a station is in spectator mode.
| stationId | The station ID to query |
Returns the effective spectator mode for a station. Checks in order:
|
virtual |
Sets the spectator mode preference for a station.
| stationId | The station ID |
| spectatorMode | True for spectator, false for normal |
Records a spectator preference that will be applied when a pending assignment is created for this station. This allows the user to pre-select spectator mode before choosing an entity/role. If the station already has a pending assignment, its spectator flag is updated in place.
Emits assignmentStateChanged() if the effective state changed.
|
virtual |
Gets count of assigned roles for an entity.
| entityUUID | The entity UUID |
| availableRoles | List of available role names |
Counts roles with either confirmed or pending assignments. Used for the entity badge display (e.g., "2/3").
|
virtual |
Gets count of unassigned stations.
|
virtual |
Gets total station count.
|
virtual |
Checks if there are any pending changes.
|
virtual |
Gets all station IDs.
Returns the IDs of all stations known to the status listener. Used by the station list model to populate its list.
|
virtual |
Checks if a station ID is a synthetic placeholder.
|
virtual |
Returns all synthetic placeholder station IDs.
|
virtual |
Exports the effective assignment snapshot for persistence.
Returns name-based records from the merged confirmed+pending view, excluding stations with pending unassignment.
|
virtual |
Imports saved assignments as pending state.
For each record, if a live station with the saved name exists, creates a pending assignment on that station. Otherwise creates a placeholder. Records whose entity UUID fails the entityExists callback are skipped with a warning appended to warnings.
Existing pending assignments and placeholders are cleared before import.
Records whose entity UUID is not currently in the exercise are still imported as placeholder stations so the assignments are ready when the entity and station appear later. This makes the function safe to call before a scenario is loaded.
| records | The saved assignment records to import. |
| entityExists | Callback that returns true if an entity UUID is currently in the exercise. Used only for informational logging; a false result does not prevent the record from being imported. |
| warnings | Receives non-fatal informational messages. |
| errorText | Receives a fatal error string; import is aborted when non-empty. |
|
signal |
Emitted when any assignment state changes.
Emitted when pending assignments are added, cleared, or when confirmed state changes from the status listener. UI should refresh display when this signal is received.
|
signal |
Emitted when a station is added.
| stationId | The new station ID |
|
signal |
Emitted when a station is removed.
| stationId | The removed station ID |
|
signal |
Emitted when a station's confirmed assignment changes.
| stationId | The station ID |
|
staticprotected |
Callback invoked when a station is added to the listener.
| id | The station ID |
| userData | Pointer to the DtVreAssignmentTracker instance |
|
staticprotected |
Callback invoked when a station is removed from the listener.
| id | The station ID |
| userData | Pointer to the DtVreAssignmentTracker instance |
|
staticprotected |
Callback invoked when a station's confirmed state changes.
| id | The station ID |
| userData | Pointer to the DtVreAssignmentTracker instance |
|
private |
|
private |
|
private |
|
private |
|
private |
|
privatedelete |
Assignment operator (deleted)
References DtVreAssignmentTracker().
|
protected |
Reference to status listener for confirmed assignments.
|
protected |
Map of station ID to pending assignment.
Contains only stations with pending (uncommitted) assignments. Stations not in this map use their confirmed state from the listener.
|
protected |
Set of station IDs with pending unassignments.
Contains station IDs that the user explicitly marked for unassignment. These stations currently have confirmed assignments that will be removed when the user clicks Submit.
|
protected |
Station IDs that have been removed but may still be in the listener's map.
Handles the case where the removed callback fires before the listener erases the station from its map. Cleared on the next stationAdded call.
|
protected |
Map of station ID to pre-assignment spectator preference.
Stores spectator mode preferences for stations that do not yet have a pending or confirmed assignment. When a pending assignment is later created for a station with a preference, the preference is applied automatically. Cleared alongside pending state by clearAllPendingAssignments() / importAssignmentsForPersistence() and pruned per-station on station removal.
|
staticconstexprprotected |
Prefix for synthetic placeholder station IDs.
Placeholder IDs are allocated in a reserved string namespace so they can be distinguished from live station IDs while remaining valid string IDs.
|
protected |
Next synthetic placeholder ID suffix to allocate.
|
protected |
Map of placeholder station ID to placeholder data.
|
protected |
Map of station name to placeholder station ID for quick lookup.