Tawara  0.1.0
block_group.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, 2012, Geoffrey Biggs, geoffrey.biggs@aist.go.jp
5  * RT-Synthesis Research Group
6  * Intelligent Systems Research Institute,
7  * National Institute of Advanced Industrial Science and Technology (AIST),
8  * Japan
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * * Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * * Redistributions in binary form must reproduce the above
18  * copyright notice, this list of conditions and the following
19  * disclaimer in the documentation and/or other materials provided
20  * with the distribution.
21  * * Neither the name of Geoffrey Biggs nor AIST, nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #if !defined(TAWARA_BLOCK_GROUP_H_)
40 #define TAWARA_BLOCK_GROUP_H_
41 
42 #include <boost/operators.hpp>
43 #include <tawara/binary_element.h>
44 #include <tawara/block_element.h>
45 #include <tawara/block_additions.h>
46 #include <tawara/block_impl.h>
47 #include <tawara/master_element.h>
48 #include <tawara/uint_element.h>
49 #include <tawara/win_dll.h>
50 
53 
54 namespace tawara
55 {
66  class BlockGroup : public BlockElement,
67  public boost::equality_comparable<BlockGroup>
68  {
69  public:
78  BlockGroup(uint64_t track_number, int16_t timecode,
80  uint64_t ref_priority=0);
81 
84 
98  uint64_t duration() const { return duration_; }
100  void duration(uint64_t duration) { duration_ = duration; }
101 
108  uint64_t ref_priority() const { return ref_priority_; }
110  void ref_priority(uint64_t ref_priority)
112 
119  std::vector<int16_t>& ref_blocks() { return ref_blocks_; }
120 
127  std::vector<char> codec_state() const
128  { return codec_state_; }
130  void codec_state(std::vector<char> const& codec_state)
132 
134  // Block interface
136 
143  virtual uint64_t track_number() const
144  { return block_.track_number(); }
146  virtual void track_number(uint64_t track_number)
147  { block_.track_number(track_number); }
148 
155  virtual int16_t timecode() const { return block_.timecode(); }
157  virtual void timecode(int16_t timecode)
158  { block_.timecode(timecode); }
159 
165  virtual bool invisible() const { return block_.invisible(); }
167  virtual void invisible(bool invisible)
168  { block_.invisible(invisible); }
169 
179  virtual LacingType lacing() const { return block_.lacing(); }
181  virtual void lacing(LacingType lacing)
182  { block_.lacing(lacing); }
183 
190  virtual value_type& at(size_type pos) { return block_.at(pos); }
197  virtual value_type const& at(size_type pos) const
198  { return block_.at(pos); }
199 
207  { return block_[pos]; }
214  virtual value_type const& operator[](size_type pos) const
215  { return block_[pos]; }
216 
218  virtual iterator begin() { return block_.begin(); }
220  virtual const_iterator begin() const { return block_.begin(); }
222  virtual iterator end() { return block_.end(); }
224  virtual const_iterator end() const { return block_.end(); }
226  virtual reverse_iterator rbegin() { return block_.rbegin(); }
229  { return block_.rbegin(); }
233  virtual reverse_iterator rend() { return block_.rend(); }
237  virtual const_reverse_iterator rend() const
238  { return block_.rend(); }
239 
245  virtual bool empty() const { return block_.empty(); }
247  virtual size_type count() const { return block_.count(); }
255  virtual size_type max_count() const { return block_.max_count(); }
256 
258  virtual void clear() { block_.clear(); }
259 
264  virtual void erase(iterator position) { block_.erase(position); }
270  virtual void erase(iterator first, iterator last)
271  { block_.erase(first, last); }
272 
285  virtual void push_back(value_type const& value)
286  { block_.push_back(value); }
287 
303  virtual void resize(size_type count) { block_.resize(count); }
304 
309  virtual void swap(BlockGroup& other);
310 
312  friend bool operator==(BlockGroup const& lhs,
313  BlockGroup const& rhs);
314 
315  protected:
319  std::vector<int16_t> ref_blocks_;
322 
324  // Element interface
326 
328  virtual std::streamsize body_size() const;
329 
331  virtual std::streamsize read_body(std::istream& input,
332  std::streamsize size);
333 
335  virtual std::streamsize write_body(std::ostream& output);
336 
338  void reset();
339  }; // class BlockGroup
340 
342  bool operator==(BlockGroup const& lhs, BlockGroup const& rhs);
343 }; // namespace tawara
344 
346 // group elements
347 
348 #endif // TAWARA_BLOCK_GROUP_H_
349 
virtual bool invisible() const
If this block is invisible.
Definition: block_group.h:165
virtual uint64_t track_number() const
The block's track number.
Definition: block_group.h:143
std::vector< int16_t > & ref_blocks()
Get the reference block timecode array.
Definition: block_group.h:119
virtual int16_t timecode() const
The timecode of this block.
Definition: block_group.h:155
size_type count() const
Get the number of frames.
Definition: block_impl.h:135
LacingType
Lacing types.
Definition: block.h:69
void push_back(value_type const &value)
Add a frame to this block.
virtual reverse_iterator rend()
Get a reverse iterator to the position before the first frame.
Definition: block_group.h:233
virtual void swap(BlockGroup &other)
Swaps the contents of this block with another.
virtual value_type & operator[](size_type pos)
Get a reference to a frame.
Definition: block_group.h:206
virtual void track_number(uint64_t track_number)
Set the block's track number.
Definition: block_group.h:146
virtual reverse_iterator rbegin()
Get a reverse iterator to the last frame.
Definition: block_group.h:226
std::vector< FramePtr >::const_iterator const_iterator
The constant random access iterator type.
Definition: block.h:93
virtual size_type max_count() const
Get the maximum number of frames.
Definition: block_group.h:255
Common block functionality implementation.
Definition: block_impl.h:57
UIntElement ref_priority_
Definition: block_group.h:318
virtual void lacing(LacingType lacing)
Set the lacing type in use.
Definition: block_group.h:181
virtual value_type const & at(size_type pos) const
Get the frame at the given position, with bounds checking.
Definition: block_group.h:197
virtual size_type count() const
Get the number of frames.
Definition: block_group.h:247
std::vector< int16_t > ref_blocks_
Definition: block_group.h:319
void reset()
Reset all values to their defaults.
std::vector< FramePtr >::value_type value_type
The value type of this container.
Definition: block.h:83
virtual iterator end()
Get an iterator to the position past the last frame.
Definition: block_group.h:222
iterator begin()
Get an iterator to the first frame.
Definition: block_impl.h:112
Binary primitive element.
bool invisible() const
If this block is invisible.
Definition: block_impl.h:77
uint64_t ref_priority() const
Get the block's reference priority.
Definition: block_group.h:108
reverse_iterator rbegin()
Get a reverse iterator to the last frame.
Definition: block_impl.h:120
virtual value_type & at(size_type pos)
Get the frame at the given position, with bounds checking.
Definition: block_group.h:190
void clear()
Remove all frames.
Definition: block_impl.h:140
friend bool operator==(BlockGroup const &lhs, BlockGroup const &rhs)
Equality operator.
virtual const_iterator end() const
Get an iterator to the position past the last frame.
Definition: block_group.h:224
bool operator==(AttachedFile const &lhs, AttachedFile const &rhs)
Equality operator for the AttachedFile object.
void resize(size_type count)
Resizes the frames storage.
virtual std::streamsize write_body(std::ostream &output)
Element body writing.
BlockAdditions & additions()
Access the block additions property.
Definition: block_group.h:83
virtual std::streamsize size() const
Get the total size of the element.
std::vector< FramePtr >::size_type size_type
The size type of this container.
Definition: block.h:85
void ref_priority(uint64_t ref_priority)
Set the block's reference priority.
Definition: block_group.h:110
virtual void timecode(int16_t timecode)
Set the block's timecode.
Definition: block_group.h:157
UIntElement duration_
Definition: block_group.h:317
virtual LacingType lacing() const
Get the lacing type in use.
Definition: block_group.h:179
bool empty() const
Check if there are no frames.
Definition: block_impl.h:133
Unsigned integer primitive element.
Definition: uint_element.h:57
virtual void clear()
Remove all frames.
Definition: block_group.h:258
virtual std::streamsize body_size() const
Get the size of the body of this element.
virtual void invisible(bool invisible)
Set if this block is invisible.
Definition: block_group.h:167
BinaryElement codec_state_
Definition: block_group.h:320
virtual void erase(iterator position)
Erase the frame at the specified iterator.
Definition: block_group.h:264
reverse_iterator rend()
Get a reverse iterator to the position before the first frame.
Definition: block_impl.h:126
virtual void push_back(value_type const &value)
Add a frame to this block.
Definition: block_group.h:285
std::vector< FramePtr >::reverse_iterator reverse_iterator
The reversed random access iterator type.
Definition: block.h:95
LacingType lacing() const
Get the lacing type in use.
Definition: block_impl.h:82
void duration(uint64_t duration)
Set the block's duration.
Definition: block_group.h:100
BlockAdditions additions_
Definition: block_group.h:316
virtual const_reverse_iterator rend() const
Get a reverse iterator to the position before the first frame.
Definition: block_group.h:237
This element is used to specify reference blocks.
virtual bool empty() const
Check if there are no frames.
Definition: block_group.h:245
virtual iterator begin()
Get an iterator to the first frame.
Definition: block_group.h:218
virtual value_type const & operator[](size_type pos) const
Get a reference to a frame.
Definition: block_group.h:214
void erase(iterator position)
Erase the frame at the specified iterator.
Definition: block_impl.h:143
value_type & at(size_type pos)
Get the frame at the given position, with bounds checking.
Definition: block_impl.h:92
BlockGroup(uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE, uint64_t duration=0, uint64_t ref_priority=0)
Create a new BlockGroup.
std::vector< FramePtr >::const_reverse_iterator const_reverse_iterator
The constant reversed random access iterator type.
Definition: block.h:98
uint64_t duration() const
Get the block's duration.
Definition: block_group.h:98
virtual void resize(size_type count)
Resizes the frames storage.
Definition: block_group.h:303
uint64_t track_number() const
The block's track number.
Definition: block_impl.h:66
virtual void erase(iterator first, iterator last)
Erase a range of frames.
Definition: block_group.h:270
std::vector< char > codec_state() const
Get the codec state for this block.
Definition: block_group.h:127
int16_t timecode() const
The timecode of this block.
Definition: block_impl.h:72
virtual const_iterator begin() const
Get an iterator to the first frame.
Definition: block_group.h:220
virtual std::streamsize read_body(std::istream &input, std::streamsize size)
Element body loading.
void codec_state(std::vector< char > const &codec_state)
Set the codec state for this block.
Definition: block_group.h:130
The BlockGroup is the standard block.
Definition: block_group.h:66
size_type max_count() const
Get the maximum number of frames.
virtual const_reverse_iterator rbegin() const
Get a reverse iterator to the last frame.
Definition: block_group.h:228
iterator end()
Get an iterator to the position past the last frame.
Definition: block_impl.h:116
std::vector< FramePtr >::iterator iterator
The random access iterator type.
Definition: block.h:91