Member Functions | |||
exchange() impl() |
isValid() name() |
operator=() setImpl() |
source() target() |
#include <rw/money/currexchange.h> #include <rw/money/divexchange.h> #include <rw/money/decimal.h> #include <rw/money/mp2int.h> typedef RWDecimal<RWMP2Int> Decimal; RWDivisionGroup<Decimal>* impl = new RWDivisionGroup<Decimal>("LBP","CAD",971.8); RWExchange<Decimal> divExchange(impl);
com.roguewave.money.currency.v1_0.Exchange
Currency exchange objects are responsible for converting money of one currency into money of another currency. They encapsulate the source and target currency mnemonics, an exchange algorithm and any required exchange rates.
RWExchangeImpl is an abstract base class from which all currency implementation classes must derive. Class RWExchange<T> is the handle class, which forwards all conversion requests to its associated implementation class.
Money.h++ provides three types of currency exchange objects. The first type implements a triangular exchange algorithm required for converting between local currencies through an intermediate currency, such as the EMU requires for the Euro transition. The second type of exchange object multiplies the source currency amount by the exchange factor to obtain a target amount. The third type of exchange object divides the source currency amount by the exchange factor to obtain the target currency amount. All of the exchange objects share a common API for performing the actual conversion of money.
RWExchange();
Default constructor.
RWExchange(const RWExchange<T>& e);
Makes a (deep) copy of the implementation for currency exchange object e.
RWExchange(RWExchangeImpl<T>* impl);
Constructs an exchange object with the provided implementation impl. The object's destructor will delete impl.
RWExchange<T>& operator=(const RWExchange<T>& e);
Deletes self's current implementation and clones a copy of the implementation for e.
RWMoney<T> exchange(const RWMoney<T>& money) const;
Converts the amount money from the source currency to the target currency. If the currency associated with money does not match the source currency of self, an exception is thrown.
RWExchangeImpl<T>* impl() const;
Returns a pointer to the implementation class.
RWBoolean isValid() const;
Returns TRUE if this exchange object has a valid implementation, FALSE otherwise.
RWCString name()const;
Returns the name of the implementation class. Rogue Wave implementation classes return their static data member exchangeMethodName. For example, when an RWExchange object contains an RWTriangularExchange<T> implementation, name() returns RWTriangularExchange::exchangeMethodName.
void setImpl( RWExchangeImpl<T>* impl );
Sets impl as the implementation for this exchange object.
RWCString source() const;
Returns the mnemonic for the source currency.
RWCString target() const;
Returns the mnemonic for the target currency.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.