summaryrefslogtreecommitdiff
path: root/walk.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-10 18:19:36 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-10 18:19:36 -0400
commita2efee0a8e895fc94e6eb4e048d32aa248b92080 (patch)
treea24ecdcae48add2ce5bafa3a3532aceb0e375159 /walk.cc
parent8792945e76277cea96c13444fa5e4cad7f3ce6ee (diff)
downloadfork-ledger-a2efee0a8e895fc94e6eb4e048d32aa248b92080.tar.gz
fork-ledger-a2efee0a8e895fc94e6eb4e048d32aa248b92080.tar.bz2
fork-ledger-a2efee0a8e895fc94e6eb4e048d32aa248b92080.zip
use polymorphism, instead of templates, for walking items
Diffstat (limited to 'walk.cc')
-rw-r--r--walk.cc16
1 files changed, 7 insertions, 9 deletions
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<transaction_t> {
+ virtual void operator()(transaction_t * xact) const {
xact->account->value += *xact;
}
};
void calc__accounts(account_t * account,
- const item_predicate<transaction_t>& pred_functor,
+ const item_predicate<transaction_t>& 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