#include <DefaultPriceIndexFactory.h>
Inheritance diagram for com::ftlabs::fisa::DefaultPriceIndexFactory:

Public Member Functions | |
| DefaultPriceIndexFactory (void) | |
| Creates a new instance of DefaultPriceIndexFactory without any price index values. | |
| DefaultPriceIndexFactory (const char *filePath) | |
| Creates a new instance of DefaultPriceIndexFactory populated with data contained in the provided file. | |
| DefaultPriceIndexFactory (std::istream &inputStream) | |
| Creates a new instance of DefaultPriceIndexFactory populated with dates and price index values provided by an InputStream. | |
| ~DefaultPriceIndexFactory (void) | |
| void | clear () |
| Clear all price index values. | |
| void | loadPriceIndices (std::istream &inputStream) |
| Adds price index data provided by an InputStream to this DefaultPriceIndexFactory. | |
| void | addPriceIndex (const FISADate &date, double priceIndex) |
| Add a price index for the provided date. | |
| void | addPriceIndex (int year, int month, double priceIndex) |
| Add a price index for a given year and month. | |
| double | getPriceIndex (const FISADate &date) const |
| This method returns the price index for the given Date. | |
| double | getPriceIndex (const FISADate &date, int monthOffset) const |
| This method returns the price index for the given month offset from the given date. | |
| double | getPriceIndex (int year, int month) const |
| This method returns the price index for the given year and month. | |
| double | getPriceIndex (int year, int month, int monthOffset) const |
| This method returns the price index for the given month offset from year and month. | |
Private Types | |
| typedef std::map< int, double * > | price_index_map |
Private Attributes | |
| price_index_map | priceIndices |
Static Private Attributes | |
| static char * | DEFAULT_PARSE_MASK |
typedef std::map<int, double*> com::ftlabs::fisa::DefaultPriceIndexFactory::price_index_map [private] |
| com::ftlabs::fisa::DefaultPriceIndexFactory::DefaultPriceIndexFactory | ( | void | ) |
Creates a new instance of DefaultPriceIndexFactory without any price index values.
The addPriceIndex() method, or one of the loadPriceIndexValues() methods must be called to populate the factory. Otherwise all calls to getPriceIndex() will return 0.0.
| com::ftlabs::fisa::DefaultPriceIndexFactory::DefaultPriceIndexFactory | ( | const char * | filePath | ) |
Creates a new instance of DefaultPriceIndexFactory populated with data contained in the provided file.
The dates in the file must be in a format of "M/yyyy". See loadPriceIndexValues() for a full description of the required data format.
| filePath | The path to a file that contains the price index data. |
| com::ftlabs::fisa::DefaultPriceIndexFactory::DefaultPriceIndexFactory | ( | std::istream & | inputStream | ) |
Creates a new instance of DefaultPriceIndexFactory populated with dates and price index values provided by an InputStream.
The dates in the stream must be in a format of "M/yyyy". See loadPriceIndexValues() for a full description of the required data format.
| inputStream | A stream that contains the price index data. |
| com::ftlabs::fisa::DefaultPriceIndexFactory::~DefaultPriceIndexFactory | ( | void | ) |
| void com::ftlabs::fisa::DefaultPriceIndexFactory::clear | ( | ) |
Clear all price index values.
| void com::ftlabs::fisa::DefaultPriceIndexFactory::loadPriceIndices | ( | std::istream & | inputStream | ) |
Adds price index data provided by an InputStream to this DefaultPriceIndexFactory.
The dates in the stream must be in a format of "M/yyyy". The price index values must be parsable as a double. Each date and value should be separated with an equal sign where the date is the key. Each date/value pair should be delimited with a carriage return and/or a linefeed. The order of the date/value pairs doesn't matter, however if there is a duplicate date, the price index value of the last occurrance will be the value returned for that date.
Sample file layout : 03/2005 = 120.5 04/2005 = 121.0 05/2005 = 121.5
| inputStream | An InputStream that contains the price index data. |
| void com::ftlabs::fisa::DefaultPriceIndexFactory::addPriceIndex | ( | const FISADate & | date, | |
| double | priceIndex | |||
| ) |
Add a price index for the provided date.
| date | The price index date. | |
| priceIndex | The price index value. |
| void com::ftlabs::fisa::DefaultPriceIndexFactory::addPriceIndex | ( | int | year, | |
| int | month, | |||
| double | priceIndex | |||
| ) |
Add a price index for a given year and month.
| year | The year. | |
| month | The month. | |
| priceIndex | The price index value. |
| double com::ftlabs::fisa::DefaultPriceIndexFactory::getPriceIndex | ( | const FISADate & | date | ) | const [virtual] |
This method returns the price index for the given Date.
| date | A Date |
Implements com::ftlabs::fisa::PriceIndexFactory.
| double com::ftlabs::fisa::DefaultPriceIndexFactory::getPriceIndex | ( | const FISADate & | date, | |
| int | monthOffset | |||
| ) | const [virtual] |
This method returns the price index for the given month offset from the given date.
| date | A date | |
| monthOffset | number of months from the given month. |
Implements com::ftlabs::fisa::PriceIndexFactory.
| double com::ftlabs::fisa::DefaultPriceIndexFactory::getPriceIndex | ( | int | year, | |
| int | month | |||
| ) | const [virtual] |
This method returns the price index for the given year and month.
| year | The year | |
| month | The month |
Implements com::ftlabs::fisa::PriceIndexFactory.
| double com::ftlabs::fisa::DefaultPriceIndexFactory::getPriceIndex | ( | int | year, | |
| int | month, | |||
| int | monthOffset | |||
| ) | const [virtual] |
This method returns the price index for the given month offset from year and month.
| year | The year | |
| month | The month | |
| monthOffset | Months from the given month. |
Implements com::ftlabs::fisa::PriceIndexFactory.
char* com::ftlabs::fisa::DefaultPriceIndexFactory::DEFAULT_PARSE_MASK [static, private] |
1.5.2