Audacity  3.0.3
Classes | Macros | Typedefs | Functions
MemoryX.h File Reference
#include <iterator>
#include <memory>
#include <new>
#include <cstdlib>
#include <functional>
#include <limits>
#include <algorithm>
Include dependency graph for MemoryX.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ArrayOf< X >
 Memory.h template class for making an array of float, bool, etc. More...
 
class  ArraysOf< X >
 memory.h template class for making an array of arrays. More...
 
class  Optional< X >
 Like a smart pointer, allows for object to not exist (nullptr) More...
 
struct  freer
 
struct  Destroyer< T >
 A deleter class to supply the second template parameter of unique_ptr for classes like wxWindow that should be sent a message called Destroy rather than be deleted directly. More...
 
struct  Final_action< F >
 "finally" as in The C++ Programming Language, 4th ed., p. 358 Useful for defining ad-hoc RAII actions. typical usage: auto cleanup = finally([&]{ ... code; ... }); More...
 
struct  RestoreValue< T >
 Structure used by ValueRestorer. More...
 
class  ValueRestorer< T >
 Set a variable temporarily in a scope. More...
 
struct  IteratorRange< Iterator >
 A convenience for use with range-for. More...
 
struct  IteratorRange< Iterator >::identity< T >
 
struct  NonInterfering< T >
 

Macros

#define safenew   new
 
#define QUANTIZED_TIME(time, rate)   (floor(((double)(time) * (rate)) + 0.5) / (rate))
 
#define DB_TO_LINEAR(x)   (pow(10.0, (x) / 20.0))
 
#define LINEAR_TO_DB(x)   (20.0 * log10(x))
 
#define MAX_AUDIO   (1. - 1./(1<<15))
 

Typedefs

template<typename T >
using MallocPtr = std::unique_ptr< T, freer >
 
template<typename Character = char>
using MallocString = std::unique_ptr< Character[], freer >
 
template<typename T >
using Destroy_ptr = std::unique_ptr< T, Destroyer< T > >
 a convenience for using Destroyer More...
 
template<typename Value , typename Category = std::forward_iterator_tag>
using ValueIterator = std::iterator< Category, const Value, ptrdiff_t, void, const Value >
 A convenience for defining iterators that return rvalue types, so that they cooperate correctly with stl algorithms and std::reverse_iterator. More...
 

Functions

template<typename F >
Final_action< F > finally (F f)
 Function template with type deduction lets you construct Final_action without typing any angle brackets. More...
 
template<typename T >
ValueRestorer< T > valueRestorer (T &var)
 inline functions provide convenient parameter type deduction More...
 
template<typename T >
ValueRestorer< T > valueRestorer (T &var, const T &newValue)
 
template<typename Iterator >
IteratorRange< Iterator > make_iterator_range (const Iterator &i1, const Iterator &i2)
 
template<typename Container >
IteratorRange< typename Container::iterator > make_iterator_range (Container &container)
 
template<typename Container >
IteratorRange< typename Container::const_iterator > make_iterator_range (const Container &container)
 
template<typename Container , typename Iterator , typename Function >
Container transform_range (Iterator first, Iterator last, Function &&fn)
 
template<typename OutContainer , typename InContainer , typename Function >
OutContainer transform_container (InContainer &inContainer, Function &&fn)
 
struct UTILITY_API alignas (64) NonInterferingBase
 Non-template helper for class template NonInterfering. More...
 

Macro Definition Documentation

◆ DB_TO_LINEAR

#define DB_TO_LINEAR (   x)    (pow(10.0, (x) / 20.0))

Definition at line 628 of file MemoryX.h.

◆ LINEAR_TO_DB

#define LINEAR_TO_DB (   x)    (20.0 * log10(x))

Definition at line 629 of file MemoryX.h.

◆ MAX_AUDIO

#define MAX_AUDIO   (1. - 1./(1<<15))

Definition at line 631 of file MemoryX.h.

◆ QUANTIZED_TIME

#define QUANTIZED_TIME (   time,
  rate 
)    (floor(((double)(time) * (rate)) + 0.5) / (rate))

Definition at line 626 of file MemoryX.h.

◆ safenew

#define safenew   new

Definition at line 10 of file MemoryX.h.

Typedef Documentation

◆ Destroy_ptr

template<typename T >
using Destroy_ptr = std::unique_ptr<T, Destroyer<T> >

a convenience for using Destroyer

Definition at line 290 of file MemoryX.h.

◆ MallocPtr

template<typename T >
using MallocPtr = std::unique_ptr< T, freer >

A useful alias for holding the result of malloc

Definition at line 268 of file MemoryX.h.

◆ MallocString

template<typename Character = char>
using MallocString = std::unique_ptr< Character[], freer >

A useful alias for holding the result of strup and similar

Definition at line 274 of file MemoryX.h.

◆ ValueIterator

template<typename Value , typename Category = std::forward_iterator_tag>
using ValueIterator = std::iterator< Category, const Value, ptrdiff_t, void, const Value >

A convenience for defining iterators that return rvalue types, so that they cooperate correctly with stl algorithms and std::reverse_iterator.

Definition at line 366 of file MemoryX.h.

