VISR  0.11.8
Versatile Interactive Scene Renderer
fractional_delay_factory.hpp
Go to the documentation of this file.
1 /* Copyright Institute of Sound and Vibration Research - All rights reserved */
2 
3 #ifndef VISR_LIBRBBL_FRACTIONAL_DELAY_FACTORY_HPP_INCLUDED
4 #define VISR_LIBRBBL_FRACTIONAL_DELAY_FACTORY_HPP_INCLUDED
5 
6 #include "export_symbols.hpp"
7 
8 #include <functional>
9 #include <map>
10 #include <memory>
11 #include <string>
12 
13 namespace visr
14 {
15 namespace rbbl
16 {
17 
18 // Forward declarations
19 template< typename SampleType >
20 class FractionalDelayBase;
21 
26 template <typename SampleType>
27 class VISR_RBBL_LIBRARY_SYMBOL FractionalDelayFactory
28 {
29 public:
30  static std::unique_ptr<FractionalDelayBase<SampleType> > create( std::string const & name,
31  std::size_t maxNumSamples );
32 
33  template< class InterpolatorType >
34  static void registerAlgorithm( std::string const & name );
35 
36 private:
37  struct Creator
38  {
39  using CreateFunction = std::function< std::unique_ptr<FractionalDelayBase<SampleType> >(std::size_t) >;
40 
41  explicit Creator( CreateFunction fcn );
42 
43  std::unique_ptr<FractionalDelayBase<SampleType> > create( std::size_t maxNumSamples ) const;
44  private:
45  CreateFunction mCreateFunction;
46  };
47 
48  template< class InterpolatorType >
49  class TCreator: public Creator
50  {
51  public:
52  TCreator()
53  : Creator( &TCreator<InterpolatorType>::construct )
54  {
55  }
56 
57  static std::unique_ptr<FractionalDelayBase<SampleType> > construct( std::size_t maxNumSamples )
58  {
59  return std::unique_ptr<FractionalDelayBase<SampleType> >( new InterpolatorType( maxNumSamples ) );
60  }
61  };
62 
63  using CreatorTable = std::map<std::string const, Creator >;
64 
65  static CreatorTable & creatorTable();
66 };
67 
68 template< class SampleType >
69 template< class InterpolatorType >
71 {
72  creatorTable().insert( std::make_pair( name, TCreator<InterpolatorType>() ) );
73 }
74 
75 } // namespace rbbl
76 } // namespace visr
77 
78 #endif // #ifndef VISR_LIBRBBL_FRACTIONAL_DELAY_FACTORY_HPP_INCLUDED
Definition: options.cpp:10
static void registerAlgorithm(std::string const &name)
Definition: fractional_delay_factory.hpp:70
Definition: fractional_delay_factory.hpp:27