Tawara  0.1.0
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
tawara::MemoryCluster Class Reference

The in-memory Cluster implementation. More...

#include <tawara/memory_cluster.h>

Inheritance diagram for tawara::MemoryCluster:
Inheritance graph
[legend]
Collaboration diagram for tawara::MemoryCluster:
Collaboration graph
[legend]

Classes

class  IteratorBase
 

Public Types

typedef boost::shared_ptr
< MemoryCluster
Ptr
 Pointer to a memory-based cluster. More...
 
typedef IteratorBase
< BlockElement::Ptr,
BlockStore::iterator > 
Iterator
 Block iterator interface. More...
 
typedef IteratorBase
< Block::ConstPtr,
BlockStore::const_iterator > 
ConstIterator
 Block const iterator interface. More...
 
- Public Types inherited from tawara::Cluster
typedef boost::shared_ptr
< Cluster
Ptr
 Pointer to a cluster. More...
 
typedef BlockElement::Ptr value_type
 The value type of this container. More...
 
typedef size_t size_type
 The size type of this container. More...
 
typedef value_typereference
 The reference type. More...
 
typedef value_type const & const_reference
 The constant reference type. More...
 

Public Member Functions

 MemoryCluster (uint64_t timecode=0)
 Construct a new cluster. More...
 
Iterator begin ()
 Access the start of the blocks. More...
 
ConstIterator begin () const
 Access the start of the blocks. More...
 
Iterator end ()
 Access the end of the blocks. More...
 
ConstIterator end () const
 Access the end of the blocks. More...
 
virtual bool empty () const
 Check if there are no blocks. More...
 
virtual size_type count () const
 Get the number of blocks. More...
 
virtual void clear ()
 Remove all blocks. More...
 
virtual void erase (Iterator position)
 Erase the block at the specified iterator. More...
 
virtual void erase (Iterator first, Iterator last)
 Erase a range of blocks. More...
 
virtual void push_back (value_type const &value)
 Add a block to this cluster. More...
 
std::streamsize finalise (std::ostream &output)
 Finalise writing of the cluster. More...
 
- Public Member Functions inherited from tawara::Cluster
 Cluster (uint64_t timecode=0)
 Construct a new Cluster. More...
 
virtual ~Cluster ()
 Destructor. More...
 
uint64_t timecode () const
 Get the cluster's timecode. More...
 
void timecode (uint64_t timecode)
 Set the cluster's timecode. More...
 
std::vector< SilentTrackNumber > & silent_tracks ()
 Get the list of silent tracks. More...
 
uint64_t position () const
 Get the position of this cluster in the segment. More...
 
uint64_t previous_size () const
 Get the size of the previous cluster in the segment. More...
 
void previous_size (uint64_t size)
 Set the size of the previous cluster in the segment. More...
 
std::streamsize size () const
 Get the total size of the element. More...
 
std::streamsize read (std::istream &input)
 Element reading. More...
 
- Public Member Functions inherited from tawara::MasterElement
 MasterElement (uint32_t id, bool crc=false)
 Create a new MasterElement. More...
 
virtual ~MasterElement ()
 Destructor. More...
 
- Public Member Functions inherited from tawara::Element
 Element (tawara::ids::ID id)
 Create a new Element. More...
 
virtual ~Element ()
 Destructor. More...
 
uint32_t id () const
 Get the element's ID. More...
 
std::streampos offset () const
 Get the element's offset in the byte stream. More...
 
virtual std::streamsize write (std::ostream &output)
 Element writing. More...
 

Protected Types

typedef std::vector
< BlockElement::Ptr
BlockStore
 Block storage type. More...
 

Protected Member Functions

std::streamsize blocks_size () const
 Get the size of the blocks in this cluster. More...
 
std::streamsize read_blocks (std::istream &input, std::streamsize size)
 Read the blocks in this cluster from the output stream. More...
 
- Protected Member Functions inherited from tawara::Cluster
std::streamsize meta_size () const
 Get the size of the meta-data portion of the body of. More...
 
std::streamsize body_size () const
 Get the size of the body of this element. More...
 
std::streamsize write_size (std::ostream &output)
 Element size writing. More...
 
std::streamsize write_body (std::ostream &output)
 Element body writing. More...
 
std::streamsize read_body (std::istream &input, std::streamsize size)
 Element body loading. More...
 
std::streamsize read_silent_tracks (std::istream &input)
 Read the SilentTracks child element. More...
 
virtual void reset ()
 Reset the cluster's members to default values. More...
 
- Protected Member Functions inherited from tawara::Element
std::streamsize write_id (std::ostream &output)
 Element ID writing. More...
 

Protected Attributes

BlockStore blocks_
 Block storage. More...
 
- Protected Attributes inherited from tawara::Cluster
UIntElement timecode_
 
std::vector< SilentTrackNumbersilent_tracks_
 
UIntElement position_
 
UIntElement prev_size_
 
bool writing_
 
- Protected Attributes inherited from tawara::Element
tawara::ids::ID id_
 
std::streampos offset_
 

Detailed Description

The in-memory Cluster implementation.

This implementation of the Cluster interface stores the entire cluster in memory, using a std::vector to store the Blocks. It provides rapid access to the blocks at the expense of a larger memory footprint and longer loading time when opening the cluster.

Definition at line 61 of file memory_cluster.h.

Member Typedef Documentation

typedef std::vector<BlockElement::Ptr> tawara::MemoryCluster::BlockStore
protected

Block storage type.

Definition at line 65 of file memory_cluster.h.

Block const iterator interface.

This interface provides access to the blocks in the cluster. The access is const, preventing modification of the blocks.

Definition at line 169 of file memory_cluster.h.

Block iterator interface.

This interface provides access to the blocks in the cluster.

Definition at line 162 of file memory_cluster.h.

typedef boost::shared_ptr<MemoryCluster> tawara::MemoryCluster::Ptr

Pointer to a memory-based cluster.

Definition at line 69 of file memory_cluster.h.

Constructor & Destructor Documentation

tawara::MemoryCluster::MemoryCluster ( uint64_t  timecode = 0)

Construct a new cluster.

Parameters
[in]timecodeThe timecode of the cluster, in the units specified by TimecodeScale.

Member Function Documentation

Iterator tawara::MemoryCluster::begin ( )

Access the start of the blocks.

Gets an iterator pointing to the first block in the cluster.

ConstIterator tawara::MemoryCluster::begin ( ) const

Access the start of the blocks.

Gets an iterator pointing to the first block in the cluster.

std::streamsize tawara::MemoryCluster::blocks_size ( ) const
protectedvirtual

Get the size of the blocks in this cluster.

Implements tawara::Cluster.

virtual void tawara::MemoryCluster::clear ( )
inlinevirtual

Remove all blocks.

Implements tawara::Cluster.

Definition at line 206 of file memory_cluster.h.

virtual size_type tawara::MemoryCluster::count ( ) const
inlinevirtual

Get the number of blocks.

Implements tawara::Cluster.

Definition at line 204 of file memory_cluster.h.

virtual bool tawara::MemoryCluster::empty ( ) const
inlinevirtual

Check if there are no blocks.

Implements tawara::Cluster.

Definition at line 202 of file memory_cluster.h.

Iterator tawara::MemoryCluster::end ( )

Access the end of the blocks.

Gets an iterator pointing beyond the last block in the cluster.

ConstIterator tawara::MemoryCluster::end ( ) const

Access the end of the blocks.

Gets an iterator pointing beyond the last block in the cluster.

virtual void tawara::MemoryCluster::erase ( Iterator  position)
inlinevirtual

Erase the block at the specified iterator.

Parameters
[in]positionThe position to erase at.

Definition at line 212 of file memory_cluster.h.

virtual void tawara::MemoryCluster::erase ( Iterator  first,
Iterator  last 
)
inlinevirtual

Erase a range of blocks.

Parameters
[in]firstThe start of the range.
[in]lastThe end of the range.

Definition at line 219 of file memory_cluster.h.

std::streamsize tawara::MemoryCluster::finalise ( std::ostream &  output)
virtual

Finalise writing of the cluster.

Implements tawara::Cluster.

virtual void tawara::MemoryCluster::push_back ( value_type const &  value)
inlinevirtual

Add a block to this cluster.

The cluster must be in the writable state. This means that write() has been called and finalise() has not been called.

Implements tawara::Cluster.

Definition at line 227 of file memory_cluster.h.

std::streamsize tawara::MemoryCluster::read_blocks ( std::istream &  input,
std::streamsize  size 
)
protectedvirtual

Read the blocks in this cluster from the output stream.

Implements tawara::Cluster.

Member Data Documentation

BlockStore tawara::MemoryCluster::blocks_
protected

Block storage.

Definition at line 235 of file memory_cluster.h.


The documentation for this class was generated from the following file: