Re: [QuantLib-svn] SF.net SVN: quantlib:[17105] trunk/QuantLib/ql/cashflows

Posted by Ferdinando M. Ametrano-3 on
URL: http://quantlib.414.s1.nabble.com/Re-QuantLib-svn-SF-net-SVN-quantlib-17105-trunk-QuantLib-ql-cashflows-tp12374p12375.html

On Wed, Feb 17, 2010 at 10:21 AM, Luigi Ballabio
<[hidden email]> wrote:
> On Tue, 2010-02-16 at 19:09 +0000, [hidden email] wrote:
>> added more Coupon inspectors
>
> We're duplicating code all over the place---they're all basically the
> same loop.  Why don't you write a nextCoupon() method instead and call
> whatever method you want on the result?

you're right and this is true for both nextCashFlow and nextCoupon,
their "previous" variants, and their CashFlows and Bond flavors

Anyway if bond_ is a shared_ptr<Bond> you would then have to write

(*BondFunctions::nextCashFlow(*bond_))->date();

instead of

bond_->nextCashFlowDate();

You might have multiple CashFlow on the same date, so nextCashFlow
might actually aggregate flows and create a new AggregateCashFlow
instance, then returning a shared_ptr instead of an iterator. In this
case one would have to write:

BondFunctions::nextCashFlow(*bond_)->date();

As for nextCoupon it should return an instance of some AggregateCoupon
class. This class would have pointers to the Coupons to be aggregated
for its own nominal() and rate() method implementations.

What do you think about it ?

ciao -- Nando

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev