add clone method to checked_space_map

This commit is contained in:
Joe Thornber 2011-11-16 13:15:32 +00:00
parent 876dd2427f
commit f503cf7fbe
3 changed files with 18 additions and 2 deletions

View File

@ -54,6 +54,7 @@ namespace persistent_data {
public:
typedef boost::shared_ptr<persistent_space_map> ptr;
// FIXME: these two should be const
virtual size_t root_size() = 0;
virtual void copy_root(void *dest, size_t len) = 0;
};
@ -65,6 +66,8 @@ namespace persistent_data {
virtual void check(block_counter &counter) const {
throw std::runtime_error("not implemented");
}
virtual ptr clone() const = 0;
};
class sm_adjust {

View File

@ -381,11 +381,11 @@ namespace {
}
}
size_t root_size() {
virtual size_t root_size() {
return sizeof(sm_root_disk);
}
void copy_root(void *dest, size_t len) {
virtual void copy_root(void *dest, size_t len) {
sm_root_disk d;
sm_root v;
@ -401,6 +401,16 @@ namespace {
::memcpy(dest, &d, sizeof(d));
}
virtual checked_space_map::ptr clone() const {
sm_root root;
root.nr_blocks_ = nr_blocks_;
root.nr_allocated_ = nr_allocated_;
root.bitmap_root_ = indexes_->get_root();
root.ref_count_root_ = ref_counts_.get_root();
return checked_space_map::ptr(
new sm_disk(indexes_->clone(), tm_, root));
}
protected:
transaction_manager::ptr get_tm() const {
return tm_;

View File

@ -138,6 +138,9 @@ namespace {
return sm_->check(counter);
}
virtual checked_space_map::ptr clone() const {
return checked_space_map::ptr(new sm_recursive(sm_->clone()));
}
void flush_ops() {
op_map::const_iterator it, end = ops_.end();