File indexing completed on 2024-06-16 07:42:27

0001 /*
0002     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 #ifndef _K3B_THROUGHPUT_ESTIMATOR_H_
0006 #define _K3B_THROUGHPUT_ESTIMATOR_H_
0007 
0008 #include <QObject>
0009 
0010 
0011 namespace K3b {
0012     /**
0013      * Little helper class that allows an estimation of the current writing
0014      * speed. Just init with @p reset() then always call @p dataWritten with
0015      * the already written data in KB. The class will emit throughput signals
0016      * whenever the throughput changes.
0017      */
0018     class ThroughputEstimator : public QObject
0019     {
0020         Q_OBJECT
0021 
0022     public:
0023         explicit ThroughputEstimator( QObject* parent = 0 );
0024         ~ThroughputEstimator() override;
0025 
0026         int average() const;
0027 
0028     Q_SIGNALS:
0029         /**
0030          * kb/s if differs from previous
0031          */
0032         void throughput( int );
0033 
0034     public Q_SLOTS:
0035         void reset();
0036 
0037         /**
0038          * @param data written kb
0039          */
0040         void dataWritten( unsigned long data );
0041 
0042     private:
0043         class Private;
0044         Private* d;
0045     };
0046 }
0047 
0048 #endif