diff options
author | Sakari Bergen <sakari.bergen@beatwaves.net> | 2010-03-15 19:11:48 +0000 |
---|---|---|
committer | Sakari Bergen <sakari.bergen@beatwaves.net> | 2010-03-15 19:11:48 +0000 |
commit | 830911f6f9451d83a58043b3f9084d3caa164b7b (patch) | |
tree | f4ca4e3d86b51d66e7cecfb6b370cc4eb553e2d7 /libs/audiographer/audiographer/type_utils.h | |
parent | 44f4b84551d36ef4103d09452768f5ba53e0002c (diff) |
Fix export, which has been broken since the boost::signals2 changes. Also update Audiographer, bacause of its incomplete sndfile handling. Audiographer is equal to revision 74
git-svn-id: svn://localhost/ardour2/branches/3.0@6760 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/audiographer/audiographer/type_utils.h')
-rw-r--r-- | libs/audiographer/audiographer/type_utils.h | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/libs/audiographer/audiographer/type_utils.h b/libs/audiographer/audiographer/type_utils.h index 84a28f3d07..d17f3634ed 100644 --- a/libs/audiographer/audiographer/type_utils.h +++ b/libs/audiographer/audiographer/type_utils.h @@ -1,7 +1,7 @@ #ifndef AUDIOGRAPHER_TYPE_UTILS_H #define AUDIOGRAPHER_TYPE_UTILS_H -#include "types.h" +#include "audiographer/types.h" #include <boost/static_assert.hpp> #include <boost/type_traits.hpp> #include <memory> @@ -10,22 +10,22 @@ namespace AudioGrapher { +/// Non-template base class for TypeUtils class TypeUtilsBase { protected: template<typename T, bool b> - static void do_fill(T * buffer, nframes_t frames, const boost::integral_constant<bool, b>&) + static void do_zero_fill(T * buffer, nframes_t frames, const boost::integral_constant<bool, b>&) { std::uninitialized_fill_n (buffer, frames, T()); } template<typename T> - static void do_fill(T * buffer, nframes_t frames, const boost::true_type&) - { memset (buffer, frames * sizeof(T), 0); } - - private: + static void do_zero_fill(T * buffer, nframes_t frames, const boost::true_type&) + { memset (buffer, 0, frames * sizeof(T)); } }; -template<typename T> +/// Utilities for initializing, copying, moving, etc. data +template<typename T = DefaultSampleType> class TypeUtils : private TypeUtilsBase { BOOST_STATIC_ASSERT (boost::has_trivial_destructor<T>::value); @@ -34,23 +34,33 @@ class TypeUtils : private TypeUtilsBase boost::is_floating_point<T>::value || boost::is_signed<T>::value> zero_fillable; public: + /** Fill buffer with a zero value + * The value used for filling is either 0 or the value of T() + * if T is not a floating point or signed integer type + * \n RT safe + */ inline static void zero_fill (T * buffer, nframes_t frames) { do_zero_fill(buffer, frames, zero_fillable()); } - inline static void copy (T* source, T* destination, nframes_t frames) + /** Copies \a frames frames of data from \a source to \a destination + * The source and destination may NOT overlap. + * \n RT safe + */ + inline static void copy (T const * source, T * destination, nframes_t frames) { std::uninitialized_copy (source, &source[frames], destination); } - inline static void move (T* source, T* destination, nframes_t frames) + /** Moves \a frames frames of data from \a source to \a destination + * The source and destination may overlap in any way. + * \n RT safe + */ + inline static void move (T const * source, T * destination, nframes_t frames) { if (destination < source) { std::copy (source, &source[frames], destination); - } else { - std::copy_backward (source, &source[frames], destination); + } else if (destination > source) { + std::copy_backward (source, &source[frames], destination + frames); } } - - private: - }; |