LCOV - code coverage report
Current view: top level - Tools - CachedCosinusGeneratorFilter.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 1 1 100.0 %
Date: 2021-02-18 20:07:22 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /**
       2             :  * \file CachedCosinusGeneratorFilter.h
       3             :  */
       4             : 
       5             : #ifndef ATK_TOOLS_CACHEDCOSINUSGENERATORFILTER_H
       6             : #define ATK_TOOLS_CACHEDCOSINUSGENERATORFILTER_H
       7             : 
       8             : #include <ATK/Core/TypedBaseFilter.h>
       9             : #include <ATK/Tools/config.h>
      10             : 
      11             : #include <vector>
      12             : 
      13             : namespace ATK
      14             : {
      15             :   /// Generates a cosinus signal from a cache
      16             :   template<typename DataType_>
      17             :   class ATK_TOOLS_EXPORT CachedCosinusGeneratorFilter final : public TypedBaseFilter<DataType_>
      18             :   {
      19             :   protected:
      20             :     /// Simplify parent calls
      21             :     using Parent = TypedBaseFilter<DataType_>;
      22             :     using typename Parent::DataType;
      23             :     using Parent::outputs;
      24             :     using Parent::output_sampling_rate;
      25             : 
      26             :   public:
      27             :     /*!
      28             :      * @brief Constructor
      29             :      * @param periods is the number of periods per second
      30             :      * @param seconds is the number of seconds to cache
      31             :      */
      32             :     CachedCosinusGeneratorFilter(int periods, int seconds = 1);
      33             :     /// Destructor
      34           5 :     ~CachedCosinusGeneratorFilter() override = default;
      35             : 
      36             :     /*!
      37             :     * @brief Updates the cache with new values
      38             :     * @param periods is the number of periods per second
      39             :     * @param seconds is the number of seconds to cache
      40             :     */
      41             :     void set_frequency(int periods, int seconds = 1);
      42             :     /// Retrieves the current parameters
      43             :     std::pair<int, int> get_frequency() const;
      44             : 
      45             :     /// Sets the output volume, doesn't update the cache
      46             :     void set_volume(DataType_ volume);
      47             :     /// Gets the output volume
      48             :     DataType_ get_volume() const;
      49             : 
      50             :     /// Sets the offset of the generated signal, doesn't update the cache
      51             :     void set_offset(DataType_ offset);
      52             :     /// Gets the offset
      53             :     DataType_ get_offset() const;
      54             : 
      55             :   protected:
      56             :     void process_impl(gsl::index size) const final;
      57             :     void setup() final;
      58             :     
      59             :   private:
      60             :     mutable gsl::index indice{1};
      61             :     int periods{0};
      62             :     int seconds{0};
      63             :     DataType_ volume{1};
      64             :     DataType_ offset{0};
      65             :     std::vector<DataType_> cache;
      66             :   };
      67             : }
      68             : 
      69             : #endif

Generated by: LCOV version TK-3.3.0-4-gdba42eea