DuxReiNummariae 1.0.0-alpha.23
Simple and powerful budgeting application
 
Loading...
Searching...
No Matches
drn::banking::BankMap Struct Referencefinal

A representation of financial institutions mapped to their names. More...

#include <BankMap.h>

Inheritance diagram for drn::banking::BankMap:
Collaboration diagram for drn::banking::BankMap:

Public Member Functions

 BankMap ()=default
 Constructs a default instance.
 
 BankMap (std::map< BankName, Bank > banks)
 Full initialisation constructor.
 
void add (Bank b)
 Adds a new financial institution to the container.
 
void add (const BankName &name, const accounting::AccountNumber &number, const BankAccountTypes type)
 Adds an associated account to the financial institution.
 
const Bankbank (const BankName &bn) const
 An accessor to the bank via its financial institution name.
 
void close (const BankName &name)
 Marks the financial institution as closed for usage.
 
std::optional< Bankfind (const accounting::AccountNumber &number) const
 Finds the bank that is associated with a given account number.
 
bool hasBank (const BankName &name) const
 Determines if a financial institution is in a container.
 
std::set< BankNamenames () const
 Collects all the known bank names.
 
void open (const BankName &name)
 Marks the financial institution as opened for usage.
 
void remove (const BankName &name)
 Removes the financial institution from the container.
 
void remove (const BankName &name, const accounting::AccountNumber &number)
 Removes an associated account from the financial institution.
 
void rename (const BankName &original, const BankName &changed)
 Renames the financial institution in the container.
 
void update (Bank b)
 Updates the financial institution information.
 

Friends

DRN_BANKING_EXPORT std::ostream & operator<< (std::ostream &o, const BankMap &bm)
 
DRN_BANKING_EXPORT bool operator== (const BankMap &lhs, const BankMap &rhs)
 

Detailed Description

A representation of financial institutions mapped to their names.

Constructor & Destructor Documentation

◆ BankMap() [1/2]

drn::banking::BankMap::BankMap ( )
default

Constructs a default instance.

This constructor initializes it with default values, ensuring it is ready to be used without prior setup.

Here is the caller graph for this function:

◆ BankMap() [2/2]

drn::banking::BankMap::BankMap ( std::map< BankName, Bank > banks)
explicit

Full initialisation constructor.

Exceptions
BankErrorWhen a financial institution name key does not match its name.
BankErrorWhen a financial institution uses a general ledger account number used by another financial institution.
BankErrorWhen a financial institution uses the a default ledger account.
Parameters
banksThe financial institutions.

Member Function Documentation

◆ add() [1/2]

void drn::banking::BankMap::add ( Bank b)

Adds a new financial institution to the container.

Exceptions
BankErrorWhen the financial institution is already closed.
BankErrorWhen the financial institution is already present in the container.
Parameters
bThe financial institution to add.

◆ add() [2/2]

void drn::banking::BankMap::add ( const BankName & name,
const accounting::AccountNumber & number,
const BankAccountTypes type )

Adds an associated account to the financial institution.

Exceptions
BankErrorWhen the financial institution does not exist.
BankErrorWhen the account number is already associated with another financial institution.
Parameters
nameThe name of the financial institution.
numberThe account number to add the association.

◆ bank()

const Bank & drn::banking::BankMap::bank ( const BankName & bn) const
nodiscard

An accessor to the bank via its financial institution name.

Exceptions
BankErrorWhen the financial institution name does not exist.
Parameters
bnThe name of the financial institution to look-up.
Returns
The requested financial institution.

◆ close()

void drn::banking::BankMap::close ( const BankName & name)

Marks the financial institution as closed for usage.

Exceptions
BankErrorWhen the financial institution does not exist.
Parameters
nameThe name of the financial institution.

◆ find()

std::optional< Bank > drn::banking::BankMap::find ( const accounting::AccountNumber & number) const
nodiscard

Finds the bank that is associated with a given account number.

Parameters
numberThe account number to find the associated bank.
Returns
Gives the found associated bank, or an empty optional.

◆ hasBank()

bool drn::banking::BankMap::hasBank ( const BankName & name) const
nodiscard

Determines if a financial institution is in a container.

Parameters
nameThe name of the financial institution to check.
Returns
Gives true when the institution is present, false otherwise.

◆ names()

std::set< BankName > drn::banking::BankMap::names ( ) const
nodiscard

Collects all the known bank names.

◆ open()

void drn::banking::BankMap::open ( const BankName & name)

Marks the financial institution as opened for usage.

Exceptions
BankErrorWhen the financial institution does not exist.
Parameters
nameThe name of the financial institution.

◆ remove() [1/2]

void drn::banking::BankMap::remove ( const BankName & name)

Removes the financial institution from the container.

Exceptions
BankErrorWhen the financial institution does not exist.
Parameters
nameThe name of the financial institution.

◆ remove() [2/2]

void drn::banking::BankMap::remove ( const BankName & name,
const accounting::AccountNumber & number )

Removes an associated account from the financial institution.

Exceptions
BankErrorWhen the financial institution does not exist.
BankErrorWhen the financial institution does not have the account.
Parameters
nameThe name of the financial institution.
numberThe account number to remove the association.

◆ rename()

void drn::banking::BankMap::rename ( const BankName & original,
const BankName & changed )

Renames the financial institution in the container.

Exceptions
BankErrorWhen the financial institution name to be changed does not exist.
BankErrorWhen the financial institution name to be changed and to be changed into are the same.
BankErrorWhen the financial institution name to change to already exists.
Parameters
originalThe name of the financial institution.
changedThe changed name of the financial institution.

◆ update()

void drn::banking::BankMap::update ( Bank b)

Updates the financial institution information.

Exceptions
BankErrorWhen the financial institution does not exist.
BankErrorWhen the financial institution to update is closed.
BankErrorWhen the financial institution's associated account ledger is already associated with another financial institution.
Parameters
bThe financial institution to update.

Friends And Related Symbol Documentation

◆ operator<<

DRN_BANKING_EXPORT std::ostream & operator<< ( std::ostream & o,
const BankMap & bm )
friend

◆ operator==

DRN_BANKING_EXPORT bool operator== ( const BankMap & lhs,
const BankMap & rhs )
friend