Function Documentation

◆ alignas()

struct UTILITY_API alignas ( 64  )

Non-template helper for class template NonInterfering.

If a structure contains any members with large alignment, this base class may also allow it to work in macOS builds under current limitations of the C++17 standard implementation.

Definition at line 578 of file MemoryX.h.

598  {
599  static void *operator new(std::size_t count, std::align_val_t al);
600  static void operator delete(void *ptr, std::align_val_t al);
601 
602 #if defined (_MSC_VER) && defined(_DEBUG)
603  // Versions that work in the presence of the DEBUG_NEW macro.
604  // Ignore the arguments supplied by the macro and forward to the
605  // other overloads.
606  static void *operator new(
607  std::size_t count, std::align_val_t al, int, const char *, int)
608  { return operator new(count, al); }
609  static void operator delete(
610  void *ptr, std::align_val_t al, int, const char *, int)
611  { return operator delete(ptr, al); }
612 #endif
613 };

◆ finally()

template<typename F >
Final_action<F> finally ( f)

Function template with type deduction lets you construct Final_action without typing any angle brackets.

Definition at line 310 of file MemoryX.h.

311 {
312  return Final_action<F>(f);
313 }

◆ make_iterator_range() [1/3]

template<typename Container >
IteratorRange< typename Container::const_iterator > make_iterator_range ( const Container &  container)

Definition at line 563 of file MemoryX.h.

564 {
565  return { container.begin(), container.end() };
566 }

◆ make_iterator_range() [2/3]

template<typename Iterator >
IteratorRange< Iterator > make_iterator_range ( const Iterator &  i1,
const Iterator &  i2 
)

Definition at line 549 of file MemoryX.h.

550 {
551  return { i1, i2 };
552 }

Referenced by ShuttleGuiBase::AddChoice(), ProjectFileManager::AddImportedTracks(), AudioIO::AllocateBuffers(), ChoiceEditor::BeginEdit(), PluginManager::CheckForUpdates(), WaveTrack::ClearAndPaste(), TrackList::Contains(), ProjectAudioManager::DoRecord(), ExportMP3::Export(), ExportFFmpegOptions::FetchCompatibleCodecList(), DeviceToolBar::FillHosts(), ExportFFmpegOptions::FindSelectedCodec(), ExportFFmpegOptions::FindSelectedFormat(), AudioIO::GetBestRate(), CommandManager::GetCategories(), DevicePrefs::GetNamesAndLabels(), AudioIOBase::GetOptimalSupportedSampleRate(), AudioIOBase::GetSupportedCaptureRates(), AudioIOBase::GetSupportedPlaybackRates(), AudioIOBase::GetSupportedSampleRates(), MacroCommands::IsFixed(), LangChoiceDialog::LangChoiceDialog(), LabelDialog::OnChangeTrack(), LabelDialog::OnInsert(), LangChoiceDialog::OnOk(), EffectUIHost::OnSaveAs(), KeyConfigPrefs::OnSet(), LabelTrackMenuTable::OnSetFont(), NyquistEffect::Parse(), ModuleManager::Providers(), ChoiceEditor::Reset(), Effect::SetAutomationParameters(), KeyConfigPrefs::SetKeyForSelected(), ThemeBase::ThemeTypeOfTypeName(), ShuttleGuiBase::TieChoice(), ShuttleGuiBase::TieNumberAsChoice(), NyquistEffect::Tokenizer::Tokenize(), ShuttleGuiBase::TranslateToIndex(), and OptionValidator::Validate().

Here is the caller graph for this function:

◆ make_iterator_range() [3/3]

template<typename Container >
IteratorRange< typename Container::iterator > make_iterator_range ( Container &  container)

Definition at line 556 of file MemoryX.h.

557 {
558  return { container.begin(), container.end() };
559 }

◆ transform_container()

template<typename OutContainer , typename InContainer , typename Function >
OutContainer transform_container ( InContainer &  inContainer,
Function &&  fn 
)

Definition at line 578 of file MemoryX.h.

579 {
580  return transform_range<OutContainer>(
581  inContainer.begin(), inContainer.end(), fn );
582 }

References fn.

◆ transform_range()

template<typename Container , typename Iterator , typename Function >
Container transform_range ( Iterator  first,
Iterator  last,
Function &&  fn 
)

Definition at line 570 of file MemoryX.h.

571 {
572  Container result;
573  std::transform( first, last, std::back_inserter( result ), fn );
574  return result;
575 }

References fn.

◆ valueRestorer() [1/2]

template<typename T >
ValueRestorer< T > valueRestorer ( T &  var)

◆ valueRestorer() [2/2]

template<typename T >
ValueRestorer< T > valueRestorer ( T &  var,
const T &  newValue 
)

Definition at line 358 of file MemoryX.h.

359 { return ValueRestorer< T >{ var, newValue }; }
fn
static const auto fn
Definition: WaveformView.cpp:1114
Final_action
"finally" as in The C++ Programming Language, 4th ed., p. 358 Useful for defining ad-hoc RAII actions...
Definition: MemoryX.h:301
ValueRestorer
Set a variable temporarily in a scope.
Definition: MemoryX.h:332