Tawara  0.1.0
simple_block.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_SIMPLE_BLOCK_H_)
40 #define TAWARA_SIMPLE_BLOCK_H_
41 
42 #include <tawara/block_element.h>
43 #include <tawara/block_impl.h>
44 #include <tawara/win_dll.h>
45 
48 
49 namespace tawara
50 {
60  public boost::equality_comparable<SimpleBlock>
61  {
62  public:
69  SimpleBlock(uint64_t track_number, int16_t timecode,
70  LacingType lacing=LACING_NONE);
71 
73  bool keyframe() const { return keyframe_; }
87  void keyframe(bool keyframe) { keyframe_ = keyframe; }
88 
90  bool discardable() const { return discardable_; }
102  void discardable(bool discardable) { discardable_ = discardable; }
103 
105  // Block interface
107 
114  virtual uint64_t track_number() const
115  { return block_.track_number(); }
117  virtual void track_number(uint64_t track_number)
118  { block_.track_number(track_number); }
119 
126  virtual int16_t timecode() const { return block_.timecode(); }
128  virtual void timecode(int16_t timecode)
129  { block_.timecode(timecode); }
130 
136  virtual bool invisible() const { return block_.invisible(); }
138  virtual void invisible(bool invisible)
139  { block_.invisible(invisible); }
140 
150  virtual LacingType lacing() const { return block_.lacing(); }
152  virtual void lacing(LacingType lacing)
153  { block_.lacing(lacing); }
154 
161  virtual value_type& at(size_type pos) { return block_.at(pos); }
168  virtual value_type const& at(size_type pos) const
169  { return block_.at(pos); }
170 
178  { return block_[pos]; }
185  virtual value_type const& operator[](size_type pos) const
186  { return block_[pos]; }
187 
189  virtual iterator begin() { return block_.begin(); }
191  virtual const_iterator begin() const { return block_.begin(); }
193  virtual iterator end() { return block_.end(); }
195  virtual const_iterator end() const { return block_.end(); }
197  virtual reverse_iterator rbegin() { return block_.rbegin(); }
200  { return block_.rbegin(); }
204  virtual reverse_iterator rend() { return block_.rend(); }
208  virtual const_reverse_iterator rend() const
209  { return block_.rend(); }
210 
216  virtual bool empty() const { return block_.empty(); }
218  virtual size_type count() const { return block_.count(); }
226  virtual size_type max_count() const { return block_.max_count(); }
227 
229  virtual void clear() { block_.clear(); }
230 
235  virtual void erase(iterator position) { block_.erase(position); }
241  virtual void erase(iterator first, iterator last)
242  { block_.erase(first, last); }
243 
256  virtual void push_back(value_type const& value)
257  { block_.push_back(value); }
258 
274  virtual void resize(size_type count) { block_.resize(count); }
275 
280  virtual void swap(SimpleBlock& other);
281 
283  friend bool operator==(SimpleBlock const& lhs,
284  SimpleBlock const& rhs);
285 
286  private:
287  bool keyframe_;
288  bool discardable_;
289  BlockImpl block_;
290 
292  // Element interface
294 
296  virtual std::streamsize body_size() const;
297 
299  virtual std::streamsize read_body(std::istream& input,
300  std::streamsize size);
301 
303  virtual std::streamsize write_body(std::ostream& output);
304  }; // class SimpleBlock
305 
307  bool operator==(SimpleBlock const& lhs, SimpleBlock const& rhs);
308 }; // namespace tawara
309 
311 // group elements
312 
313 #endif // TAWARA_SIMPLE_BLOCK_H_
314 
virtual const_iterator end() const
Get an iterator to the position past the last frame.
Definition: simple_block.h:195
virtual reverse_iterator rbegin()
Get a reverse iterator to the last frame.
Definition: simple_block.h:197
virtual void invisible(bool invisible)
Set if this block is invisible.
Definition: simple_block.h:138
virtual void track_number(uint64_t track_number)
Set the block's track number.
Definition: simple_block.h:117
LacingType
Lacing types.
Definition: block.h:69
virtual const_reverse_iterator rbegin() const
Get a reverse iterator to the last frame.
Definition: simple_block.h:199
std::streamsize size(ID id)
Get the number of bytes required by an ID.
#define TAWARA_EXPORT
Definition: win_dll.h:51
virtual value_type & operator[](size_type pos)
Get a reference to a frame.
Definition: simple_block.h:177
virtual void erase(iterator position)
Erase the frame at the specified iterator.
Definition: simple_block.h:235
std::vector< FramePtr >::const_iterator const_iterator
The constant random access iterator type.
Definition: block.h:93
virtual void lacing(LacingType lacing)
Set the lacing type in use.
Definition: simple_block.h:152
Common block functionality implementation.
Definition: block_impl.h:57
virtual iterator begin()
Get an iterator to the first frame.
Definition: simple_block.h:189
virtual void timecode(int16_t timecode)
Set the block's timecode.
Definition: simple_block.h:128
std::vector< FramePtr >::value_type value_type
The value type of this container.
Definition: block.h:83
virtual int16_t timecode() const
The timecode of this block.
Definition: simple_block.h:126
bool operator==(AttachedFile const &lhs, AttachedFile const &rhs)
Equality operator for the AttachedFile object.
virtual value_type & at(size_type pos)
Get the frame at the given position, with bounds checking.
Definition: simple_block.h:161
const ID SimpleBlock(0xA3)
std::vector< FramePtr >::size_type size_type
The size type of this container.
Definition: block.h:85
virtual const_reverse_iterator rend() const
Get a reverse iterator to the position before the first frame.
Definition: simple_block.h:208
virtual reverse_iterator rend()
Get a reverse iterator to the position before the first frame.
Definition: simple_block.h:204
virtual void push_back(value_type const &value)
Add a frame to this block.
Definition: simple_block.h:256
virtual uint64_t track_number() const
The block's track number.
Definition: simple_block.h:114
bool keyframe() const
Check if this block is a keyframe or not.
Definition: simple_block.h:73
std::vector< FramePtr >::reverse_iterator reverse_iterator
The reversed random access iterator type.
Definition: block.h:95
virtual bool invisible() const
If this block is invisible.
Definition: simple_block.h:136
virtual bool empty() const
Check if there are no frames.
Definition: simple_block.h:216
void keyframe(bool keyframe)
Set if this block is a keyframe.
Definition: simple_block.h:87
virtual void erase(iterator first, iterator last)
Erase a range of frames.
Definition: simple_block.h:241
virtual const_iterator begin() const
Get an iterator to the first frame.
Definition: simple_block.h:191
virtual value_type const & at(size_type pos) const
Get the frame at the given position, with bounds checking.
Definition: simple_block.h:168
virtual LacingType lacing() const
Get the lacing type in use.
Definition: simple_block.h:150
virtual void resize(size_type count)
Resizes the frames storage.
Definition: simple_block.h:274
virtual size_type count() const
Get the number of frames.
Definition: simple_block.h:218
virtual void clear()
Remove all frames.
Definition: simple_block.h:229
std::vector< FramePtr >::const_reverse_iterator const_reverse_iterator
The constant reversed random access iterator type.
Definition: block.h:98
virtual value_type const & operator[](size_type pos) const
Get a reference to a frame.
Definition: simple_block.h:185
The SimpleBlock element, a simplified version of Blocks.
Definition: simple_block.h:59
void discardable(bool discardable)
Set if this block can be discarded during playback.
Definition: simple_block.h:102
bool discardable() const
Check if this block can be discarded during playback.
Definition: simple_block.h:90
virtual iterator end()
Get an iterator to the position past the last frame.
Definition: simple_block.h:193
virtual size_type max_count() const
Get the maximum number of frames.
Definition: simple_block.h:226
std::vector< FramePtr >::iterator iterator
The random access iterator type.
Definition: block.h:91