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

The Tracks element, listing all tracks in the segment. More...

#include <tawara/tracks.h>

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

Public Types

typedef uint64_t key_type
 The key type (Key) of this container. More...
 
typedef TrackEntry::Ptr mapped_type
 The mapped type (T) of this container. More...
 
typedef storage_type_::value_type value_type
 The value type of this container. More...
 
typedef storage_type_::size_type size_type
 The size type of this container. More...
 
typedef storage_type_::reference reference
 The reference type. More...
 
typedef
storage_type_::const_reference 
const_reference
 The constant reference type. More...
 
typedef storage_type_::iterator iterator
 The random access iterator type. More...
 
typedef
storage_type_::const_iterator 
const_iterator
 The constant random access iterator type. More...
 
typedef
storage_type_::reverse_iterator 
reverse_iterator
 The reversed random access iterator type. More...
 
typedef
storage_type_::const_reverse_iterator 
const_reverse_iterator
 The constant reversed random access iterator type. More...
 

Public Member Functions

 Tracks ()
 Construct a new Tracks element. More...
 
virtual ~Tracks ()
 Destructor. More...
 
mapped_typeat (key_type const &pos)
 Get the TrackEntry with the given track number. More...
 
mapped_type const & at (key_type const &pos) const
 Get the TrackEntry with the given track number. More...
 
mapped_typeoperator[] (key_type const &key)
 Gets a reference to the TrackEntry with the given track number. More...
 
mapped_type const & operator[] (key_type const &key) const
 Gets a reference to the TrackEntry with the given track number. More...
 
iterator begin ()
 Get an iterator to the first TrackEntry. More...
 
const_iterator begin () const
 Get an iterator to the first TrackEntry. More...
 
iterator end ()
 Get an iterator to the position past the last TrackEntry. More...
 
const_iterator end () const
 Get an iterator to the position past the last TrackEntry. More...
 
reverse_iterator rbegin ()
 Get a reverse iterator to the last TrackEntry. More...
 
const_reverse_iterator rbegin () const
 Get a reverse iterator to the last TrackEntry. More...
 
reverse_iterator rend ()
 Get a reverse iterator to the position before the first TrackEntry. More...
 
const_reverse_iterator rend () const
 Get a reverse iterator to the position before the first TrackEntry. More...
 
bool empty () const
 Check if there are no TrackElements. More...
 
size_type count () const
 Get the number of TrackElements. More...
 
size_type max_count () const
 Get the maximum number of TrackElements. More...
 
void clear ()
 Remove all TrackElements. More...
 
std::pair< iterator, bool > insert (mapped_type const &value)
 Insert a new TrackElement. More...
 
void insert (const_iterator first, const_iterator last)
 Insert a range of TrackElements. More...
 
void erase (iterator position)
 Erase the TrackEntry at the specified iterator. More...
 
void erase (iterator first, iterator last)
 Erase a range of TrackEntries. More...
 
size_type erase (key_type const &number)
 Erase the TrackEntry with the given track number. More...
 
void swap (Tracks &other)
 Swaps the contents of this Tracks element with another. More...
 
iterator find (key_type const &number)
 Search for the TrackEntry with the given track number. More...
 
const_iterator find (key_type const &number) const
 Search for the TrackEntry with the given track number. 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 size () const
 Get the total size of the element. More...
 
virtual std::streamsize write (std::ostream &output)
 Element writing. More...
 
virtual std::streamsize read (std::istream &input)
 Element reading. More...
 

Protected Types

typedef std::map< key_type,
mapped_type
storage_type_
 The type of the internal storage. More...
 

Protected Member Functions

virtual std::streamsize body_size () const
 Get the size of the body of this element. More...
 
virtual std::streamsize write_body (std::ostream &output)
 Element body writing. More...
 
virtual std::streamsize read_body (std::istream &input, std::streamsize size)
 Element body loading. More...
 
void validate_entries () const
 Checks for duplicate track numbers and UIDs. More...
 
void verify_not_duplicate (TrackEntry::Ptr entry) const
 Looks for a duplicate track entry, throws an exception if it is. More...
 
- Protected Member Functions inherited from tawara::Element
std::streamsize write_id (std::ostream &output)
 Element ID writing. More...
 
virtual std::streamsize write_size (std::ostream &output)
 Element size writing. More...
 

Protected Attributes

storage_type_ entries_
 The track entry store. More...
 
- Protected Attributes inherited from tawara::Element
tawara::ids::ID id_
 
std::streampos offset_
 

Friends

bool operator== (Tracks const &lhs, Tracks const &rhs)
 Equality operator. More...
 

Detailed Description

