rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWExchange< T > Class Template Reference
[Currency Conversions]

Handle class for the abstract body class RWExchangeImpl<T> from which all concrete currency converters derive. More...

#include <rw/currency/currexchange.h>

List of all members.

Public Member Functions

 RWExchange ()
 RWExchange (const RWExchange< T > &c)
 RWExchange (RWExchangeImpl< T > *impl)
void setImpl (RWExchangeImpl< T > *impl)
const RWExchangeImpl< T > * impl () const
RWMoney< T > exchange (const RWMoney< T > &m) const
RWCString source () const
RWCString target () const
RWCString name () const
bool isValid () const
RWExchange< T > & operator= (const RWExchange< T > &c)

Detailed Description

template<class T>
class RWExchange< T >

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<T> 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.

Currency Module 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.

Synopsis

 #include <rw/currency/currexchange.h>
 #include <rw/currency/divexchange.h>
 #include <rw/currency/decimal.h>
 #include <rw/currency/mp2int.h>
 
 typedef RWDecimal<RWMP2Int> Decimal;
 RWDivisionGroup<Decimal>* impl =
   new RWDivisionGroup<Decimal>("LBP","CAD",971.8);
 RWExchange<Decimal> divExchange(impl);

Constructor & Destructor Documentation

template<class T>
RWExchange< T >::RWExchange (  )  [inline]

Default constructor.

template<class T>
RWExchange< T >::RWExchange ( const RWExchange< T > &  c  )  [inline]

Makes a (deep) copy of the implementation for currency exchange object c.

template<class T>
RWExchange< T >::RWExchange ( RWExchangeImpl< T > *  impl  )  [inline]

Constructs an exchange object with the provided implementation impl. The object's destructor will delete impl.


Member Function Documentation

template<class T>
RWMoney<T> RWExchange< T >::exchange ( const RWMoney< T > &  m  )  const [inline]

Converts the amount m from the source currency to the target currency. If the currency associated with m does not match the source currency of self, an exception is thrown.

template<class T>
const RWExchangeImpl<T>* RWExchange< T >::impl (  )  const [inline]

Returns a pointer to the implementation class.

template<class T>
bool RWExchange< T >::isValid (  )  const [inline]

Returns true if this exchange object has a valid implementation, false otherwise.

template<class T>
RWCString RWExchange< T >::name (  )  const [inline]

Returns the name of the implementation class. Rogue Wave implementation classes return their static data member exchangeMethodName. For example, when an RWExchange<T> object contains an RWTriangularExchange<T> implementation, name() returns RWTriangularExchange::exchangeMethodName.

template<class T>
RWExchange<T>& RWExchange< T >::operator= ( const RWExchange< T > &  c  )  [inline]

Deletes self's current implementation and clones a copy of the implementation for c.

template<class T>
void RWExchange< T >::setImpl ( RWExchangeImpl< T > *  impl  )  [inline]

Sets impl as the implementation for this exchange object.

template<class T>
RWCString RWExchange< T >::source (  )  const [inline]

Returns the mnemonic for the source currency.

template<class T>
RWCString RWExchange< T >::target (  )  const [inline]

Returns the mnemonic for the target currency.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.