-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.h
More file actions
76 lines (69 loc) · 3.17 KB
/
Bank.h
File metadata and controls
76 lines (69 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// Created by Luca Teodorescu on 20.03.2026.
//
#ifndef PROJECT_OOP_BANK_H
#define PROJECT_OOP_BANK_H
#include <iostream>
#include <map>
#include <vector>
#include <thread>
#include <atomic>
#include <unordered_set>
#include <mutex>
#include <set>
#include "Account.h"
#include "ExchangeBuffer.h"
#include "AuditBuffer.h"
#include "User.h"
using namespace std;
struct Currency {
string first_currency, second_currency;
bool operator<(const Currency &other) const{
if (first_currency != other.first_currency) {
return first_currency < other.first_currency;
}
return second_currency < other.second_currency;
}
};
class Bank {
struct AuditEdge {
std::string receiverCNP;
double amount;
};
map<string, User*> AllUsers;
map<Currency, double> ExchangeRates;
map<string, unordered_set<User*>> GraphUsers;
map<AuditBuffer::USER, bool> TransferVerification;
ExchangeBuffer exchangeBuffer;
AuditBuffer auditBuffer;
thread rateUpdateThread;
std::thread auditThread;
std::map<std::string, std::vector<AuditEdge>> TransactionGraph;
std::mutex graphMutex;
void BackgroundAuditConsumer();
atomic<bool> running{true};
void BackgroundFetcher();
public:
Bank();
~Bank();
void RefreshRates();
void CreateUser(const string &FirstName, const string &LastName, const string &CNP, const string &BirthDate);
void CreateUser(const string &FirstName, const string &LastName, const string &CNP, const string &BirthDate, const string ¤cy);
void DeleteUser(const string &FirstName, const string &LastName, const string &CNP);
void CreateAccount(const string &CNP, const string ¤cy);
void DeleteAccount(const string &CNP, const string &IBAN);
void CreateWallet(const string &FirstName, const string &LastName, const string &CNP, const string &BirthDate, const string &IBAN);
void DeleteWallet(const string &CNP, const string &IBAN, const string &WalletID);
bool Deposit(const string &CNP, const string &IBAN, const string &WalletID, const double &amount, const string ¤cy);
bool Withdraw(const string &CNP, const string &IBAN, const string &WalletID, const double &amount, const string ¤cy);
void ChangeExchangeRates(const string &first_currency, const string &second_currency, const double &amount);
double GetExchangeRates(const string &first_currency, const string &second_currency);
void Transfer(const string &Send_CNP, const string &Receive_CNP, const string &Send_IBAN, const string &Receive_IBAN, const string &Send_WalletID, const string &Receive_WalletID, const double &amount, const string ¤cy);
void SendFriendInvitation(const string &Send_CNP, const string &Receive_CNP);
void AcceptFriendInvitation(const string &Send_CNP, const string &Receive_CNP);
void DeleteFriend(const string &Send_CNP, const string &Receive_CNP);
bool VerifyTransaction(const AuditBuffer::USER &userAudit);
void AddTransferVerification(const AuditBuffer::USER &userAudit, const bool &transfer);
bool DFSCycleCheck(const std::string ¤t, const std::string &target, double amount, set<string> &visited);
};
#endif //PROJECT_OOP_BANK_H