|
libpsynth 0.2.1
|
00001 00011 /* 00012 * Copyright (C) 2010 Juan Pedro Bolivar Puente 00013 * 00014 * This file is part of Psychosynth. 00015 * 00016 * Psychosynth is free software: you can redistribute it and/or modify 00017 * it under the terms of the GNU General Public License as published by 00018 * the Free Software Foundation, either version 3 of the License, or 00019 * (at your option) any later version. 00020 * 00021 * Psychosynth is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU General Public License 00027 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00028 * 00029 */ 00030 00031 /* 00032 * Copyright 2005-2007 Adobe Systems Incorporated 00033 * 00034 * Use, modification and distribution are subject to the Boost 00035 * Software License, Version 1.0. (See accompanying file 00036 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). 00037 */ 00038 00039 #ifndef PSYNTH_SOUND_FRAME_ITERATOR_H 00040 #define PSYNTH_SOUND_FRAME_ITERATOR_H 00041 00042 #include <cassert> 00043 #include <iterator> 00044 00045 #include <psynth/base/compat.hpp> 00046 #include <psynth/sound/concept.hpp> 00047 #include <psynth/sound/util.hpp> 00048 #include <psynth/sound/frame.hpp> 00049 00050 namespace psynth 00051 { 00052 namespace sound 00053 { 00054 00055 /* forwarded declaration (as this file is included in 00056 * step_iterator.hpp) */ 00057 template <typename Iterator> 00058 class memory_based_step_iterator; 00059 00060 template <typename Iterator> struct dynamic_step_type; 00061 00069 template <typename It> 00070 struct is_iterator_adaptor : public boost::mpl::false_{}; 00071 00077 template <typename It> 00078 struct iterator_adaptor_get_base; 00079 00084 template <typename It, typename NewBaseIt> 00085 struct iterator_adaptor_rebind; 00086 00091 template <typename It> 00092 struct const_iterator_type; 00093 00098 template <typename T> 00099 struct const_iterator_type<T*> 00100 { 00101 typedef const T* type; 00102 }; 00103 00104 template <typename T> 00105 struct const_iterator_type<const T*> 00106 { 00107 typedef const T* type; 00108 }; 00109 00116 template <typename It> 00117 struct iterator_is_mutable{}; 00118 00123 template <typename T> struct iterator_is_mutable< T*> : public boost::mpl::true_ {}; 00124 template <typename T> struct iterator_is_mutable<const T*> : public boost::mpl::false_ {}; 00125 00137 /* 00138 * 00139 * HasDynamicStepTypeConcept 00140 * 00141 */ 00142 00144 template <typename Frame> 00145 struct dynamic_step_type<Frame*> 00146 { 00147 typedef memory_based_step_iterator<Frame*> type; 00148 }; 00149 00151 template <typename Frame> 00152 struct dynamic_step_type<const Frame*> 00153 { 00154 typedef memory_based_step_iterator<const Frame*> type; 00155 }; 00156 00157 00158 /* 00159 * 00160 * FrameBasedConcept 00161 * 00162 */ 00163 00164 template <typename Frame> 00165 struct channel_space_type<Frame*> : public channel_space_type<Frame> {}; 00166 template <typename Frame> 00167 struct channel_space_type<const Frame*> : public channel_space_type<Frame> {}; 00168 00169 template <typename Frame> 00170 struct sample_mapping_type<Frame*> : public sample_mapping_type<Frame> {}; 00171 template <typename Frame> 00172 struct sample_mapping_type<const Frame*> : public sample_mapping_type<Frame> {}; 00173 00174 template <typename Frame> 00175 struct is_planar<Frame*> : public is_planar<Frame> {}; 00176 template <typename Frame> 00177 struct is_planar<const Frame*> : public is_planar<Frame> {}; 00178 00179 00180 /* 00181 * 00182 * HomogeneousFrameBasedConcept 00183 * 00184 */ 00185 00186 template <typename Frame> 00187 struct sample_type<Frame*> : public sample_type<Frame> {}; 00188 template <typename Frame> 00189 struct sample_type<const Frame*> : public sample_type<Frame> {}; 00190 00191 00198 /* 00199 * 00200 * MemoryBasedIteratorConcept 00201 * 00202 */ 00203 00204 template <typename T> 00205 struct byte_to_memunit : public boost::mpl::int_<1> {}; 00206 00207 template <typename P> 00208 inline std::ptrdiff_t memunit_step (const P*) 00209 { 00210 return sizeof(P); 00211 } 00212 00213 template <typename P> 00214 inline std::ptrdiff_t memunit_distance (const P* p1, const P* p2) 00215 { 00216 return (psynth_reinterpret_cast_c<const unsigned char*> (p2) - 00217 psynth_reinterpret_cast_c<const unsigned char*> (p1)); 00218 } 00219 00220 template <typename P> 00221 inline void memunit_advance (P* &p, std::ptrdiff_t diff) 00222 { 00223 p = (P*) ((unsigned char*)(p) + diff); 00224 } 00225 00226 template <typename P> 00227 inline P* memunit_advanced (const P* p, std::ptrdiff_t diff) 00228 { 00229 return (P*) ((char*)(p) + diff); 00230 } 00231 00237 template <typename P> 00238 inline P& memunit_advanced_ref (P* p, std::ptrdiff_t diff) 00239 { 00240 return *memunit_advanced(p,diff); 00241 } 00242 00243 } /* namespace sound */ 00244 } /* namespace psynth */ 00245 00246 #endif /* PSYNTH_FRAME_ITERATOR */
1.7.4