Operating System Simulator Plugin
3.5.1
Unreal Engine plugin that simulates an Operating System Environment
|
Manager class for operating system users. More...
#include "OperatingSystemUserManager.h"
Public Member Functions | |
UOperatingSystemUserManager () | |
OPERATINGSYSTEMSIMULATOR_API bool | FindUserByEmail (const FText &TestEmail, FOperatingSystemUser &OutUser) |
OPERATINGSYSTEMSIMULATOR_API bool | FindUserByUsername (const FText &TestUsername, FOperatingSystemUser &OutUser) |
OPERATINGSYSTEMSIMULATOR_API bool | CheckUserExistForOperatingSystem (const UOperatingSystem *TargetOS, const FOperatingSystemUser &TestUser, const bool bCheckByUsernameOnly) const |
OPERATINGSYSTEMSIMULATOR_API bool | CheckUserExist (const FOperatingSystemUser &TestUser, const bool bCheckByUsernameOnly) const |
OPERATINGSYSTEMSIMULATOR_API bool | HasUsers () const |
OPERATINGSYSTEMSIMULATOR_API bool | AuthorizeUser (const FText &Email, const FText &Password, FOperatingSystemUser &OutAuthorizedUser) |
OPERATINGSYSTEMSIMULATOR_API void | GetAllUsers (TArray< FOperatingSystemUser > &OutUsers) const |
OPERATINGSYSTEMSIMULATOR_API bool | CreateGenericUser (const FOperatingSystemUser &NewUser) |
OPERATINGSYSTEMSIMULATOR_API bool | CreateNewUser (UOperatingSystem *TargetOS, const FOperatingSystemUser &NewUser) |
Create a new user in the operating system. | |
OPERATINGSYSTEMSIMULATOR_API TSet< FOperatingSystemUser > | GetAllUsersForOS (const UOperatingSystem *TargetOS) const |
Retrieves all the users for a given operating system. | |
OPERATINGSYSTEMSIMULATOR_API bool | UpdateUserDetails (UPARAM(ref) FOperatingSystemUser &TargetUser, const FOperatingSystemUser &UpdatedDetails) |
OPERATINGSYSTEMSIMULATOR_API void | ForEachUserInOS (const UOperatingSystem *TargetOS, const TFunctionRef< bool(const FOperatingSystemUser &)> Func) const |
OPERATINGSYSTEMSIMULATOR_API void | ForEachUserInOS (const UOperatingSystem *TargetOS, const TFunctionRef< bool(FOperatingSystemUser &)> Func) |
OPERATINGSYSTEMSIMULATOR_API void | ForEachUser (const TFunctionRef< bool(const FOperatingSystemUser &)> &Func) const |
OPERATINGSYSTEMSIMULATOR_API void | ForEachUser (const TFunctionRef< bool(FOperatingSystemUser &)> &Func) |
Static Public Member Functions | |
static UOperatingSystemUserManager * | CreateUserManager () |
Create a new instance of the User Manager class. It checks if a save game file exists and loads it if found. If not, it creates a new instance and returns it. | |
static UOperatingSystemUserManager * | GetUserManager (const UObject *WorldContextObject) |
Returns the user manager instance associated with the given WorldContextObject. | |
static OPERATINGSYSTEMSIMULATOR_API FString | GetUserKey (const UOperatingSystem *TargetOS) |
Retrieves the user key for the specified operating system. | |
Protected Member Functions | |
void | K2_OnUserCreated (const FOperatingSystemUser &CreatedUser) |
Blueprint implementable event called when a user is created. | |
void | K2_OnUserUpdated (UPARAM(ref) FOperatingSystemUser &TargetUser, const FOperatingSystemUser &UpdatedDetails) |
BlueprintImplementableEvent called when a user's details are updated. The updated user details are provided as input parameters. | |
Protected Attributes | |
TMap< FString, FOperatingSystemUserManagerSaveData > | Users |
Manager class for operating system users.
This class manages the creation, retrieval, and modification of users in an operating system. It provides various methods for finding users, checking user existence, authorizing users, and performing user operations. Users are stored in a mapping structure where the key is the user's email and the value is the user's data. The class inherits from USaveGame to enable saving and loading of user data.
UOperatingSystemUserManager::UOperatingSystemUserManager | ( | ) |
bool UOperatingSystemUserManager::AuthorizeUser | ( | const FText & | Email, |
const FText & | Password, | ||
FOperatingSystemUser & | OutAuthorizedUser ) |
Authorizes a user by comparing the provided email and password with the stored user data.
The email of the user to authorize. | |
Password | The password of the user to authorize. |
OutAuthorizedUser | The authorized user object if the authorization is successful. |
bool UOperatingSystemUserManager::CheckUserExist | ( | const FOperatingSystemUser & | TestUser, |
const bool | bCheckByUsernameOnly ) const |
Checks if a user exists in the operating system user manager. It can be used to verify if a user already exists before performing any operations related to user management.
TestUser | The user to check for existence. |
bCheckByUsernameOnly | Specifies whether to perform the existence check based on username only. Set to true to perform the check based on username only, or false to perform full user comparison. |
bool UOperatingSystemUserManager::CheckUserExistForOperatingSystem | ( | const UOperatingSystem * | TargetOS, |
const FOperatingSystemUser & | TestUser, | ||
const bool | bCheckByUsernameOnly ) const |
Check if a user exists for the given operating system.
This method checks if the specified user exists for the specified operating system.
TargetOS | The target operating system to check for user existence. |
TestUser | The user object to compare against the operating system users. |
bCheckByUsernameOnly | Flag indicating if the check should only be performed based on username. If this flag is true, the method will only check if the username of the TestUser matches any of the usernames in the operating system users. If this flag is false, the method will compare the entire TestUser object with each operating system user to determine if a match exists. |
bool UOperatingSystemUserManager::CreateGenericUser | ( | const FOperatingSystemUser & | NewUser | ) |
Creates a generic user in the operating system user manager.
NewUser | The operating system user to create. |
bool UOperatingSystemUserManager::CreateNewUser | ( | UOperatingSystem * | TargetOS, |
const FOperatingSystemUser & | NewUser ) |
Create a new user in the operating system.
This method creates a new user in the specified operating system.
TargetOS | The operating system in which to create the user. |
NewUser | The user data of the new user. |
|
static |
Create a new instance of the User Manager class. It checks if a save game file exists and loads it if found. If not, it creates a new instance and returns it.
bool UOperatingSystemUserManager::FindUserByEmail | ( | const FText & | TestEmail, |
FOperatingSystemUser & | OutUser ) |
Finds a user by email.
Searches for a user with the specified email and retrieves their information. If the email is empty or whitespace, an error will be logged and the method will return false. If the email matches the default email for the "No Reply" user, the "No Reply" user information will be returned. If a user with the specified email is found, their information will be stored in the OutUser parameter. If the found user's color is invalid, it will be updated and saved to the database.
TestEmail | The email to search for. |
OutUser | [out] The user information if found. |
bool UOperatingSystemUserManager::FindUserByUsername | ( | const FText & | TestUsername, |
FOperatingSystemUser & | OutUser ) |
Finds a user by their username.
This method searches for a user with the given username and populates the provided FOperatingSystemUser object with the found user's details.
TestUsername | The username to search for. |
OutUser | The FOperatingSystemUser object to populate with the found user's details. |
void UOperatingSystemUserManager::ForEachUser | ( | const TFunctionRef< bool(const FOperatingSystemUser &)> & | Func | ) | const |
Applies a given function to each user in the operating system user manager.
The function receives a constant reference to an FOperatingSystemUser object and must return a boolean value. If the function returns true, the loop is stopped and no further users are processed.
Func | A TFunctionRef object that represents the function to be applied to each user. |
void UOperatingSystemUserManager::ForEachUser | ( | const TFunctionRef< bool(FOperatingSystemUser &)> & | Func | ) |
Executes a lambda function for each user in the operating system user manager.
This method iterates over each user in the operating system user manager and executes the provided lambda function for each user. The lambda function should take a reference to an FOperatingSystemUser object as a parameter and return a boolean value indicating whether the iteration should stop or continue.
Func | A lambda function that takes a reference to an FOperatingSystemUser object as a parameter and returns a boolean value. |
void UOperatingSystemUserManager::ForEachUserInOS | ( | const UOperatingSystem * | TargetOS, |
const TFunctionRef< bool(const FOperatingSystemUser &)> | Func ) const |
Executes a given function for each user in the specified operating system.
TargetOS | The operating system for which the function should be executed. |
Func | The function to be executed for each user. It should accept a constant reference to an FOperatingSystemUser object and return a bool value. |
void UOperatingSystemUserManager::ForEachUserInOS | ( | const UOperatingSystem * | TargetOS, |
const TFunctionRef< bool(FOperatingSystemUser &)> | Func ) |
Iterates over each user in the given operating system and calls the provided function on each user. If the function returns true, the iteration stops.
TargetOS | The target operating system to iterate users on. |
Func | The function to call on each user. It should take an FOperatingSystemUser reference as input and return a boolean value indicating whether to stop the iteration. |
void UOperatingSystemUserManager::GetAllUsers | ( | TArray< FOperatingSystemUser > & | OutUsers | ) | const |
Retrieves all the operating system users managed by this user manager.
This method populates the provided array OutUsers
with the operating system users. The array OutUsers
is cleared and then filled with the operating system users managed by this user manager. The method does not return any values.
OutUsers | The array to be populated with the operating system users. |
TSet< FOperatingSystemUser > UOperatingSystemUserManager::GetAllUsersForOS | ( | const UOperatingSystem * | TargetOS | ) | const |
Retrieves all the users for a given operating system.
This method returns a set of operating system users associated with the specified operating system.
TargetOS | The operating system for which to retrieve the users. |
|
static |
Retrieves the user key for the specified operating system.
This method returns a unique identifier that represents the user associated with the given operating system.
TargetOS | The pointer to the operating system to retrieve the user key for. |
|
static |
Returns the user manager instance associated with the given WorldContextObject.
WorldContextObject | The world context object used to retrieve the user manager. |
bool UOperatingSystemUserManager::HasUsers | ( | ) | const |
Checks if there are any users.
|
protected |
Blueprint implementable event called when a user is created.
This event is called when a user is created in the OperatingSystemUserManager class. It passes the created user as a parameter.
CreatedUser | The user that was created. |
|
protected |
BlueprintImplementableEvent called when a user's details are updated. The updated user details are provided as input parameters.
TargetUser | The user object being updated. Passed by reference to allow modifications. |
UpdatedDetails | The new user details to be applied. |
bool UOperatingSystemUserManager::UpdateUserDetails | ( | UPARAM(ref) FOperatingSystemUser & | TargetUser, |
const FOperatingSystemUser & | UpdatedDetails ) |
public UOperatingSystemUserManager::UpdateUserDetails Updates the details for the given user. If you don't want specific data to change, simply leave them empty or null.
TargetUser | User to update |
UpdatedDetails | Details to update. If a setting is null or empty, it is not updated |
|
protected |
This map associates user names (as strings) with their respective save data (as FOperatingSystemUserManagerSaveData objects).