LCOV - code coverage report
Current view: top level - src/MIDI_Parsers - LambdaPuller.hpp (source / functions) Hit Total Coverage
Test: b8a30b4b7040ae1abf162fd0a258beaa2de43626 Lines: 5 5 100.0 %
Date: 2024-12-21 21:28:55 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