LCOV - code coverage report
Current view: top level - src/operations - SyncOperation.h (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 100.0 % 1 1
Test Date: 2026-03-23 10:19:47 Functions: 50.0 % 2 1

            Line data    Source code
       1              : #ifndef SYNCOPERATION_H
       2              : #define SYNCOPERATION_H
       3              : 
       4              : #include <QObject>
       5              : #include <QString>
       6              : 
       7              : #include "../FangObject.h"
       8              : 
       9              : class OperationManager;
      10              : 
      11              : /*!
      12              :     \brief Base class for synchronous operations. This is mainly used for operations that
      13              :     complete quickly and/or need to happen in a certain order, such as database operations.
      14              :  */
      15              : class SyncOperation : public FangObject
      16              : {
      17              :     Q_OBJECT
      18              : 
      19              : public:
      20              :     explicit SyncOperation(OperationManager* parent);
      21           20 :     virtual ~SyncOperation() = default;
      22              : 
      23              :     /*!
      24              :         \brief Executes the operation synchronously.
      25              :      */
      26              :     virtual void execute() = 0;
      27              : 
      28              :     /*!
      29              :         \return Returns true if there was an error, else false.
      30              :      */
      31              :     bool hasError() const { return error; }
      32              : 
      33              :     /*!
      34              :         \return Error message, if any.
      35              :      */
      36              :     QString errorMessage() const { return errorMsg; }
      37              : 
      38              : protected:
      39              : 
      40              :     /*!
      41              :         \brief Call this to report an error. Logs the error and sets the error flag.
      42              :         Unlike AsyncOperation::reportError(), this does NOT emit any signals.
      43              :         \param errorString The text that will be logged along with the error.
      44              :      */
      45              :     void reportError(const QString& errorString);
      46              : 
      47              : private:
      48              :     OperationManager* operationManager;
      49              :     bool error = false;
      50              :     QString errorMsg;
      51              : };
      52              : 
      53              : #endif // SYNCOPERATION_H
        

Generated by: LCOV version 2.0-1