00001 #ifndef DEREF_ITERATOR_H 00002 #define DEREF_ITERATOR_H 00003 00004 #include "y2storage/AppUtil.h" 00005 00006 namespace storage 00007 { 00008 00009 template< class Iter, class Value > 00010 class DerefIterator : public Iter 00011 { 00012 public: 00013 typedef Value value_type; 00014 typedef Value& reference; 00015 typedef Value* pointer; 00016 typedef typename Iter::difference_type difference_type; 00017 typedef typename Iter::iterator_category iterator_category; 00018 00019 DerefIterator() {} 00020 00021 DerefIterator( const Iter& i ) : Iter(i) {} 00022 00023 DerefIterator& operator++() { Iter::operator++(); return(*this); } 00024 DerefIterator operator++(int) 00025 { 00026 y2warning( "Expensive ++ DerefIterator" ); 00027 DerefIterator tmp(*this); 00028 Iter::operator++(); 00029 return(tmp); 00030 } 00031 DerefIterator& operator--() { Iter::operator--(); return(*this); } 00032 DerefIterator operator--(int) 00033 { 00034 y2warning( "Expensive -- DerefIterator" ); 00035 DerefIterator tmp(*this); 00036 Iter::operator--(); 00037 return(tmp); 00038 } 00039 00040 reference operator*() const 00041 { 00042 return( *Iter::operator*() ); 00043 } 00044 00045 pointer operator->() const 00046 { 00047 return( Iter::operator*() ); 00048 } 00049 }; 00050 00051 } 00052 00053 #endif