Factory class that creates currency exchange objects. More...
#include <rw/currency/exchgfact.h>
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.
RWExchangeFactory< T >::RWExchangeFactory | ( | ) |
Default constructor. By default the only exchange group in the factory is the RWMultiplicationGroup group.
RWExchangeFactory< T >::RWExchangeFactory | ( | const RWExchangeFactory< T > & | f | ) |
Copy constructor. Constructs a copy of the factory f.
RWExchangeFactory< T >::RWExchangeFactory | ( | const RWExchangeRateTable & | ) |
Constructs an exchange factory that will use the given exchange rate table and contain the RWMultiplicationGroup group.
|
inline |
Adds group g to the end of the list.
|
inline |
Removes all exchange groups from the factory, including the default group.
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.
|
inline |
Returns the exchange group at index i. An exception of type RWBoundsErr will be thrown if i is not a valid index.
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.
|
inline |
Returns the list of exchange groups contained in the factory.
|
inline |
Returns the exchange rate table being used by the factory.
|
inline |
Returns the exchange rate table being used by the factory and can be used to modify the table's contents.
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
.
|
inline |
Returns the first exchange group in the list. The behavior is undefined if the list is empty.
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.
|
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.
|
inline |
Returns the last exchange group in the list. The behavior is undefined if the list is empty.
|
inline |
Returns the number of exchange groups that are currently in the factory.
RWExchangeFactory<T>& RWExchangeFactory< T >::operator= | ( | const RWExchangeFactory< T > & | ) |
Assignment operator.
|
inline |
Adds exchange group a to the beginning of the list.
bool RWExchangeFactory< T >::removeExchangeGroup | ( | const RWCString & | groupName | ) |
Removes the first object named groupName and returns true
. If groupName is not found, returns false
.
|
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.
|
inline |
Removes the first exchange group in the list and returns it. The behavior is undefined if the list is empty.
|
inline |
Removes the last exchange group in the list and returns it. The behavior is undefined if the list is empty.
|
inline |
Replaces the exchange groups in the factory with the ones in the list l.
|
inline |
Replaces the exchange rate table being used by the factory with t.
Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |