|
BDE 4.14.0 Production release
|
Provide a parameterized day-count convention implementation.
This component provides a parameterized (template) implementation, bbldc::BasicDateRangeDayCountAdapter, of the bbldc::DateRangeDayCount protocol. The template argument can be any type supporting the following two class methods.
The template class bbldc::BasicDateRangeDayCountAdapter provides convenient support for run-time polymorphic choice of day-count conventions (via conventional use of a base-class pointer or reference) without having to implement each derived type explicitly. In this sense, bbldc::BasicDateRangeDayCountAdapter adapts the various concrete "basic" day-count convention classes (e.g., bbldc::BasicIsma30360) to a run-time binding mechanism.
The bbldc::DateRangeDayCount protocol requires two methods, firstDate and lastDate, that define a date range for which calculations are valid, to reflect the valid range of, say, a calendar required for the computations. For "basic" day-count implementations, the valid date range is identical to the range of bdlt::Date.
This section illustrates intended use of this component.
This example shows the procedure for using bbldc::BasicDateRangeDayCountAdapter to adapt the bbldc::BasicIsma30360 day-count convention to the bbldc::DateRangeDayCount protocol, and then the use of the day-count methods. First, we define an instance of the adapted day-count convention and obtain a reference to the bbldc::DateRangeDayCount:
Then, create two bdlt::Date variables, d1 and d2, with which to use the day-count convention methods:
Now, use the base-class reference to compute the day count between the two dates:
Finally, use the base-class reference to compute the year fraction between the two dates: