12 #include <tbb/spin_rw_mutex.h>
13 #include <json/json.h>
57 void initialize(
const std::string& assignmentsDir);
66 std::string& outError)
const;
82 const std::string& description,
83 const std::string& scenarioName,
84 const std::string& definitionId,
85 const std::map<std::string, std::vector<std::string>>& assignments,
86 std::string& outError);
91 const std::string& description,
92 std::string& outError);
98 const std::string& username,
99 const std::vector<std::string>& roleNames,
100 std::string& outError);
107 const std::vector<std::string>& roleNames,
108 std::string& outError);
117 std::string& outError);
140 std::vector<std::string>
savedAssignments(
const std::string& username)
const;
154 static std::vector<std::string>
scanDirectory(
const std::string& dir);
162 std::string& outError);
167 std::string& outError);
174 std::map<std::string, DtAssignmentSetSummary>
myIndex;
std::string activeAssignmentDefinitionId() const
Returns the definitionId bound to the currently active assignment set, or empty string.
std::string assignmentId
Stable UUID for this saved assignment set.
Definition: roleAssignmentStore.h:18
std::string myAssignmentsDir
Definition: roleAssignmentStore.h:171
void initialize(const std::string &assignmentsDir)
Scans assignmentsDir for *.json saved assignment files and builds the index. Ensures a reserved "defa...
static bool writeAssignmentFile(const std::string &filePath, const Json::Value &root, std::string &outError)
Writes one assignment file to disk.
bool updateAssignmentSetDescription(const std::string &assignmentId, const std::string &description, std::string &outError)
Updates the saved assignment set description.
std::string myActiveDefinitionId
Definition: roleAssignmentStore.h:179
std::string myActiveSetName
Definition: roleAssignmentStore.h:177
static bool readAssignmentFile(const std::string &filePath, Json::Value &outRoot, std::string &outError)
Reads one assignment file from disk.
std::map< std::string, std::vector< std::string > > allSavedAssignments() const
Returns a copy of the complete username -> roleNames map for the active set. Returns an empty map if ...
std::map< std::string, std::vector< std::string > > myActiveAssignments
username -> roleNames
Definition: roleAssignmentStore.h:180
bool updateActiveAssignmentUserRoles(const std::string &username, const std::vector< std::string > &roleNames, std::string &outError)
Replaces one user's role list within the currently active assignment set in memory. Passing an empty roleNames vector removes the user entry. Changes are not persisted to disk until saveActiveAssignmentSet() is called.
std::map< std::string, std::string > myIdToFilePath
assignmentId -> absolute file path
Definition: roleAssignmentStore.h:172
std::vector< std::string > savedAssignments(const std::string &username) const
Returns the role names saved for the given username in the active assignment set. Returns an empty ve...
std::string scenarioName
Value of the "scenarioName" field (informational).
Definition: roleAssignmentStore.h:21
std::string description
Optional description.
Definition: roleAssignmentStore.h:20
static std::string generateUuid()
Generates a random UUID in 8-4-4-4-12 lowercase hex format.
DtRoleAssignmentStore — process-wide singleton for saved username-to-role assignments.
Definition: roleAssignmentStore.h:47
std::map< std::string, std::string > myNameToId
name -> assignmentId
Definition: roleAssignmentStore.h:173
tbb::spin_rw_mutex myMutex
Definition: roleAssignmentStore.h:169
Summary information for one saved assignment set file.
Definition: roleAssignmentStore.h:16
std::string definitionId
DefinitionId this assignment set is bound to.
Definition: roleAssignmentStore.h:22
std::vector< DtAssignmentSetSummary > listAssignmentSets() const
Returns summary information for all available assignment set files.
DtRoleAssignmentStore()=default
IMGUI_API void Value(const char *prefix, bool b)
std::string activeAssignmentSetName() const
Returns the name of the currently active assignment set, or an empty string if none.
std::atomic< uint64_t > myAssignmentGeneration
Definition: roleAssignmentStore.h:182
uint64_t assignmentGeneration() const
Monotonically increasing counter incremented whenever assignment metadata or active-assignment state ...
static std::vector< std::string > scanDirectory(const std::string &dir)
Returns full file paths for every *.json file found directly in dir.
std::string myActiveSetDescription
Definition: roleAssignmentStore.h:178
void clearActiveAssignment()
Activates the reserved "default" assignment set and cached mapping.
bool loadAssignmentSet(const std::string &name)
Loads and activates the named assignment set. Replaces any previously active set. Compatibility helpe...
std::string myActiveSetId
Definition: roleAssignmentStore.h:176
bool saveActiveAssignmentSet(const std::map< std::string, std::vector< std::string >> &assignments, std::string &outError)
Saves (overwrites) the active assignment set's username -> roleNames map.
static DtRoleAssignmentStore & getInstance()
Returns the process-wide singleton instance.
std::string createAssignmentSet(const std::string &name, const std::string &description, const std::string &scenarioName, const std::string &definitionId, const std::map< std::string, std::vector< std::string >> &assignments, std::string &outError)
Creates a new saved assignment set and activates it.
bool updateAssignmentSetUserRoles(const std::string &assignmentId, const std::string &username, const std::vector< std::string > &roleNames, std::string &outError)
Replaces one user's role list within a saved assignment set. Passing an empty roleNames vector remove...
bool deleteAssignmentSet(const std::string &assignmentId, std::string &outError)
Deletes a saved assignment set by stable assignmentId.
std::string activeAssignmentSetDescription() const
Returns the description of the currently active assignment set, or empty string.
std::string name
Value of the "name" field in the file.
Definition: roleAssignmentStore.h:19
bool loadAssignmentSetById(const std::string &assignmentId, std::string &outError)
Loads and activates the assignment set by stable assignmentId. Replaces any previously active set...
bool getAssignmentSetById(const std::string &assignmentId, Json::Value &outJson, std::string &outError) const
Reads and returns one saved assignment set by stable assignmentId.
std::map< std::string, DtAssignmentSetSummary > myIndex
assignmentId -> summary
Definition: roleAssignmentStore.h:174
std::string activeAssignmentSetId() const
Returns the stable assignmentId of the currently active set, or empty string if none.