LCOV - code coverage report
Current view: top level - src/MIDI_Parsers - LambdaPuller.hpp (source / functions) Hit Total Coverage
Test: 169c36a3797bc662d84b5726f34a3f37d3c58247 Lines: 5 5 100.0 %
Date: 2024-11-09 15:32:27 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <AH/STL/utility> // std::forward
       4             : #include <Settings/NamespaceSettings.hpp>
       5             : 
       6             : BEGIN_CS_NAMESPACE
       7             : 
       8             : /**
       9             :  * @brief   Helper to turn a lambda function into a puller.
      10             :  * @ingroup MIDIParsers
      11             :  */
      12             : template <class Lambda>
      13             : class LambdaPuller_ {
      14             :   public:
      15          18 :     LambdaPuller_(Lambda &&lambda) : lambda(std::forward<Lambda>(lambda)) {}
      16             : 
      17             :     template <class T>
      18          26 :     bool pull(T &packet) {
      19          26 :         return lambda(packet);
      20             :     }
      21             : 
      22             :   private:
      23             :     Lambda lambda;
      24             : };
      25             : 
      26             : template <class Lambda>
      27          18 : LambdaPuller_<Lambda> LambdaPuller(Lambda &&lambda) {
      28          18 :     return std::forward<Lambda>(lambda);
      29             : }
      30             : 
      31             : END_CS_NAMESPACE

Generated by: LCOV version 1.15