(sort_transactions::post_accumulated_xacts): Created this function so

that interval_transactions has a way to post sorted xacts without
calling flush().
This commit is contained in:
John Wiegley 2005-05-27 01:36:32 +00:00
parent f8b45d534a
commit c8bbbf3f9c
2 changed files with 10 additions and 6 deletions

View file

@ -117,7 +117,7 @@ void set_account_value::operator()(transaction_t& xact)
item_handler<transaction_t>::operator()(xact); item_handler<transaction_t>::operator()(xact);
} }
void sort_transactions::flush() void sort_transactions::post_accumulated_xacts()
{ {
std::stable_sort(transactions.begin(), transactions.end(), std::stable_sort(transactions.begin(), transactions.end(),
compare_items<transaction_t>(sort_order)); compare_items<transaction_t>(sort_order));
@ -129,8 +129,6 @@ void sort_transactions::flush()
item_handler<transaction_t>::operator()(**i); item_handler<transaction_t>::operator()(**i);
} }
item_handler<transaction_t>::flush();
transactions.clear(); transactions.clear();
} }
@ -402,7 +400,7 @@ void interval_transactions::report_subtotal(const std::time_t moment)
subtotal_transactions::report_subtotal(); subtotal_transactions::report_subtotal();
if (sorter) if (sorter)
subtotal_transactions::flush(); sorter->post_accumulated_xacts();
last_xact = NULL; last_xact = NULL;
} }

10
walk.h
View file

@ -220,7 +220,13 @@ class sort_transactions : public item_handler<transaction_t>
delete sort_order; delete sort_order;
} }
virtual void flush(); virtual void post_accumulated_xacts();
virtual void flush() {
post_accumulated_xacts();
item_handler<transaction_t>::flush();
}
virtual void operator()(transaction_t& xact) { virtual void operator()(transaction_t& xact) {
transactions.push_back(&xact); transactions.push_back(&xact);
} }
@ -402,7 +408,7 @@ class interval_transactions : public subtotal_transactions
transaction_t * last_xact; transaction_t * last_xact;
bool started; bool started;
item_handler<transaction_t> * sorter; sort_transactions * sorter;
public: public:
interval_transactions(item_handler<transaction_t> * _handler, interval_transactions(item_handler<transaction_t> * _handler,