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

0001 /*
0002     SPDX-FileCopyrightText: 2006-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef _K3B_CHECKSUM_PIPE_H_
0009 #define _K3B_CHECKSUM_PIPE_H_
0010 
0011 #include "k3bactivepipe.h"
0012 
0013 #include "k3b_export.h"
0014 
0015 
0016 namespace K3b {
0017     /**
0018      * The checksum pipe calculates the checksum of the data
0019      * passed through it.
0020      */
0021     class LIBK3B_EXPORT ChecksumPipe : public ActivePipe
0022     {
0023         Q_OBJECT
0024 
0025     public:
0026         ChecksumPipe();
0027         ~ChecksumPipe() override;
0028 
0029         enum Type {
0030             MD5
0031         };
0032 
0033         /**
0034          * \reimplemented
0035          * Defaults to MD5 checksum
0036          */
0037         bool open( bool closeWhenDone = false ) override;
0038 
0039         /**
0040          * Opens the pipe and thus starts the
0041          * checksum calculation
0042          *
0043          * \param closeWhenDone If true the pipes will be closed
0044          *        once all data has been read.
0045          */
0046         bool open( Type type, bool closeWhenDone = false );
0047 
0048         /**
0049          * Get the calculated checksum
0050          */
0051         QByteArray checksum() const;
0052 
0053     protected:
0054         qint64 writeData( const char* data, qint64 max ) override;
0055 
0056     private:
0057         /**
0058          * Hidden open method. Use open(bool).
0059          */
0060         bool open( OpenMode mode ) override;
0061 
0062         class Private;
0063         Private* d;
0064     };
0065 }
0066 
0067 #endif