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

The in-file Cluster implementation. More...

#include <tawara/file_cluster.h>

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

Classes

class  IteratorBase
 

Public Types

typedef boost::shared_ptr
< FileCluster
Ptr
 Pointer to a file-based cluster. More...
 
typedef IteratorBase
< BlockElement
Iterator
 File-based cluster 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

 FileCluster (uint64_t timecode=0)
 Construct a new cluster. More...
 
Iterator begin ()
 Access the start of the blocks. More...
 
Iterator end ()
 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 write (std::ostream &output)
 Element writing. 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...
 

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

std::ostream * ostream_
 
std::istream * istream_
 
std::streampos blocks_start_pos_
 
std::streampos blocks_end_pos_
 
- 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-file Cluster implementation.

This implementation of the cluster interface stores only a minimal amount of information in memory. When reading, each block is left in the file until needed. When writing, blocks are written to the file immediately as they become available. It provides a lower memory footprint than the MemoryCluster implementation, at the expense of slower block retrieval and addition.

Definition at line 62 of file file_cluster.h.

Member Typedef Documentation

File-based cluster iterator interface.

This interface provides access to the blocks in the cluster.

Definition at line 234 of file file_cluster.h.

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

Pointer to a file-based cluster.

Definition at line 66 of file file_cluster.h.

Constructor & Destructor Documentation

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

Construct a new cluster.

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

Member Function Documentation

Iterator tawara::FileCluster::begin ( )

Access the start of the blocks.

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

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

Get the size of the blocks in this cluster.

Implements tawara::Cluster.

virtual void tawara::FileCluster::clear ( )
virtual

Remove all blocks.

This will not erase the blocks from the file. It will instead overwrite them with a void element, hiding them.

Implements tawara::Cluster.

virtual size_type tawara::FileCluster::count ( ) const
virtual

Get the number of blocks.

Implements tawara::Cluster.

virtual bool tawara::FileCluster::empty ( ) const
virtual

Check if there are no blocks.

Implements tawara::Cluster.

Iterator tawara::FileCluster::end ( )

Access the end of the blocks.

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

virtual void tawara::FileCluster::erase ( Iterator  position)
virtual

Erase the block at the specified iterator.

This will not erase the block from the file. It will instead overwrite it with a void element, hiding the data.

Parameters
[in]positionThe position to erase at.
virtual void tawara::FileCluster::erase ( Iterator  first,
Iterator  last 
)
virtual

Erase a range of blocks.

This will not erase the blocks from the file. It will instead overwrite them with a void element, hiding them.

Parameters
[in]firstThe start of the range.
[in]lastThe end of the range.
std::streamsize tawara::FileCluster::finalise ( std::ostream &  output)
virtual

Finalise writing of the cluster.

Implements tawara::Cluster.

virtual void tawara::FileCluster::push_back ( value_type const &  value)
virtual

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.

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

Read the blocks in this cluster from the output stream.

Implements tawara::Cluster.

std::streamsize tawara::FileCluster::write ( std::ostream &  output)
virtual

Element writing.

Reimplemented from tawara::Element.

Member Data Documentation

std::streampos tawara::FileCluster::blocks_end_pos_
protected

Definition at line 302 of file file_cluster.h.

std::streampos tawara::FileCluster::blocks_start_pos_
protected

Definition at line 301 of file file_cluster.h.

std::istream* tawara::FileCluster::istream_
protected

Definition at line 300 of file file_cluster.h.

std::ostream* tawara::FileCluster::ostream_
protected

Definition at line 299 of file file_cluster.h.


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