stldb::trans_assoc_iterator
// In header: </Users/bobw/workspace/stldb_lib/stldb/containers/trans_assoc_iterator.h> template<typename container_t, typename base_iterator> class trans_assoc_iterator { public: // types typedef iterator_traits< base_iterator >::value_type value_type; typedef iterator_traits< base_iterator >::value_type::first_type K; typedef iterator_traits< base_iterator >::value_type::second_type V; typedef container_t::pending_change_map_t pending_change_map_t; typedef value_type & reference; typedef value_type * pointer; // construct/copy/destruct trans_assoc_iterator(); trans_assoc_iterator(base_iterator, container_t *); trans_assoc_iterator(base_iterator, container_t *, Transaction &); trans_assoc_iterator(const trans_assoc_iterator &); // public member functions reference operator*() const; pointer operator->() const; trans_assoc_iterator & operator++() ; trans_assoc_iterator & operator--() ; trans_assoc_iterator operator++(int) ; trans_assoc_iterator operator--(int) ; base_iterator & base() ; bool valid() const; // private member functions void forward(int) ; void backward(int) ; };
This is an iterator adapter which will work for any associative iterator type in which the value type of the base iterator is pair<const K,transEntry<V>> for any K,V.
This adapter provides a transactionally aware iterator which keeps transactions isolated from each other.
First, the iterator will skip over any uncomitted data, or any uncomitted data not associated with the transaction that the iterator was constructed with. This provides a consistent view of the data in the map.
Finally, when the iterator lands on an entry which has been modified by the current transaction, it composes a value_type entry which has the key and the pending update value on it, and returns references to that pair. In this case, the pair being seen is not actually in the map, but is rather a pending change.
trans_assoc_iterator
public
construct/copy/destructtrans_assoc_iterator();
trans_assoc_iterator(base_iterator i, container_t * container);
TODO: There seems to be a bug with boost::interprocess::map<>, because although map::value_type is pair<const K, V>, it seems that map::iterator::operator* is returning pair<K,V>, in violation of current C++ standards. The workaround are the reinterpret casts seen below and in the tcc.
trans_assoc_iterator(base_iterator i, container_t * container, Transaction & trans);
trans_assoc_iterator(const trans_assoc_iterator & rarg);
trans_assoc_iterator
public member functionsreference operator*() const;
pointer operator->() const;
trans_assoc_iterator & operator++() ;
trans_assoc_iterator & operator--() ;
trans_assoc_iterator operator++(int n) ;
trans_assoc_iterator operator--(int n) ;
base_iterator & base() ;
bool valid() const;