The Tracks element, listing all tracks in the segment.

The Tracks element contains the list of tracks that have data in the segment. Each track is represented by a TrackEntry element, and each has a number and a UID. The numbers and UIDs must be unique within the segment, and UIDs should be as unique as possible.

Definition at line 61 of file tracks.h.

Member Typedef Documentation

typedef storage_type_::const_iterator tawara::Tracks::const_iterator

The constant random access iterator type.

Definition at line 96 of file tracks.h.

typedef storage_type_::const_reference tawara::Tracks::const_reference

The constant reference type.

Definition at line 92 of file tracks.h.

typedef storage_type_::const_reverse_iterator tawara::Tracks::const_reverse_iterator

The constant reversed random access iterator type.

Definition at line 101 of file tracks.h.

typedef storage_type_::iterator tawara::Tracks::iterator

The random access iterator type.

Definition at line 94 of file tracks.h.

typedef uint64_t tawara::Tracks::key_type

The key type (Key) of this container.

Definition at line 66 of file tracks.h.

The mapped type (T) of this container.

Definition at line 68 of file tracks.h.

typedef storage_type_::reference tawara::Tracks::reference

The reference type.

Definition at line 90 of file tracks.h.

typedef storage_type_::reverse_iterator tawara::Tracks::reverse_iterator

The reversed random access iterator type.

Definition at line 98 of file tracks.h.

typedef storage_type_::size_type tawara::Tracks::size_type

The size type of this container.

Definition at line 88 of file tracks.h.

typedef std::map<key_type, mapped_type> tawara::Tracks::storage_type_
protected

The type of the internal storage.

Definition at line 72 of file tracks.h.

typedef storage_type_::value_type tawara::Tracks::value_type

The value type of this container.

Definition at line 83 of file tracks.h.

Constructor & Destructor Documentation

tawara::Tracks::Tracks ( )

Construct a new Tracks element.

Upon construction, the list of tracks will be empty. At least one TrackEntry must be added before writing the element.

virtual tawara::Tracks::~Tracks ( )
inlinevirtual

Destructor.

Definition at line 83 of file tracks.h.

Member Function Documentation

mapped_type& tawara::Tracks::at ( key_type const &  pos)
inline

Get the TrackEntry with the given track number.

Returns
A reference to the specified TrackEntry.
Exceptions
std::out_of_rangeif the track number is invalid.

Definition at line 108 of file tracks.h.

mapped_type const& tawara::Tracks::at ( key_type const &  pos) const
inline

Get the TrackEntry with the given track number.

Returns
A reference to the specified TrackEntry.
Exceptions
std::out_of_rangeif the track number is invalid.

Definition at line 115 of file tracks.h.

iterator tawara::Tracks::begin ( )
inline

Get an iterator to the first TrackEntry.

Definition at line 134 of file tracks.h.

const_iterator tawara::Tracks::begin ( ) const
inline

Get an iterator to the first TrackEntry.

Definition at line 136 of file tracks.h.

virtual std::streamsize tawara::Tracks::body_size ( ) const
protectedvirtual

Get the size of the body of this element.

Implements tawara::Element.

void tawara::Tracks::clear ( )
inline

Remove all TrackElements.

Definition at line 162 of file tracks.h.

size_type tawara::Tracks::count ( ) const
inline

Get the number of TrackElements.

Definition at line 157 of file tracks.h.

bool tawara::Tracks::empty ( ) const
inline

Check if there are no TrackElements.

Definition at line 155 of file tracks.h.

iterator tawara::Tracks::end ( )
inline

Get an iterator to the position past the last TrackEntry.

Definition at line 138 of file tracks.h.

const_iterator tawara::Tracks::end ( ) const
inline

Get an iterator to the position past the last TrackEntry.

Definition at line 140 of file tracks.h.

void tawara::Tracks::erase ( iterator  position)
inline

Erase the TrackEntry at the specified iterator.

Parameters
[in]positionThe position to erase at.

Definition at line 195 of file tracks.h.

void tawara::Tracks::erase ( iterator  first,
iterator  last 
)
inline

Erase a range of TrackEntries.

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

Definition at line 202 of file tracks.h.

size_type tawara::Tracks::erase ( key_type const &  number)
inline

Erase the TrackEntry with the given track number.

Parameters
[in]numberThe track number to erase.
Returns
The number of TrackEntries erased.

Definition at line 209 of file tracks.h.

iterator tawara::Tracks::find ( key_type const &  number)
inline

Search for the TrackEntry with the given track number.

Parameters
[in]numberThe track number to search for.
Returns
An iterator to the matching TrackEntry, or end() if there is no TrackEntry with that number.

Definition at line 224 of file tracks.h.

const_iterator tawara::Tracks::find ( key_type const &  number) const
inline

Search for the TrackEntry with the given track number.

Parameters
[in]numberThe track number to search for.
Returns
An iterator to the matching TrackEntry, or end() if there is no TrackEntry with that number.

Definition at line 232 of file tracks.h.

std::pair<iterator, bool> tawara::Tracks::insert ( mapped_type const &  value)

Insert a new TrackElement.

If a TrackElement already exists with the same track number, the new one will not replace it, and the return code will indicate that no insertion took place.

Parameters
[in]valueThe TrackEntry to insert. Its track number will be used as the key.
Returns
A pair of the iterator at the position where the TrackEntry was added (or blocked) and a boolean indicating if the insertion took place.
Exceptions
DuplicateTrackNumberif an existing track entry uses the same track number.
DuplicateUIDif an existing track entry uses the same UID.
void tawara::Tracks::insert ( const_iterator  first,
const_iterator  last 
)

Insert a range of TrackElements.

Parameters
[in]firstThe start of the range.
[in]lastThe end of the range.
Exceptions
DuplicateTrackNumberif an existing track entry uses the same track number.
DuplicateUIDif an existing track entry uses the same UID.
size_type tawara::Tracks::max_count ( ) const
inline

Get the maximum number of TrackElements.

Definition at line 159 of file tracks.h.

mapped_type& tawara::Tracks::operator[] ( key_type const &  key)

Gets a reference to the TrackEntry with the given track number.

Returns
A reference to a TrackEntry with the given track number.
Exceptions
std::out_of_rangeif the track number is invalid.
mapped_type const& tawara::Tracks::operator[] ( key_type const &  key) const

Gets a reference to the TrackEntry with the given track number.

Returns
A reference to a TrackEntry with the given track number.
Exceptions
std::out_of_rangeif the track number is invalid.
reverse_iterator tawara::Tracks::rbegin ( )
inline

Get a reverse iterator to the last TrackEntry.

Definition at line 142 of file tracks.h.

const_reverse_iterator tawara::Tracks::rbegin ( ) const
inline

Get a reverse iterator to the last TrackEntry.

Definition at line 144 of file tracks.h.

virtual std::streamsize tawara::Tracks::read_body ( std::istream &  input,
std::streamsize  size 
)
protectedvirtual

Element body loading.

Exceptions
DuplicateTrackNumberif more than one TrackEntry in the stored element has the same track number.
DuplicateUIDif more than one TrackEntry in the stored element has the same UID.

Implements tawara::Element.

reverse_iterator tawara::Tracks::rend ( )
inline

Get a reverse iterator to the position before the first TrackEntry.

Definition at line 148 of file tracks.h.

const_reverse_iterator tawara::Tracks::rend ( ) const
inline

Get a reverse iterator to the position before the first TrackEntry.

Definition at line 152 of file tracks.h.

void tawara::Tracks::swap ( Tracks other)
inline

Swaps the contents of this Tracks element with another.

Parameters
[in]otherThe other Tracks element to swap with.

Definition at line 215 of file tracks.h.

void tawara::Tracks::validate_entries ( ) const
protected

Checks for duplicate track numbers and UIDs.

Exceptions
DuplicateTrackNumberif more than one TrackEntry in the element has the same track number.
DuplicateUIDif more than one TrackEntry in the element has the same UID.
void tawara::Tracks::verify_not_duplicate ( TrackEntry::Ptr  entry) const
protected

Looks for a duplicate track entry, throws an exception if it is.

This function searchers the stored TrackEntry elements for one with the same track number OR track UID as the given entry. The result is indicated by throwing an exception. No exception means the TrackEntry is unique.

Parameters
[in]entryThe entry to look for a duplicate for.
Exceptions
DuplicateTrackNumberif more than one TrackEntry in the element has the same track number.
DuplicateUIDif more than one TrackEntry in the element has the same UID.
virtual std::streamsize tawara::Tracks::write_body ( std::ostream &  output)
protectedvirtual

Element body writing.

Exceptions
DuplicateTrackNumberif more than one TrackEntry in the element has the same track number.
DuplicateUIDif more than one TrackEntry in the element has the same UID.

Implements tawara::Element.

Friends And Related Function Documentation

bool operator== ( Tracks const &  lhs,
Tracks const &  rhs 
)
friend

Equality operator.

Member Data Documentation

storage_type_ tawara::Tracks::entries_
protected

The track entry store.

This must always be sorted by TrackNumber.

Definition at line 243 of file tracks.h.


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