Audacity 3.2.0
Namespaces | Classes | Functions
PackedArray Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  Deleter
 Deleter for an array of elements and optional contiguous header structure. More...
 
struct  Ptr
 Smart pointer type that deallocates with Deleter. More...
 
struct  Traits
 Primary template used in Deleter that can be specialized. More...
 
struct  Traits< AudioBufferList >
 
struct  Traits< AudioUnitCocoaViewInfo >
 

Functions

template<typename Type , template< typename > typename BaseDeleter>
size_t Count (const Ptr< Type, BaseDeleter > &p)
 Find out how many elements were allocated with a Ptr. More...
 
template<typename Type , template< typename > typename BaseDeleter>
auto begin (const Ptr< Type, BaseDeleter > &p)
 Enables range-for. More...
 
template<typename Type , template< typename > typename BaseDeleter>
auto end (const Ptr< Type, BaseDeleter > &p)
 Enables range-for. More...
 
template<typename Type >
auto AllocateBytes (size_t enlarged)
 Allocate a Ptr<Type> holding at least enlarged bytes. More...
 
template<typename Type >
auto AllocateCount (size_t count)
 Allocate a Ptr<Type> holding count elements. More...
 

Function Documentation

◆ AllocateBytes()

template<typename Type >
auto PackedArray::AllocateBytes ( size_t  enlarged)

Allocate a Ptr<Type> holding at least enlarged bytes.

Usage: AllocateBytes<Type>(bytes)(constructor arguments for Type) Meant to resemble placement-new syntax with separation of allocator and constructor arguments

Definition at line 192 of file PackedArray.h.

193{
194 return [enlarged](auto &&...args) {
195 return Ptr<Type>{
196 safenew(PackedArrayArg, enlarged)
197 Type{ std::forward<decltype(args)>(args)... },
198 std::max(sizeof(Type), enlarged) // Deleter's constructor argument
199 };
200 };
201}
#define safenew
Definition: MemoryX.h:10
static constexpr PackedArray_t PackedArrayArg
Tag argument to distinguish an overload of operator new.
Definition: PackedArray.h:171
Smart pointer type that deallocates with Deleter.
Definition: PackedArray.h:130

References PackedArrayArg, and safenew.

◆ AllocateCount()

template<typename Type >
auto PackedArray::AllocateCount ( size_t  count)

Allocate a Ptr<Type> holding count elements.

Usage: AllocateCount<Type>(count)(constructor arguments for Type) Meant to resemble placement-new syntax with separation of allocator and constructor arguments

If Traits<Type> defines a nonempty header, the result always holds at least one element

Definition at line 212 of file PackedArray.h.

213{
214 using traits_type = detail::ExtendedTraits<Type>;
215 const auto bytes = traits_type::element_offset()
216 + count * sizeof(typename traits_type::element_type);
217 return AllocateBytes<Type>(bytes);
218}
Primary template of metafunction deducing other things from Traits<T>
Definition: PackedArray.h:26

◆ begin()

template<typename Type , template< typename > typename BaseDeleter>
auto PackedArray::begin ( const Ptr< Type, BaseDeleter > &  p)
inline

Enables range-for.

Definition at line 150 of file PackedArray.h.

151{
152 using traits_type = detail::ExtendedTraits<Type>;
153 auto ptr = p.get();
154 return ptr ? traits_type::begin(ptr) : nullptr;
155}
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References begin().

Referenced by begin(), end(), and PackedArray::Ptr< Type, BaseDeleter >::operator[]().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Count()

template<typename Type , template< typename > typename BaseDeleter>
size_t PackedArray::Count ( const Ptr< Type, BaseDeleter > &  p)
inline

Find out how many elements were allocated with a Ptr.

Definition at line 143 of file PackedArray.h.

144{
145 return p.get_deleter().GetCount();
146}

Referenced by end(), AudioUnitEffectBase::InitializePlugin(), EffectRepeat::PopulateOrExchange(), AudioUnitInstance::ProcessBlock(), and AudioUnitInstance::Render().

Here is the caller graph for this function:

◆ end()

template<typename Type , template< typename > typename BaseDeleter>
auto PackedArray::end ( const Ptr< Type, BaseDeleter > &  p)
inline

Enables range-for.

Definition at line 159 of file PackedArray.h.

160{
161 auto result = begin(p);
162 if (result)
163 result += Count(p);
164 return result;
165}
size_t Count(const Ptr< Type, BaseDeleter > &p)
Find out how many elements were allocated with a Ptr.
Definition: PackedArray.h:143

References begin(), and Count().

Here is the call graph for this function: