com::ftlabs::fisa::DefaultPriceIndexFactory Class Reference

This is the default implementation of PriceIndexFactory. For maximum efficiency, this implementation maintains a list of all provided values so that the getPriceIndex() methods returns as quickly as possible. More...

#include <DefaultPriceIndexFactory.h>

Inheritance diagram for com::ftlabs::fisa::DefaultPriceIndexFactory:

com::ftlabs::fisa::PriceIndexFactory List of all members.

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

Detailed Description

This is the default implementation of PriceIndexFactory. For maximum efficiency, this implementation maintains a list of all provided values so that the getPriceIndex() methods returns as quickly as possible.


Member Typedef Documentation

typedef std::map<int, double*> com::ftlabs::fisa::DefaultPriceIndexFactory::price_index_map [private]


Constructor & Destructor Documentation

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.

Parameters:
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.

Parameters:
inputStream A stream that contains the price index data.

com::ftlabs::fisa::DefaultPriceIndexFactory::~DefaultPriceIndexFactory ( void   ) 


Member Function Documentation

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

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
date A Date
Returns:
Price index for the given 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.

Parameters:
date A date
monthOffset number of months from the given month.
Returns:
Price index for the given offset from the given date.

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.

Parameters:
year The year
month The month
Returns:
Price index for the given year and 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.

Parameters:
year The year
month The month
monthOffset Months from the given month.
Returns:
Price index for the given offset from year and month.

Implements com::ftlabs::fisa::PriceIndexFactory.


Member Data Documentation

char* com::ftlabs::fisa::DefaultPriceIndexFactory::DEFAULT_PARSE_MASK [static, private]

price_index_map com::ftlabs::fisa::DefaultPriceIndexFactory::priceIndices [private]


The documentation for this class was generated from the following file:
Generated on Tue Feb 5 03:50:25 2008 for FTLabs FISA (c++) by  doxygen 1.5.2