"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "fsremap/src/map.hh" between
fstransform-0.9.3-src.tar.gz and fstransform-0.9.4.tar.gz

About: fstransform is a tool to change a file-system from one format to another, for example from jfs, xfs, or reiser to ext2, ext3, or ext4, in-place and without the need for backup.

map.hh  (fstransform-0.9.3-src):map.hh  (fstransform-0.9.4)
skipping to change at line 31 skipping to change at line 31
* *
* Created on: Feb 27, 2011 * Created on: Feb 27, 2011
* Author: max * Author: max
*/ */
#ifndef FSREMAP_MAP_HH #ifndef FSREMAP_MAP_HH
#define FSREMAP_MAP_HH #define FSREMAP_MAP_HH
#include "check.hh" #include "check.hh"
#include <map> // for std::map<K,V> */ #include <map> // for std::map<K,V>
#include "types.hh" // for ft_uoff */ #include "types.hh" // for ft_uoff
#include "fwd.hh" // for fr_map<T> and fr_vector<T> forward declarations */ #include "fwd.hh" // for fr_map<T> and fr_vector<T> forward declarations
#include "extent.hh" // for fr_extent_key<T>, fr_extent_payload<T>, ft_match */ #include "log.hh" // for ft_log_level, FC_SHOW_DEFAULT_LEVEL. also used by ma
p.t.hh for ff_log()
#include "extent.hh" // for fr_extent_key<T>, fr_extent_payload<T>, ft_match
FT_NAMESPACE_BEGIN FT_NAMESPACE_BEGIN
template<typename T> template<typename T>
class fr_map : private std::map<fr_extent_key<T>, fr_extent_payload<T> > class fr_map : private std::map<fr_extent_key<T>, fr_extent_payload<T> >
{ {
private: private:
typedef std::map<fr_extent_key<T>, fr_extent_payload<T> > super_type; typedef std::map<fr_extent_key<T>, fr_extent_payload<T> > super_type;
public: public:
skipping to change at line 124 skipping to change at line 125
*/ */
iterator merge(iterator pos1, const key_type & key2, const mapped_type & val ue2); iterator merge(iterator pos1, const key_type & key2, const mapped_type & val ue2);
/** /**
* remove a part of an existing extent (or a whole existing extent) * remove a part of an existing extent (or a whole existing extent)
* from this fr_map, splitting the existing extent if needed. * from this fr_map, splitting the existing extent if needed.
* throws an assertion failure if extent to remove is not part of existing e xtents. * throws an assertion failure if extent to remove is not part of existing e xtents.
* *
* does not support removing an extent that is part of TWO OR MORE existing extents. * does not support removing an extent that is part of TWO OR MORE existing extents.
*/ */
void remove1(const value_type & extent); void remove1(const value_type & extent, ft_match match);
public: public:
// construct empty fr_map // construct empty fr_map
fr_map(); fr_map();
// duplicate a fr_map, i.e. initialize this fr_map as a copy of other. // duplicate a fr_map, i.e. initialize this fr_map as a copy of other.
fr_map(const fr_map<T> & other); fr_map(const fr_map<T> & other);
// destroy fr_map // destroy fr_map
~fr_map(); ~fr_map();
// return iterator to beginning of this map // return iterator to beginning of this map
super_type::begin; using super_type::begin;
// return iterator one past the end of this map // return iterator one past the end of this map
super_type::end; using super_type::end;
// return true is this map is empty, i.e. if it size() == 0 // return true is this map is empty, i.e. if it size() == 0
super_type::empty; using super_type::empty;
// return number of extents in this map // return number of extents in this map
super_type::size; using super_type::size;
// clear this map, i.e. erase all elements // clear this map, i.e. erase all elements
super_type::clear; using super_type::clear;
// find an extent given its starting ->physical // find an extent given its starting ->physical
super_type::find; using super_type::find;
// copy fr_map, i.e. set this fr_map contents as a copy of other's contents. // copy fr_map, i.e. set this fr_map contents as a copy of other's contents.
const fr_map<T> & operator=(const fr_map<T> & other); const fr_map<T> & operator=(const fr_map<T> & other);
// swap this map contents with other map // swap this map contents with other map
void swap(fr_map<T> & other); void swap(fr_map<T> & other);
/** /**
* returns the minimum physical and the maximum physical+length in this map. * returns the minimum physical and the maximum physical+length in this map.
* if this map is empty, return {0,0} * if this map is empty, return {0,0}
skipping to change at line 234 skipping to change at line 235
*/ */
iterator insert(const key_type & key, const mapped_type & value); iterator insert(const key_type & key, const mapped_type & value);
/** /**
* insert a single extent into this fr_map, * insert a single extent into this fr_map,
* merging with existing extents where possible. * merging with existing extents where possible.
* return iterator to inserted/merged extent * return iterator to inserted/merged extent
* *
* simply calls insert(key_type, value_type) * simply calls insert(key_type, value_type)
*/ */
iterator insert(const value_type & extent) { return insert(extent.first, ext ent.second); } FT_INLINE iterator insert(const value_type & extent) { return insert(extent. first, extent.second); }
/** /**
* insert a single extent into this fr_map, * insert a single extent into this fr_map,
* merging with existing extents where possible. * merging with existing extents where possible.
* return iterator to inserted/merged extent. * return iterator to inserted/merged extent.
* *
* simply calls insert(key_type, value_type) * simply calls insert(key_type, value_type)
*/ */
iterator insert(T physical, T logical, T length, ft_size user_data); iterator insert(T physical, T logical, T length, ft_size user_data);
skipping to change at line 268 skipping to change at line 269
* no need to check for splitting in this method, as it cannot happen: * no need to check for splitting in this method, as it cannot happen:
* the extent to remove is specified by its iterator, * the extent to remove is specified by its iterator,
* so it must be exactly one of the extents of this map * so it must be exactly one of the extents of this map
*/ */
void remove(iterator iter); void remove(iterator iter);
/** /**
* remove a part of an existing extent (or one or more existing extents) * remove a part of an existing extent (or one or more existing extents)
* from this fr_map, splitting the existing extents if needed. * from this fr_map, splitting the existing extents if needed.
*/ */
void remove(const value_type & extent); void remove(const value_type & extent, ft_match match = FC_BOTH);
/** /**
* remove a part of an existing extent (or one or more existing extents) * remove a part of an existing extent (or one or more existing extents)
* from this fr_map, splitting the existing extents if needed. * from this fr_map, splitting the existing extents if needed.
*/ */
void remove(T physical, T logical, T length); void remove(T physical, T logical, T length, ft_match match = FC_BOTH);
/** /**
* remove any (partial or full) intersection with existing extents from this fr_map, * remove any (partial or full) intersection with existing extents from this fr_map,
* splitting the existing extents if needed. * splitting the existing extents if needed.
*/ */
template<typename const_iter> template<typename const_iter>
void remove_all(const_iter iter, const_iter end) void remove_all(const_iter iter, const_iter end, ft_match match = FC_BOTH)
{ {
for (; iter != end; ++iter) for (; iter != end; ++iter)
remove(*iter); remove(*iter, match);
} }
/** /**
* remove any (partial or full) intersection with existing extents from this fr_map, * remove any (partial or full) intersection with existing extents from this fr_map,
* splitting the existing extents if needed. * splitting the existing extents if needed.
*/ */
void remove_all(const fr_map<T> & map); void remove_all(const fr_map<T> & map, ft_match match = FC_BOTH);
/** /**
* remove an initial part of an existing extent from this fr_map. * remove an initial part of an existing extent from this fr_map.
* returns iterator to new, smaller extent, or end() if the whole extent was removed * returns iterator to new, smaller extent, or end() if the whole extent was removed
*/ */
iterator remove_front(iterator iter, T shrink_length); iterator remove_front(iterator iter, T shrink_length);
/** /**
* set this map to a transposed copy of other map, * set this map to a transposed copy of other map,
* i.e. to a copy where all ->physical and ->logical are swapped * i.e. to a copy where all ->physical and ->logical are swapped
skipping to change at line 317 skipping to change at line 318
* shifting extents by effective_block_size_log2, * shifting extents by effective_block_size_log2,
* and hinting that insertion is at map end. * and hinting that insertion is at map end.
* optimized assuming that 'other' is sorted by physical. * optimized assuming that 'other' is sorted by physical.
* *
* does not merge and does not check for merges * does not merge and does not check for merges
* does not check for overflows * does not check for overflows
*/ */
void append0_shift(const fr_vector<ft_uoff> & other, ft_uoff effective_block _size_log2); void append0_shift(const fr_vector<ft_uoff> & other, ft_uoff effective_block _size_log2);
/** /**
* shift and merge specified extent vector
* into this map, skipping any intersection.
*/
void merge_shift(const fr_vector<ft_uoff> & other, ft_uoff effective_block_s
ize_log2, ft_match match);
/**
* makes the physical complement of 'other' vector, * makes the physical complement of 'other' vector,
* i.e. calculates the physical extents NOT used in 'other' vector, * i.e. calculates the physical extents NOT used in 'other' vector,
* shifts them by effective_block_size_log2, * shifts them by effective_block_size_log2,
* and inserts it in this map. * and inserts it in this map.
* *
* since the file(s) contained in such complementary extents are not known, * since the file(s) contained in such complementary extents are not known,
* all calculated extents will have ->logical == ->physical. * all calculated extents will have ->logical == ->physical.
* *
* 'other' must be already sorted by physical! * 'other' must be already sorted by physical!
* does not merge and does not check for merges * does not merge and does not check for merges
skipping to change at line 345 skipping to change at line 352
* and inserts it in this map. * and inserts it in this map.
* *
* since the file(s) contained in such complementary extents are not known, * since the file(s) contained in such complementary extents are not known,
* all calculated extents will have ->logical == ->physical. * all calculated extents will have ->logical == ->physical.
* *
* 'other' must be already sorted by logical! * 'other' must be already sorted by logical!
* does not merge and does not check for merges * does not merge and does not check for merges
* does not check for overflows * does not check for overflows
*/ */
void complement0_logical_shift(const fr_vector<ft_uoff> & other, ft_uoff eff ective_block_size_log2, ft_uoff device_length); void complement0_logical_shift(const fr_vector<ft_uoff> & other, ft_uoff eff ective_block_size_log2, ft_uoff device_length);
/** print map contents to log */
void show(const char * label1, const char * label2, ft_uoff effective_block_
size,
ft_log_level level = FC_SHOW_DEFAULT_LEVEL) const;
}; };
FT_NAMESPACE_END FT_NAMESPACE_END
#ifdef FT_HAVE_EXTERN_TEMPLATE #ifdef FT_HAVE_EXTERN_TEMPLATE
# define FT_TEMPLATE_map_hh(ft_prefix, T) ft_prefix class FT_NS fr_map< T >; # define FT_TEMPLATE_map_hh(ft_prefix, T) ft_prefix class FT_NS fr_map< T >;
FT_TEMPLATE_DECLARE(FT_TEMPLATE_map_hh) FT_TEMPLATE_DECLARE(FT_TEMPLATE_map_hh)
#else #else
# include "map.t.hh" # include "map.t.hh"
#endif /* FT_HAVE_EXTERN_TEMPLATE */ #endif /* FT_HAVE_EXTERN_TEMPLATE */
 End of changes. 17 change blocks. 
17 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)