Line data Source code
1 : /** 2 : * \file OutCircularPointerFilter.h 3 : */ 4 : 5 : #ifndef ATK_CORE_OUTCIRCULARPOINTERFILTER_H 6 : #define ATK_CORE_OUTCIRCULARPOINTERFILTER_H 7 : 8 : #include <ATK/Core/TypedBaseFilter.h> 9 : 10 : #include <array> 11 : 12 : namespace ATK 13 : { 14 : /// Filter allowing to output data in a circular array 15 : template<typename DataType_> 16 : class ATK_CORE_EXPORT OutCircularPointerFilter final : public TypedBaseFilter<DataType_> 17 : { 18 : public: 19 : static const unsigned int slice_size = 1024; 20 : static const unsigned int nb_slices = 66; 21 : static const unsigned int out_slice_size = (nb_slices - 2) * slice_size; 22 : 23 : protected: 24 : /// Simplify parent calls 25 : using Parent = TypedBaseFilter<DataType_>; 26 : using SliceBuffer = std::array<DataType_, out_slice_size>; 27 : using typename Parent::DataType; 28 : using Parent::converted_inputs; 29 : using Parent::input_sampling_rate; 30 : 31 : public: 32 : using Parent::set_input_sampling_rate; 33 : 34 : /** 35 : * @brief Create a circular filter for the end of a pipeline 36 : */ 37 : OutCircularPointerFilter(); 38 : /// Destructor 39 2 : ~OutCircularPointerFilter() override = default; 40 : 41 : void full_setup() final; 42 : 43 : /// Retrieves a slice of the processed data, setting process to true if it's a new one 44 : auto get_last_slice(bool& process) -> const SliceBuffer&; 45 : 46 : protected: 47 : /// This implementation retrieves inputs from other filters and converts it accordingly 48 : void process_impl(gsl::index size) const final; 49 : /// Output array 50 : mutable std::array<DataType, nb_slices* slice_size> array{}; 51 : SliceBuffer last_slice{}; 52 : 53 : /// Current offset in the array 54 : mutable gsl::index offset{0}; 55 : mutable gsl::index current_slice{0}; 56 : gsl::index last_checked_out_buffer = -1; 57 : 58 : }; 59 : } 60 : 61 : #endif