39 #if !defined(TAWARA_MEMORY_CLUSTER_H_)
40 #define TAWARA_MEMORY_CLUSTER_H_
42 #include <boost/iterator/iterator_facade.hpp>
43 #include <boost/type_traits/is_convertible.hpp>
44 #include <boost/utility/enable_if.hpp>
69 typedef boost::shared_ptr<MemoryCluster>
Ptr;
82 template <
typename BlockType,
typename IterType>
84 :
public boost::iterator_facade<
85 IteratorBase<BlockType, IterType>,
86 BlockType, boost::bidirectional_traversal_tag>
111 template <
typename OtherType,
typename OtherIterType>
119 friend class boost::iterator_core_access;
142 template <
typename OtherType,
typename OtherIterType>
146 return iter_ == other.
iter_;
202 virtual bool empty()
const {
return blocks_.empty(); }
206 virtual void clear() { blocks_.clear(); }
212 virtual void erase(Iterator position)
213 { blocks_.erase(position.
iter_); }
219 virtual void erase(Iterator first, Iterator last)
228 { blocks_.push_back(value); }
231 std::streamsize finalise(std::ostream& output);
238 std::streamsize blocks_size()
const;
241 std::streamsize read_blocks(std::istream& input,
242 std::streamsize
size);
249 #endif // TAWARA_MEMORY_CLUSTER_H_
virtual bool empty() const
Check if there are no blocks.
bool equal(IteratorBase< OtherType, OtherIterType > const &other) const
Test for equality with another Iterator.
void decrement()
Decrement the Iterator to the previous block.
std::streamsize size(ID id)
Get the number of bytes required by an ID.
BlockElement::Ptr value_type
The value type of this container.
IteratorBase()
Base constructor.
void increment()
Increment the Iterator to the next block.
virtual void erase(Iterator position)
Erase the block at the specified iterator.
The in-memory Cluster implementation.
BlockType & dereference() const
Dereference the iterator to get the Block pointer.
IteratorBase(IterType iter)
Constructor.
IteratorBase(IteratorBase< OtherType, OtherIterType > const &other)
Templated base constructor.
The base Cluster, defining the common interface for Cluster element implementations.
virtual size_type count() const
Get the number of blocks.
virtual void clear()
Remove all blocks.
size_t size_type
The size type of this container.
virtual void erase(Iterator first, Iterator last)
Erase a range of blocks.
BlockStore blocks_
Block storage.
virtual void push_back(value_type const &value)
Add a block to this cluster.
boost::shared_ptr< MemoryCluster > Ptr
Pointer to a memory-based cluster.
std::vector< BlockElement::Ptr > BlockStore
Block storage type.
IteratorBase< BlockElement::Ptr, BlockStore::iterator > Iterator
Block iterator interface.
IteratorBase< Block::ConstPtr, BlockStore::const_iterator > ConstIterator
Block const iterator interface.