Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
SampleBlockFactory Class Referenceabstract

abstract base class with methods to produce SampleBlock objects More...

#include <SampleBlock.h>

Inheritance diagram for SampleBlockFactory:
[legend]
Collaboration diagram for SampleBlockFactory:
[legend]

Classes

struct  Factory
 Global factory of per-project factories of sample blocks. More...
 

Public Types

using SampleBlockIDs = std::unordered_set< SampleBlockID >
 
- Public Types inherited from Observer::Publisher< SampleBlockCreateMessage >
using message_type = SampleBlockCreateMessage
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const SampleBlockCreateMessage &) >
 Type of functions that can be connected to the Publisher. More...
 

Public Member Functions

virtual ~SampleBlockFactory ()
 
SampleBlockPtr Create (constSamplePtr src, size_t numsamples, sampleFormat srcformat)
 
SampleBlockPtr CreateSilent (size_t numsamples, sampleFormat srcformat)
 
SampleBlockPtr CreateFromXML (sampleFormat srcformat, const AttributesList &attrs)
 
SampleBlockPtr CreateFromId (sampleFormat srcformat, SampleBlockID id)
 
virtual SampleBlockIDs GetActiveBlockIDs ()=0
 
- Public Member Functions inherited from Observer::Publisher< SampleBlockCreateMessage >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Static Public Member Functions

static SampleBlockFactoryPtr New (AudacityProject &project)
 

Protected Member Functions

virtual SampleBlockPtr DoCreate (constSamplePtr src, size_t numsamples, sampleFormat srcformat)=0
 
virtual SampleBlockPtr DoCreateSilent (size_t numsamples, sampleFormat srcformat)=0
 
virtual SampleBlockPtr DoCreateFromXML (sampleFormat srcformat, const AttributesList &attrs)=0
 
virtual SampleBlockPtr DoCreateFromId (sampleFormat srcformat, SampleBlockID id)=0
 
- Protected Member Functions inherited from Observer::Publisher< SampleBlockCreateMessage >
CallbackReturn Publish (const SampleBlockCreateMessage &message)
 Send a message to connected callbacks. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Observer::Publisher< SampleBlockCreateMessage >
static constexpr bool notifies_all
 

Detailed Description

abstract base class with methods to produce SampleBlock objects

Definition at line 115 of file SampleBlock.h.

Member Typedef Documentation

◆ SampleBlockIDs

Definition at line 147 of file SampleBlock.h.

Constructor & Destructor Documentation

◆ ~SampleBlockFactory()

SampleBlockFactory::~SampleBlockFactory ( )
virtualdefault

Member Function Documentation

◆ Create()

SampleBlockPtr SampleBlockFactory::Create ( constSamplePtr  src,
size_t  numsamples,
sampleFormat  srcformat 
)

Definition at line 26 of file SampleBlock.cpp.

29{
30 auto result = DoCreate(src, numsamples, srcformat);
31 if (!result)
34 return result;
35}
#define THROW_INCONSISTENCY_EXCEPTION
Throw InconsistencyException, using C++ preprocessor to identify the source code location.
CallbackReturn Publish(const SampleBlockCreateMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207
virtual SampleBlockPtr DoCreate(constSamplePtr src, size_t numsamples, sampleFormat srcformat)=0

References DoCreate(), Observer::Publisher< SampleBlockCreateMessage >::Publish(), and THROW_INCONSISTENCY_EXCEPTION.

Referenced by anonymous_namespace{Sequence.cpp}::ShareOrCopySampleBlock().

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

◆ CreateFromId()

SampleBlockPtr SampleBlockFactory::CreateFromId ( sampleFormat  srcformat,
SampleBlockID  id 
)

Definition at line 59 of file SampleBlock.cpp.

61{
62 auto result = DoCreateFromId(srcformat, id);
63 if (!result)
66 return result;
67}
virtual SampleBlockPtr DoCreateFromId(sampleFormat srcformat, SampleBlockID id)=0

References DoCreateFromId(), Observer::Publisher< SampleBlockCreateMessage >::Publish(), and THROW_INCONSISTENCY_EXCEPTION.

Here is the call graph for this function:

◆ CreateFromXML()

SampleBlockPtr SampleBlockFactory::CreateFromXML ( sampleFormat  srcformat,
const AttributesList attrs 
)

Definition at line 48 of file SampleBlock.cpp.

51{
52 auto result = DoCreateFromXML(srcformat, attrs);
53 if (!result)
56 return result;
57}
virtual SampleBlockPtr DoCreateFromXML(sampleFormat srcformat, const AttributesList &attrs)=0

References DoCreateFromXML(), Observer::Publisher< SampleBlockCreateMessage >::Publish(), and THROW_INCONSISTENCY_EXCEPTION.

Here is the call graph for this function:

◆ CreateSilent()

SampleBlockPtr SampleBlockFactory::CreateSilent ( size_t  numsamples,
sampleFormat  srcformat 
)

Definition at line 37 of file SampleBlock.cpp.

40{
41 auto result = DoCreateSilent(numsamples, srcformat);
42 if (!result)
45 return result;
46}
virtual SampleBlockPtr DoCreateSilent(size_t numsamples, sampleFormat srcformat)=0

References DoCreateSilent(), Observer::Publisher< SampleBlockCreateMessage >::Publish(), and THROW_INCONSISTENCY_EXCEPTION.

Here is the call graph for this function:

◆ DoCreate()

virtual SampleBlockPtr SampleBlockFactory::DoCreate ( constSamplePtr  src,
size_t  numsamples,
sampleFormat  srcformat 
)
protectedpure virtual

Implemented in SqliteSampleBlockFactory, and MockSampleBlockFactory.

Referenced by Create().

Here is the caller graph for this function:

◆ DoCreateFromId()

virtual SampleBlockPtr SampleBlockFactory::DoCreateFromId ( sampleFormat  srcformat,
SampleBlockID  id 
)
protectedpure virtual

Implemented in SqliteSampleBlockFactory, and MockSampleBlockFactory.

Referenced by CreateFromId().

Here is the caller graph for this function:

◆ DoCreateFromXML()

virtual SampleBlockPtr SampleBlockFactory::DoCreateFromXML ( sampleFormat  srcformat,
const AttributesList attrs 
)
protectedpure virtual

Implemented in SqliteSampleBlockFactory, and MockSampleBlockFactory.

Referenced by CreateFromXML().

Here is the caller graph for this function:

◆ DoCreateSilent()

virtual SampleBlockPtr SampleBlockFactory::DoCreateSilent ( size_t  numsamples,
sampleFormat  srcformat 
)
protectedpure virtual

Implemented in SqliteSampleBlockFactory, and MockSampleBlockFactory.

Referenced by CreateSilent().

Here is the caller graph for this function:

◆ GetActiveBlockIDs()

virtual SampleBlockIDs SampleBlockFactory::GetActiveBlockIDs ( )
pure virtual
Returns
ids of all sample blocks created by this factory and still extant

Implemented in SqliteSampleBlockFactory, and MockSampleBlockFactory.

◆ New()

SampleBlockFactoryPtr SampleBlockFactory::New ( AudacityProject project)
static

Definition at line 16 of file SampleBlock.cpp.

17{
18 auto &factory = Factory::Get();
19 if ( ! factory )
21 return factory( project );
22}
static RegisteredToolbarFactory factory
const auto project

References factory, GlobalVariable< Factory, const std::function< SampleBlockFactoryPtr(AudacityProject &) >, nullptr, Options... >::Get(), project, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by BenchmarkDialog::OnRun().

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

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