From a2efee0a8e895fc94e6eb4e048d32aa248b92080 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 10 Aug 2004 18:19:36 -0400 Subject: use polymorphism, instead of templates, for walking items --- walk.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'walk.cc') diff --git a/walk.cc b/walk.cc index 88c423ff..ee915164 100644 --- a/walk.cc +++ b/walk.cc @@ -2,30 +2,28 @@ namespace ledger { -class sum_in_account -{ - public: - void operator()(transaction_t * xact) const { +struct sum_in_account : public item_handler { + virtual void operator()(transaction_t * xact) const { xact->account->value += *xact; } }; void calc__accounts(account_t * account, - const item_predicate& pred_functor, + const item_predicate& pred, unsigned int flags) { - sum_in_account functor; + sum_in_account handler; for (transactions_list::iterator i = account->transactions.begin(); i != account->transactions.end(); i++) - if (pred_functor(*i)) - handle_transaction(*i, functor, flags); + if (pred(*i)) + handle_transaction(*i, handler, flags); for (accounts_map::iterator i = account->accounts.begin(); i != account->accounts.end(); i++) - calc__accounts((*i).second, pred_functor, flags); + calc__accounts((*i).second, pred, flags); } } // namespace ledger -- cgit v1.2.3