[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 { namespace {
class mapping_visitor { class check_mapping_visitor : public mapping_visitor {
public: public:
mapping_visitor(damage_visitor &visitor) check_mapping_visitor(damage_visitor &visitor)
: visitor_(visitor) { : visitor_(visitor) {
} }
virtual void visit(uint32_t index, mapping const &m) { virtual void visit(block_address cblock, mapping const &m) {
block_address cblock = index;
if (!valid_mapping(m)) if (!valid_mapping(m))
return; return;
@ -116,11 +114,19 @@ namespace {
} }
void 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(dv);
ll_damage_visitor ll(visitor);
array.visit_values(mv, ll); 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; 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, void check_mapping_array(mapping_array const &array,
mapping_array_damage::damage_visitor &visitor); mapping_array_damage::damage_visitor &visitor);
} }