#include <rw/money/exchgfact.h> #include <rw/money/exchgratetbl.h> RWExchangeRateTable rates; RWExchangeFactory<double> factory(rates);
com.roguewave.money.currency.v1_0.ExchangeFactory
Money.h++ provides a factory class, RWExchangeFactory<T> that creates currency exchange objects. The currency exchange factory is essentially a list of RWExchangeGroups. 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.
RWExchangeFactory<T>();
Default constructor. By default the only exchange group in the factory is the RWMultiplicationGroup<T> group.
RWExchangeFactory<T>(const RWExchangeFactory<T>& f);
Copy constructor. Constructs a copy of the factory f.
RWExchangeFactory<T>(const RWExchangeRateTable& t);
Constructs an exchange factory that will use the given exchange rate table and contain the RWMultiplicationGroup<T> group.
RWExchangeFactory<T>& operator=(const RWExchangeFactory<T>&);
Assignment operator.
void appendExchangeGroup(const RWExchangeGroup<T>& a);
Adds group a to the end of the list.
void clearExchangeGroups();
Removes all exchange groups from the factory, including the default group.
RWBoolean 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.
RWExchangGroup<T> exchangeGroupAt(size_t i) const;
Returns the exchange group at index i. An exception of type RWBoundsError will be thrown if i is not a valid index.
size_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.
RWTValSlist< RWExchangeGroup<T> > exchangeGroups() const;
Returns the list of exchange groups contained in the factory.
RWExchangeRateTable exchangeRateTable() const; RWExchangeRateTable& exchangeRateTable();
Returns the exchange rate table being used by the factory. The non-const version may be used to modify the table's contents.
RWBoolean 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.
RWExchangeGroup<T> firstExchangeGroup() const;
Returns the first exchange group in the list. The behavior is undefined if the list is empty.
RWExchange<T> getExchange(const RWCString& sourceMnemonic, const RWCString& targetMnemonic) 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.
void insertExchangeGroupAt(size_t i,const RWExchangeGroup<T>& a);
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 RWBoundsError.
RWExchangeGroup<T> lastExchangeGroup() const;
Returns the last exchange group in the list. The behavior is undefined if the list is empty.
size_t numberOfExchangeGroups() const;
Returns the number of exchange groups that are currently in the factory.
void prependExchangeGroup(const RWExchangeGroup<T>& a);
Adds exchange group a to the beginning of the list.
RWBoolean removeExchangeGroup(const RWCString& groupName);
Removes the first object named groupName and returns TRUE. If groupname is not found, returns FALSE.
RWExchangeGroup<T> removeExchangeGroupAt(size_t i);
Removes the exchange group at index i and returns it. An exception of type RWBoundsError is thrown if i is not a valid index. Valid indices are from zero to the number of items in the list less one.
RWExchangeGroup<T> removeFirstExchangeGroup();
Removes the first exchange group in the list and returns it. The behavior is undefined if the list is empty.
RWExchangeGroup<T> removeLastExchangeGroup();
Removes the last exchange group in the list and returns it. The behavior is undefined if the list is empty.
void setExchangeRateTable( const RWExchangeRateTable& t );
Replaces the exchange rate table being used by the factory with t.
void setExchangeGroups(const RWTValSlist< RWExchangeGroup<T> >& l);
Replaces the exchange groups in the factory with the ones in the list l.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.