rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWExchangeFactory< T > Class Template Reference
[Currency Conversions]

Factory class that creates currency exchange objects. More...

#include <rw/currency/exchgfact.h>

List of all members.

Public Member Functions

 RWExchangeFactory ()
 RWExchangeFactory (const RWExchangeFactory< T > &f)
 RWExchangeFactory (const RWExchangeRateTable &)
bool containsExchangeGroup (const RWCString &groupName) const
void clearExchangeGroups ()
size_t numberOfExchangeGroups () const
RWTValSlist< RWExchangeGroup< T > > exchangeGroups () const
void setExchangeGroups (const RWTValSlist< RWExchangeGroup< T > > &l)
bool findExchangeGroup (const RWCString &name, RWExchangeGroup< T > &grp) const
RWExchangeGroup< T > firstExchangeGroup () const
RWExchangeGroup< T > lastExchangeGroup () const
RWExchangeGroup< T > exchangeGroupAt (size_t i) const
size_t exchangeGroupIndex (const RWCString &groupName) const
void appendExchangeGroup (const RWExchangeGroup< T > &g)
void insertExchangeGroupAt (size_t i, const RWExchangeGroup< T > &a)
void prependExchangeGroup (const RWExchangeGroup< T > &a)
bool removeExchangeGroup (const RWCString &groupName)
RWExchangeGroup< T > removeExchangeGroupAt (size_t i)
RWExchangeGroup< T > removeFirstExchangeGroup ()
RWExchangeGroup< T > removeLastExchangeGroup ()
RWExchangeRateTable exchangeRateTable () const
RWExchangeRateTableexchangeRateTable ()
void setExchangeRateTable (const RWExchangeRateTable &t)
RWExchange< T > getExchange (const RWCString &src, const RWCString &target) const
RWExchangeFactory< T > & operator= (const RWExchangeFactory< T > &)

Detailed Description

template<class T>
class RWExchangeFactory< T >

Currency Module provides a factory class, RWExchangeFactory<T> that creates currency exchange objects. The currency exchange factory is essentially a list of RWExchangeGroup<T> objects. When the factory receives a request for a currency exchange object, it finds the first currency exchange group that can create an RWExchange<T> object and returns the object it found. By default, upon construction, the RWExchangeFactory<T> class always contains one currency exchange group: RWMultiplicationGroup<T>.

The RWMultiplicationGroup<T> group is the default exchange group, and, initially, is always available in the factory's list of currency groups. When presented with a source/target currency pair and exchange rate table, the default exchange group looks for an exchange rate in the table for the pair and, if found, constructs an RWExchange<T> exchange rate object, with an RWMultiplicationExchange<T> implementation.

Synopsis

 #include <rw/currency/exchgfact.h>
 #include <rw/currency/exchgratetbl.h>
 RWExchangeRateTable rates;
 RWExchangeFactory<double> factory(rates);

Constructor & Destructor Documentation

template<class T>
RWExchangeFactory< T >::RWExchangeFactory (  ) 

Default constructor. By default the only exchange group in the factory is the RWMultiplicationGroup<T> group.

template<class T>
RWExchangeFactory< T >::RWExchangeFactory ( const RWExchangeFactory< T > &  f  ) 

Copy constructor. Constructs a copy of the factory f.

template<class T>
RWExchangeFactory< T >::RWExchangeFactory ( const RWExchangeRateTable  ) 

Constructs an exchange factory that will use the given exchange rate table and contain the RWMultiplicationGroup<T> group.


Member Function Documentation

template<class T>
void RWExchangeFactory< T >::appendExchangeGroup ( const RWExchangeGroup< T > &  g  )  [inline]

Adds group g to the end of the list.

template<class T>
void RWExchangeFactory< T >::clearExchangeGroups (  )  [inline]

Removes all exchange groups from the factory, including the default group.

template<class T>
bool RWExchangeFactory< T >::containsExchangeGroup ( const RWCString groupName  )  const

Returns true if the list contains the exchange group specified by groupName. Note that Rogue Wave group names are given by the class's static variable groupName, for example, RWEuroGroup<T>::groupName.

