SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWExchangeFactory< T > Class Template Reference

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

#include <rw/currency/exchgfact.h>

Public Member Functions

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

Detailed Description

template<class T>
class RWExchangeFactory< T >

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

The RWMultiplicationGroup 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 exchange rate object, with an RWMultiplicationExchange implementation.

Synopsis
#include <rw/currency/exchgfact.h>
#include <rw/currency/exchgratetbl.h>

Constructor & Destructor Documentation

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

Default constructor. By default the only exchange group in the factory is the RWMultiplicationGroup 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 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 ( ) const
inline

Returns the exchange rate table being used by 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>
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.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.