Banking_System_Server  1.0.0
Qt-based banking app for user/admin account management, transactions, secure server communication via PostgreSQL/Supabase.
RequestManager Class Reference

The RequestManager class handles incoming requests and dispatches them to the appropriate request handler. More...

#include <RequestManager.h>

Collaboration diagram for RequestManager:
Collaboration graph

Public Types

enum  AvailableRequests {
  Login = 1 , GetAccountnumber , GetBalance , GetTransactionsHistory ,
  MakeTransaction , TransferAmount , GetDatabase , CreateNewUser ,
  DeleteUser , UpdateUser , UserInit , UpdateEmail ,
  UpdatePassword , JsonParseError = -1
}
 Enum representing the different types of requests handled by the RequestManager. More...
 

Public Member Functions

 RequestManager (QMutex *Mutex)
 Constructs a RequestManager with the specified mutex for thread safety. More...
 
QByteArray makeRequest (QByteArray data)
 Processes an incoming request and generates an appropriate response. More...
 
 ~RequestManager ()
 Destructor for the RequestManager. More...
 

Detailed Description

The RequestManager class handles incoming requests and dispatches them to the appropriate request handler.

The RequestManager class is responsible for managing and processing different types of requests. It maintains a map of request handlers for various request types, processes incoming request data, and generates appropriate responses. The class also includes error handling for JSON parsing issues.

Member Enumeration Documentation

◆ AvailableRequests

Enum representing the different types of requests handled by the RequestManager.

This enum defines various request types and special requests that the RequestManager can handle.

Enumerator
Login 

Request for user login.

GetAccountnumber 

Request to retrieve account number.

GetBalance 

Request to get account balance.

GetTransactionsHistory 

Request to retrieve transaction history.

MakeTransaction 

Request to make a transaction.

TransferAmount 

Request to transfer amount (not used currently).

GetDatabase 

Request to get database information.

CreateNewUser 

Request to create a new user.

DeleteUser 

Request to delete a user.

UpdateUser 

Request to update user information.

UserInit 

Special request for user initialization.

UpdateEmail 

Special request to update user email.

UpdatePassword 

Special request to update user password.

JsonParseError 

Special error code for JSON parsing errors.

Constructor & Destructor Documentation

◆ RequestManager()

RequestManager::RequestManager ( QMutex *  Mutex)
inline

Constructs a RequestManager with the specified mutex for thread safety.

Parameters
MutexA pointer to a QMutex used to ensure thread-safe operations.

◆ ~RequestManager()

RequestManager::~RequestManager ( )
inline

Destructor for the RequestManager.

Cleans up any resources allocated by the RequestManager.

Member Function Documentation

◆ makeRequest()

QByteArray RequestManager::makeRequest ( QByteArray  data)
inline

Processes an incoming request and generates an appropriate response.

Parameters
dataA QByteArray containing the request data in JSON format.
Returns
A QByteArray containing the response data in JSON format.

This method parses the incoming JSON data, determines the type of request, and delegates the processing to the corresponding request handler. It also handles JSON parsing errors and generates error responses if needed.

Referenced by ServerHandler::readyRead().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: