nds2-client - ClientUser  0.16.8
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
nds_gap_handler.hh
1 #ifndef __NDS_GAP_HANDLER_HH__
2 #define __NDS_GAP_HANDLER_HH__
3 
4 #include <stdint.h>
5 
6 #include "nds_buffer.hh"
7 
8 #include "nds_export.hh"
9 
10 #include "nds_memory.hh"
11 
12 namespace NDS
13 {
14  namespace detail
15  {
16  class delayed_gap_handler
17  {
18  public:
19  delayed_gap_handler( ) = default;
20  ;
21 
22  virtual ~delayed_gap_handler( ) = default;
23  ;
24 
25  virtual void operator( )( ) = 0;
26  };
27 
28  class gap_handler
29  {
30  public:
31  DLL_EXPORT gap_handler( ) = default;
32 
33  DLL_EXPORT virtual ~gap_handler( ) = default;
34 
35  DLL_EXPORT virtual std::unique_ptr< delayed_gap_handler >
36  fill_gap( buffer& cur_buffer,
37  buffer::size_type start_sample_offset,
38  buffer::size_type end_sample_offset ) const = 0;
39 
40  DLL_EXPORT virtual std::unique_ptr< gap_handler >
41  clone( ) const = 0;
42  };
43 
44  class fixed_point_gap_handler : public gap_handler
45  {
46  public:
47  struct static_val
48  {
49  ::int16_t int16val;
50  ::int32_t int32val;
51  ::int64_t int64val;
52  float float32val;
53  double float64val;
54  float complexrval;
55  float complexival;
56  ::uint32_t uint32val;
57 
58  typedef enum {
59  ZERO_VAL = 0,
60  ONE_VAL,
61  NAN_VAL,
62  POS_INF_VAL,
63  NEG_INF_VAL,
64  } fixed_values;
65  DLL_EXPORT static_val(::int16_t int16val,
66  ::int32_t int32val,
67  ::int64_t int64val,
68  float float32val,
69  double float64val,
70  float complexrval,
71  float complexival,
72  ::uint32_t uint32val );
73 
74  DLL_EXPORT explicit static_val( fixed_values spec );
75 
76  DLL_EXPORT explicit static_val( double value = 0.0 );
77  };
78 
79  public:
80  DLL_EXPORT fixed_point_gap_handler( static_val::fixed_values spec )
81  : val( spec ){};
82  DLL_EXPORT fixed_point_gap_handler( const static_val& val )
83  : val( val ){};
84  DLL_EXPORT ~fixed_point_gap_handler( ) override = default;
85 
86  DLL_EXPORT std::unique_ptr< delayed_gap_handler >
87  fill_gap( buffer& cur_buffer,
88  buffer::size_type start_sample_offset,
89  buffer::size_type end_sample_offset ) const override;
90 
91  DLL_EXPORT std::unique_ptr< gap_handler >
92  clone( ) const override
93  {
94  return NDS::detail::make_unique< fixed_point_gap_handler >(
95  val );
96  }
97 
98  protected:
99  static_val val;
100  };
101 
102  class continuation_gap_handler : public fixed_point_gap_handler
103  {
104  public:
105  DLL_EXPORT continuation_gap_handler( const static_val default_val )
106  : fixed_point_gap_handler( default_val ){};
107  DLL_EXPORT ~continuation_gap_handler( ) override = default;
108 
109  DLL_EXPORT std::unique_ptr< delayed_gap_handler >
110  fill_gap( buffer& cur_buffer,
111  buffer::size_type start_sample_offset,
112  buffer::size_type end_sample_offset ) const override;
113 
114  DLL_EXPORT std::unique_ptr< gap_handler >
115  clone( ) const override
116  {
117  return NDS::detail::make_unique< continuation_gap_handler >(
118  val );
119  }
120  };
121 
122  class abort_gap_handler : public gap_handler
123  {
124  public:
125  DLL_EXPORT abort_gap_handler( ){};
126  DLL_EXPORT ~abort_gap_handler( ) override = default;
127 
128  DLL_EXPORT std::unique_ptr< delayed_gap_handler >
129  fill_gap( buffer& cur_buffer,
130  buffer::size_type start_sample_offset,
131  buffer::size_type end_sample_offset ) const override;
132  DLL_EXPORT std::unique_ptr< gap_handler >
133  clone( ) const override
134  {
135  return std::unique_ptr< gap_handler >(
136  NDS::detail::make_unique< abort_gap_handler >( ) );
137  }
138  };
139  }
140 }
141 
142 #endif // __NDS_GAP_HANDLER_HH__