Tide 0.1.0
|
00001 /* Tide 00002 * 00003 * Header file for the common Block functionality object. 00004 * 00005 * Copyright 2011 Geoffrey Biggs geoffrey.biggs@aist.go.jp 00006 * RT-Synthesis Research Group 00007 * Intelligent Systems Research Institute, 00008 * National Institute of Advanced Industrial Science and Technology (AIST), 00009 * Japan 00010 * All rights reserved. 00011 * 00012 * This file is part of Tide. 00013 * 00014 * Tide is free software; you can redistribute it and/or modify it under 00015 * the terms of the GNU Lesser General Public License as published by 00016 * the Free Software Foundation; either version 2.1 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * Tide is distributed in the hope that it will be useful, but WITHOUT 00020 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00021 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00022 * License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public 00025 * License along with Tide. If not, see <http://www.gnu.org/licenses/>. 00026 */ 00027 00028 #if !defined(TIDE_BLOCK_IMPL_H_) 00029 #define TIDE_BLOCK_IMPL_H_ 00030 00031 #include <stdint.h> 00032 #include <tide/block.h> 00033 #include <tide/win_dll.h> 00034 #include <utility> 00035 00038 00039 namespace tide 00040 { 00046 class TIDE_EXPORT BlockImpl : public Block, 00047 public boost::equality_comparable<BlockImpl> 00048 { 00049 public: 00051 BlockImpl(uint64_t track_number, int16_t timecode, 00052 LacingType lacing=LACING_NONE); 00053 00055 uint64_t track_number() const { return track_num_; } 00057 void track_number(uint64_t track_number) 00058 { track_num_ = track_number; } 00059 00061 int16_t timecode() const { return timecode_; } 00063 void timecode(int16_t timecode) { timecode_ = timecode; } 00064 00066 bool invisible() const { return invisible_; } 00068 void invisible(bool invisible) { invisible_ = invisible; } 00069 00071 LacingType lacing() const { return lacing_; } 00073 void lacing(LacingType lacing) { lacing_ = lacing; } 00074 00076 BlockImpl& operator=(BlockImpl const& other); 00077 00081 value_type& at(size_type pos) 00082 { return frames_.at(pos); } 00086 value_type const& at(size_type pos) const 00087 { return frames_.at(pos); } 00088 00092 value_type& operator[](size_type pos) 00093 { return frames_[pos]; } 00097 value_type const& operator[](size_type pos) const 00098 { return frames_[pos]; } 00099 00101 iterator begin() { return frames_.begin(); } 00103 const_iterator begin() const { return frames_.begin(); } 00105 iterator end() { return frames_.end(); } 00107 const_iterator end() const { return frames_.end(); } 00109 reverse_iterator rbegin() { return frames_.rbegin(); } 00111 const_reverse_iterator rbegin() const { return frames_.rbegin(); } 00115 reverse_iterator rend() { return frames_.rend(); } 00119 const_reverse_iterator rend() const { return frames_.rend(); } 00120 00122 bool empty() const { return frames_.empty(); } 00124 size_type count() const { return frames_.size(); } 00126 size_type max_count() const; 00127 00129 void clear() { frames_.clear(); } 00130 00132 void erase(iterator position) 00133 { frames_.erase(position); } 00135 void erase(iterator first, iterator last) 00136 { frames_.erase(first, last); } 00137 00139 void push_back(value_type const& value); 00140 00142 void resize(size_type count); 00143 00145 void swap(BlockImpl& other); 00146 00152 std::streamsize size() const; 00153 00172 std::streamsize write(std::ostream& output, uint8_t extra_flags); 00173 00180 typedef std::pair<std::streamsize, uint8_t> ReadResult; 00193 ReadResult read(std::istream& input, std::streamsize size); 00194 00196 friend bool operator==(BlockImpl const& lhs, BlockImpl const& rhs); 00197 00199 typedef boost::shared_ptr<std::vector<char> > value_type; 00200 00201 protected: 00202 uint64_t track_num_; 00203 int16_t timecode_; 00204 bool invisible_; 00205 LacingType lacing_; 00206 std::vector<value_type> frames_; 00207 00209 void validate() const; 00210 00212 void reset(); 00213 00224 std::streamsize read_ebml_laced_frames(std::istream& input, 00225 std::streamsize size); 00226 00241 std::streamsize read_fixed_frames(std::istream& input, 00242 std::streamsize size, unsigned int count); 00243 }; // class BlockImpl 00244 00246 bool operator==(BlockImpl const& lhs, BlockImpl const& rhs); 00247 }; // namespace tide 00248 00250 // group implementations 00251 00252 #endif // TIDE_BLOCK_IMPL_H_ 00253