Currency Exchange Classes
The Currency Module provides three different conversion methods:
*Multiplication. Multiply the source currency amount by a conversion factor to determine the target currency amount. Corresponds to the class RWMultiplicationExchange.
*Division. Divide the source currency amount by a conversion factor to determine the target currency amount. Corresponds to Essential Tools Module class RWDivisionExchange.
*Triangulation. Convert the source currency amount to an intermediate currency amount, then convert the intermediate currency amount to the target currency amount. This is the conversion method that is used to convert among currencies that are in transition to the Euro currency. Corresponds to the class RWTriangularExchange<T>.
The class RWExchange contains a pointer to implementation class of type RWExchangeImpl, and defers to that implementation when actually performing a currency conversion. The Currency Module provides three currency exchange classes, corresponding to the conversion methods listed above, that derived from the abstract base class RWExchangeImpl. The three exchange classes are implementation classes of class RWExchange, which presents a generic interface for performing currency exchanges.
The different implementations share an interface, but work differently from one another. For example, an RWExchange object that contains an RWMultiplicationExchange implementation performs a currency exchange by invoking an implementation multiplies the amount in the source currency by a conversion factor to get the amount in the target currency.
Contrast this with an RWExchange object that contains an RWTriangularExchange implementation. RWTriangularExchange invokes an implementation that converts the source currency to a base currency, then converts the base currency to the target. First, the RWTriangularExchange implementation converts the source to the base by dividing the source by a base-to-source conversion factor. Then it multiplies the result by a base-to-target conversion factor to obtain the target. This is the algorithm mandated by the European Monetary Union (EMU) for converting between local EMU currencies during the Euro transition period.