DuxReiNummariae 1.1.0-alpha.19
Simple and powerful budgeting application
Loading...
Searching...
No Matches
drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType > Struct Template Reference

Maps all the budgeted monies to their source. More...

#include <BudgetedMoneyMap.hpp>

Inheritance diagram for drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >:
Collaboration diagram for drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >:

Public Member Functions

 BudgetedMoneyMap (std::map< BudgetSource, BudgetedMoneyType > monies={})
 Full initialisation constructor using the provided budgeted monies.
void add (BudgetedMoneyType added)
 Places the new budgeted money into the budgeted monies indexed by its source.
const_iterator begin () const
 Provides an iterator to the beginning of the budgeted monies map.
const_iterator end () const
 Provides an iterator to the end of the budgeted monies map.
bool has (const BudgetSource &source) const
 Determines if a specific budgeted money exists within the budgeted monies.
std::strong_ordering operator<=> (const BudgetedMoneyMap &other) const noexcept
 Performs a three-way comparison between this BudgetedMoneyMap and another.
bool operator== (const BudgetedMoneyMap &) const noexcept=default
void remove (const BudgetSource &source)
 Removes an budgeted money from the budgeted monies.
void rename (const BudgetSource &original, BudgetSource changed)
std::set< BudgetSourcesources () const
 An accessor to all the known budgeted money sources.
pecunia::Money total (const pecunia::Currency &code, const EventFrequency period) const
 Calculates the total amount of budgeted monies.
void update (BudgetedMoneyType updated)
 Changes the budgeted money to the newly supplied one indexed by the source of the budgeted money. When the new budgeted money is not in the same currency as the existing entry, the new budgeted money will replace the existing entry, i.e. no currency conversions will take place.

Detailed Description

template<typename BudgetedMoneyType>
struct drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >

Maps all the budgeted monies to their source.

Template Parameters
BudgetedMoneyTypeThis is the type that is mapped to a budget item source. This type must derive from the BudgetedMoney class.

Constructor & Destructor Documentation

◆ BudgetedMoneyMap()

template<typename BudgetedMoneyType>
drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::BudgetedMoneyMap ( std::map< BudgetSource, BudgetedMoneyType > monies = {})
explicit

Full initialisation constructor using the provided budgeted monies.

Parameters
moniesA map of budget sources to their corresponding budgeted money values.
Here is the caller graph for this function:

Member Function Documentation

◆ add()

template<typename BudgetedMoneyType>
void drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::add ( BudgetedMoneyType added)

Places the new budgeted money into the budgeted monies indexed by its source.

Exceptions
BudgetItemErrorWhen the supplied budgeted money already exists in the budgeted monies.
Parameters
addedThe new budgeted money that is placed into the budgeted monies.

◆ begin()

template<typename BudgetedMoneyType>
const_iterator drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::begin ( ) const
nodiscard

Provides an iterator to the beginning of the budgeted monies map.

This allows read-only iteration over the budgeted monies from the starting position.

Returns
An iterator pointing to the beginning of the map.

◆ end()

template<typename BudgetedMoneyType>
const_iterator drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::end ( ) const
nodiscard

Provides an iterator to the end of the budgeted monies map.

This iterator refers to the element one past the last element in the map, useful for defining the bounds of iteration.

Returns
An iterator pointing to the end of the map.

◆ has()

template<typename BudgetedMoneyType>
bool drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::has ( const BudgetSource & source) const
nodiscard

Determines if a specific budgeted money exists within the budgeted monies.

Parameters
sourceThe source of the budgeted money to check.
Returns
True when the budgeted money exists, false else-wise.

◆ operator<=>()

template<typename BudgetedMoneyType>
std::strong_ordering drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::operator<=> ( const BudgetedMoneyMap< BudgetedMoneyType > & other) const
nodiscardnoexcept

Performs a three-way comparison between this BudgetedMoneyMap and another.

Parameters
otherThe other BudgetedMoneyMap to compare with this instance.
Returns
Compares the size, keys, and corresponding values of the two maps, in that order, and returns their relative ordering. A std::strong_ordering indicating the relative order:
  • std::strong_ordering::less if this instance is less than the other.
  • std::strong_ordering::greater if this instance is greater than the other.
  • std::strong_ordering::equal if both instances are equivalent.
Here is the call graph for this function:

◆ operator==()

template<typename BudgetedMoneyType>
bool drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::operator== ( const BudgetedMoneyMap< BudgetedMoneyType > & ) const
nodiscarddefaultnoexcept
Here is the call graph for this function:

◆ remove()

template<typename BudgetedMoneyType>
void drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::remove ( const BudgetSource & source)

Removes an budgeted money from the budgeted monies.

Exceptions
BudgetItemErrorWhen the supplied source does not exist.
Parameters
sourceThe budgeted money source to remove.

◆ rename()

template<typename BudgetedMoneyType>
void drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::rename ( const BudgetSource & original,
BudgetSource changed )

Changes the source of an budgeted money, and updates it's mapping.

Exceptions
BudgetItemErrorWhen the supplied current source does not exist.
BudgetItemErrorWhen the supplied changed source already exists.
Parameters
originalThe current source of the budgeted money.
changedThe new source of the budgeted money.

◆ sources()

template<typename BudgetedMoneyType>
std::set< BudgetSource > drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::sources ( ) const
nodiscard

An accessor to all the known budgeted money sources.

Returns
The known sources.

◆ total()

template<typename BudgetedMoneyType>
pecunia::Money drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::total ( const pecunia::Currency & code,
const EventFrequency period ) const
nodiscard

Calculates the total amount of budgeted monies.

Parameters
codeThe issued currency to calculate the monies in.
periodThe frequency period all monies should be tabulated in.
Returns
The sum of the amounts.

◆ update()

template<typename BudgetedMoneyType>
void drn::budgeting::BudgetedMoneyMap< BudgetedMoneyType >::update ( BudgetedMoneyType updated)

Changes the budgeted money to the newly supplied one indexed by the source of the budgeted money. When the new budgeted money is not in the same currency as the existing entry, the new budgeted money will replace the existing entry, i.e. no currency conversions will take place.

Exceptions
BudgetItemErrorWhen the supplied source source does not exist.
Parameters
updatedThe new budgeted money to update the indexed entry to.