foobar2000 SDK  2015-08-03
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
pfc::alloc_fixed< p_width >::alloc< t_item >

#include <alloc.h>

Public Types

enum  { alloc_prioritizes_speed = false }
 

Public Member Functions

 alloc ()
 
 ~alloc ()
 
void force_reset ()
 
t_item * get_ptr ()
 
const t_item * get_ptr () const
 
t_size get_size () const
 
bool is_ptr_owned (const void *p_item) const
 
void move_from (t_self &other)
 
const t_item & operator[] (t_size n) const
 
t_item & operator[] (t_size n)
 
void prealloc (t_size)
 
void set_size (t_size p_size)
 

Private Types

typedef alloc< t_item > t_self
 

Private Member Functions

 alloc (const t_self &)
 
const t_selfoperator= (const t_self &)
 

Private Attributes

t_uint8 m_array [sizeof(t_item[p_width])]
 
t_size m_size
 

Detailed Description

template<t_size p_width>
template<typename t_item>
class pfc::alloc_fixed< p_width >::alloc< t_item >

Definition at line 417 of file alloc.h.

Member Typedef Documentation

template<t_size p_width>
template<typename t_item >
typedef alloc<t_item> pfc::alloc_fixed< p_width >::alloc< t_item >::t_self
private

Definition at line 418 of file alloc.h.

Member Enumeration Documentation

template<t_size p_width>
template<typename t_item >
anonymous enum
Enumerator
alloc_prioritizes_speed 

Definition at line 450 of file alloc.h.

Constructor & Destructor Documentation

template<t_size p_width>
template<typename t_item >
pfc::alloc_fixed< p_width >::alloc< t_item >::alloc ( )
inline

Definition at line 420 of file alloc.h.

420 : m_size(0) {}
template<t_size p_width>
template<typename t_item >
pfc::alloc_fixed< p_width >::alloc< t_item >::~alloc ( )
inline

Definition at line 435 of file alloc.h.

435  {
437  }
void set_size(t_size p_size)
Definition: alloc.h:422
template<t_size p_width>
template<typename t_item >
pfc::alloc_fixed< p_width >::alloc< t_item >::alloc ( const t_self )
inlineprivate

Definition at line 458 of file alloc.h.

458 {throw pfc::exception_not_implemented();}

Member Function Documentation

template<t_size p_width>
template<typename t_item >
void pfc::alloc_fixed< p_width >::alloc< t_item >::force_reset ( )
inline

Definition at line 448 of file alloc.h.

448 {set_size(0);}
void set_size(t_size p_size)
Definition: alloc.h:422
template<t_size p_width>
template<typename t_item >
t_item* pfc::alloc_fixed< p_width >::alloc< t_item >::get_ptr ( )
inline

Definition at line 441 of file alloc.h.

441 {return reinterpret_cast<t_item*>(&m_array);}
t_uint8 m_array[sizeof(t_item[p_width])]
Definition: alloc.h:461
template<t_size p_width>
template<typename t_item >
const t_item* pfc::alloc_fixed< p_width >::alloc< t_item >::get_ptr ( ) const
inline

Definition at line 442 of file alloc.h.

442 {return reinterpret_cast<const t_item*>(&m_array);}
t_uint8 m_array[sizeof(t_item[p_width])]
Definition: alloc.h:461
template<t_size p_width>
template<typename t_item >
t_size pfc::alloc_fixed< p_width >::alloc< t_item >::get_size ( ) const
inline

Definition at line 439 of file alloc.h.

439 {return m_size;}
template<t_size p_width>
template<typename t_item >
bool pfc::alloc_fixed< p_width >::alloc< t_item >::is_ptr_owned ( const void *  p_item) const
inline

Definition at line 446 of file alloc.h.

446 {return is_pointer_in_range(get_ptr(),p_width,p_item);}
t_item * get_ptr()
Definition: alloc.h:441
bool is_pointer_in_range(const t_item *p_buffer, t_size p_buffer_size, const void *p_pointer)
Definition: alloc.h:84
template<t_size p_width>
template<typename t_item >
void pfc::alloc_fixed< p_width >::alloc< t_item >::move_from ( t_self other)
inline

Definition at line 452 of file alloc.h.

452  {
453  const size_t count = other.get_size();
454  set_size( count );
455  for(size_t w = 0; w < count; ++w) this->get_ptr()[w] = other.get_ptr()[w];
456  }
void set_size(t_size p_size)
Definition: alloc.h:422
t_item * get_ptr()
Definition: alloc.h:441
template<t_size p_width>
template<typename t_item >
const t_self& pfc::alloc_fixed< p_width >::alloc< t_item >::operator= ( const t_self )
inlineprivate

Definition at line 459 of file alloc.h.

459 {throw pfc::exception_not_implemented();}
template<t_size p_width>
template<typename t_item >
const t_item& pfc::alloc_fixed< p_width >::alloc< t_item >::operator[] ( t_size  n) const
inline

Definition at line 444 of file alloc.h.

444 {return get_ptr()[n];}
t_item * get_ptr()
Definition: alloc.h:441
template<t_size p_width>
template<typename t_item >
t_item& pfc::alloc_fixed< p_width >::alloc< t_item >::operator[] ( t_size  n)
inline

Definition at line 445 of file alloc.h.

445 {return get_ptr()[n];}
t_item * get_ptr()
Definition: alloc.h:441
template<t_size p_width>
template<typename t_item >
void pfc::alloc_fixed< p_width >::alloc< t_item >::prealloc ( t_size  )
inline

Definition at line 447 of file alloc.h.

447 {}
template<t_size p_width>
template<typename t_item >
void pfc::alloc_fixed< p_width >::alloc< t_item >::set_size ( t_size  p_size)
inline

Definition at line 422 of file alloc.h.

422  {
423  static_assert_t<sizeof(m_array) == sizeof(t_item[p_width])>();
424 
425  if (p_size > p_width) throw pfc::exception_overflow();
426  else if (p_size > m_size) {
428  m_size = p_size;
429  } else if (p_size < m_size) {
431  m_size = p_size;
432  }
433  }
void __unsafe__in_place_destructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:123
t_type * __unsafe__in_place_constructor_array_t(t_type *p_items, t_size p_count)
Definition: primitives.h:130
t_item * get_ptr()
Definition: alloc.h:441

Field Documentation

template<t_size p_width>
template<typename t_item >
t_uint8 pfc::alloc_fixed< p_width >::alloc< t_item >::m_array[sizeof(t_item[p_width])]
private

Definition at line 461 of file alloc.h.

template<t_size p_width>
template<typename t_item >
t_size pfc::alloc_fixed< p_width >::alloc< t_item >::m_size
private

Definition at line 462 of file alloc.h.


The documentation for this class was generated from the following file: