[caching] introduce walk_mapping_array()

This commit is contained in:
Joe Thornber 2013-10-08 12:12:01 +01:00
parent 2ecf051336
commit 08142c0c66
2 changed files with 29 additions and 8 deletions

View File

@ -58,15 +58,13 @@ invalid_mapping::visit(damage_visitor &v) const
}
namespace {
class mapping_visitor {
class check_mapping_visitor : public mapping_visitor {
public:
mapping_visitor(damage_visitor &visitor)
check_mapping_visitor(damage_visitor &visitor)
: visitor_(visitor) {
}
virtual void visit(uint32_t index, mapping const &m) {
block_address cblock = index;
virtual void visit(block_address cblock, mapping const &m) {
if (!valid_mapping(m))
return;
@ -116,11 +114,19 @@ namespace {
}
void
caching::check_mapping_array(mapping_array const &array, damage_visitor &visitor)
caching::walk_mapping_array(mapping_array const &array,
mapping_visitor &mv,
damage_visitor &dv)
{
mapping_visitor mv(visitor);
ll_damage_visitor ll(visitor);
ll_damage_visitor ll(dv);
array.visit_values(mv, ll);
}
void
caching::check_mapping_array(mapping_array const &array, damage_visitor &visitor)
{
check_mapping_visitor mv(visitor);
walk_mapping_array(array, mv, visitor);
}
//----------------------------------------------------------------

View File

@ -75,6 +75,21 @@ namespace caching {
typedef persistent_data::array<mapping_traits> mapping_array;
class mapping_visitor {
public:
virtual ~mapping_visitor() {}
void visit(uint32_t index, mapping const &m) {
visit(static_cast<block_address>(index), m);
}
virtual void visit(block_address cblock, mapping const &m) = 0;
};
void walk_mapping_array(mapping_array const &array,
mapping_visitor &mv,
mapping_array_damage::damage_visitor &dv);
void check_mapping_array(mapping_array const &array,
mapping_array_damage::damage_visitor &visitor);
}