template<class T>
RWExchangeGroup<T> RWExchangeFactory< T >::exchangeGroupAt ( size_t  i  )  const [inline]

Returns the exchange group at index i. An exception of type RWBoundsErr will be thrown if i is not a valid index.

template<class T>
size_t RWExchangeFactory< T >::exchangeGroupIndex ( const RWCString groupName  )  const

Returns the index of the first exchange group whose name matches groupName, or RW_NPOS if there is no such object.

template<class T>
RWTValSlist< RWExchangeGroup<T> > RWExchangeFactory< T >::exchangeGroups (  )  const [inline]

Returns the list of exchange groups contained in the factory.

template<class T>
RWExchangeRateTable& RWExchangeFactory< T >::exchangeRateTable (  )  [inline]

Returns the exchange rate table being used by the factory and can be used to modify the table's contents.

template<class T>
RWExchangeRateTable RWExchangeFactory< T >::exchangeRateTable (  )  const [inline]

Returns the exchange rate table being used by the factory.

template<class T>
bool RWExchangeFactory< T >::findExchangeGroup ( const RWCString name,
RWExchangeGroup< T > &  grp 
) const

Searches for exchange group name. If found, it is placed in grp and the function returns true. If name is not found, grp remains unchanged and the function returns false.

template<class T>
RWExchangeGroup<T> RWExchangeFactory< T >::firstExchangeGroup (  )  const [inline]

Returns the first exchange group in the list. The behavior is undefined if the list is empty.

template<class T>
RWExchange<T> RWExchangeFactory< T >::getExchange ( const RWCString src,
const RWCString target 
) const

Searches the list of currency groups in the factory until it finds one that can create an exchange object, then returns the exchange object. If no exchange group in the factory can create an exchange object, this function returns an invalid exchange object. A valid exchange object is determined by using the RWExchange<T>::isValid() method.

template<class T>
void RWExchangeFactory< T >::insertExchangeGroupAt ( size_t  i,
const RWExchangeGroup< T > &  a 
) [inline]

Inserts group a into the index position specified by i. If the index position is not between zero and the number of groups in the list, the function throws an exception of type RWBoundsErr.

template<class T>
RWExchangeGroup<T> RWExchangeFactory< T >::lastExchangeGroup (  )  const [inline]

Returns the last exchange group in the list. The behavior is undefined if the list is empty.

template<class T>
size_t RWExchangeFactory< T >::numberOfExchangeGroups (  )  const [inline]

Returns the number of exchange groups that are currently in the factory.

template<class T>
RWExchangeFactory<T>& RWExchangeFactory< T >::operator= ( const RWExchangeFactory< T > &   ) 

Assignment operator.

template<class T>
void RWExchangeFactory< T >::prependExchangeGroup ( const RWExchangeGroup< T > &  a  )  [inline]

Adds exchange group a to the beginning of the list.

template<class T>
bool RWExchangeFactory< T >::removeExchangeGroup ( const RWCString groupName  ) 

Removes the first object named groupName and returns true. If groupName is not found, returns false.

template<class T>
RWExchangeGroup<T> RWExchangeFactory< T >::removeExchangeGroupAt ( size_t  i  )  [inline]

Removes the exchange group at index i and returns it. An exception of type RWBoundsErr is thrown if i is not a valid index. Valid indices are from zero to the number of items in the list less one.

template<class T>
RWExchangeGroup<T> RWExchangeFactory< T >::removeFirstExchangeGroup (  )  [inline]

Removes the first exchange group in the list and returns it. The behavior is undefined if the list is empty.

template<class T>
RWExchangeGroup<T> RWExchangeFactory< T >::removeLastExchangeGroup (  )  [inline]

Removes the last exchange group in the list and returns it. The behavior is undefined if the list is empty.

template<class T>
void RWExchangeFactory< T >::setExchangeGroups ( const RWTValSlist< RWExchangeGroup< T > > &  l  )  [inline]

Replaces the exchange groups in the factory with the ones in the list l.

template<class T>
void RWExchangeFactory< T >::setExchangeRateTable ( const RWExchangeRateTable t  )  [inline]

Replaces the exchange rate table being used by the factory with t.

 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.