LCOV - code coverage report
Current view: top level - src/gui/commands - command_base.h (source / functions) Coverage Total Hit
Test: merged.info Lines: 80.0 % 5 4
Test Date: 2026-06-03 09:13:19 Functions: 50.0 % 4 2

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include <chrono>
       4              : 
       5              : namespace Amplitron {
       6              : 
       7              : /**
       8              :  * @brief Abstract base class for all undoable commands (Gang of Four Command Pattern).
       9              :  *
      10              :  * Each concrete command encapsulates a single reversible action on the audio
      11              :  * engine (e.g. adding an effect, changing a parameter). Commands are stored
      12              :  * in a CommandHistory and invoked via execute() / undo().
      13              :  */
      14          210 : class Command {
      15              : public:
      16          214 :     virtual ~Command() = default;
      17              : 
      18              :     /** @brief Apply this command's action. Returns true if a mutation occurred. */
      19            0 :     virtual bool execute() { return true; }
      20              : 
      21              :     /** @brief Reverse this command's action. */
      22              :     virtual void undo() = 0;
      23              : 
      24              :     /** @brief Return a short human-readable label (shown in the Edit menu). */
      25              :     virtual const char* description() const = 0;
      26              : 
      27              :     /**
      28              :      * @brief Attempt to merge @p other into this command (coalescing).
      29              :      *
      30              :      * Two commands can merge if they affect the same target within a short
      31              :      * time window. Returns true if this command absorbed @p other.
      32              :      */
      33           81 :     virtual bool merge_with(const Command& /*other*/) { return false; }
      34              : 
      35              :     /** @brief Return the steady-clock time point when this command was created. */
      36              :     auto timestamp() const { return timestamp_; }
      37              : 
      38              : protected:
      39          105 :     std::chrono::steady_clock::time_point timestamp_ = std::chrono::steady_clock::now();
      40              : };
      41              : 
      42              : } // namespace Amplitron
        

Generated by: LCOV version 2.0-1