[btree_damage_visitor] Hide this behind a utility function btree_visit_values().

This commit is contained in:
Joe Thornber 2013-05-17 11:29:34 +01:00
parent 7f3a269757
commit f016161e9a
2 changed files with 313 additions and 307 deletions

View File

@ -91,7 +91,6 @@ namespace persistent_data {
bool damaged_;
block_address damage_begin_;
};
}
//----------------------------------------------------------------
@ -421,6 +420,17 @@ namespace persistent_data {
damage_tracker dt_;
std::list<std::string> damage_reasons_;
};
}
template <unsigned Levels, typename ValueTraits, typename ValueVisitor, typename DamageVisitor>
void btree_visit_values(btree<Levels, ValueTraits> const &tree,
block_counter &counter,
ValueVisitor &value_visitor,
DamageVisitor &damage_visitor) {
btree_detail::btree_damage_visitor<ValueVisitor, DamageVisitor, Levels, ValueTraits>
v(counter, value_visitor, damage_visitor);
tree.visit_depth_first(v);
}
}
//----------------------------------------------------------------

View File

@ -344,9 +344,7 @@ namespace {
virtual void run_() {
block_counter counter;
btree_damage_visitor<value_visitor_mock, damage_visitor_mock, 1, thing_traits>
visitor(counter, value_visitor_, damage_visitor_);
tree_->visit_depth_first(visitor);
btree_visit_values(*tree_, counter, value_visitor_, damage_visitor_);
}
};
@ -399,9 +397,7 @@ namespace {
virtual void run_() {
block_counter counter;
btree_damage_visitor<value_visitor_mock, damage_visitor_mock, 2, thing_traits>
visitor(counter, value_visitor_, damage_visitor_);
tree_->visit_depth_first(visitor);
btree_visit_values(*tree_, counter, value_visitor_, damage_visitor_);
}
};
}