Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

5.4 Currency Exchange Groups

In the Money.h++ design, currency exchange groups are responsible for creating exchange objects that contain a particular implementation. A currency exchange group attempts to create an RWExchange object when presented with a source currency, a target currency, and an exchange rate table. It uses the source and target currencies to search the exchange rate table described in Section 5.2 for the exchange rates the particular implementation needs.

Money.h++ includes three C++ currency exchange groups: RWEuroGroup, RWMultiplicationGroup, and RWDivisionGroup. Although they all produce exchange objects, they work slightly differently.

When an RWEuroGroup object is presented with source and target currencies and an exchange rate table, it determines whether both currencies are contained in its list of Euro currencies. If both currencies are in the Euro list, the RWEuroGroup object searches the exchange rate table for two conversion rates: one from the Euro to the source and a second from the Euro to the target. If both rates are found it creates an exchange object with an RWTriangularExchange implementation.

When an RWMultiplicationGroup object is presented with source and target currencies and an exchange rate table it searches the exchange rate table for a source-to-target conversion factor. If it finds one, it creates an exchange object with RWMultiplicationExchange implementation. Similarly, when an RWDivisionGroup object is presented with source and target currencies and an exchange rate table it searches the exchange rate table for a target-to-source conversion factor. If found, it creates an exchange object with RWDivisionExchange implementation.

Notice that while an RWEuroGroup pre-checks a list of currencies to see whether the currencies presented to it are members of that group, the multiplication and division group objects don't do any such pre-check.

Money.h++ also provides three Java exchange groups: EuroGroup, MultiplicationGroup, and DivisionGroup. These three groups have the same functionality as their C++ counterparts. They all inherit directly from class ExchangeGroup.

Note that in C++ the exchange group creates an invalid exchange object if it cannot create a valid one. In Java, the exchange group returns a null value when it can't create a valid exchange object.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.