File indexing completed on 2024-06-16 05:24:51

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2009, 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef KASTEN_ABSTRACTBYTEARRAYCHECKSUMALGORITHM_HPP
0010 #define KASTEN_ABSTRACTBYTEARRAYCHECKSUMALGORITHM_HPP
0011 
0012 // Okteta core
0013 #include <Okteta/AddressRange>
0014 // Qt
0015 #include <QObject>
0016 // Std
0017 #include <memory>
0018 
0019 class AbstractByteArrayChecksumParameterSet;
0020 namespace Okteta {
0021 class AbstractByteArrayModel;
0022 }
0023 class KConfigGroup;
0024 class QString;
0025 
0026 class AbstractByteArrayChecksumAlgorithm : public QObject
0027 {
0028     Q_OBJECT
0029 
0030 protected:
0031     static constexpr int CalculatedByteCountSignalLimit = 10000;
0032 
0033 protected:
0034     explicit AbstractByteArrayChecksumAlgorithm(const QString& name, const QString& id);
0035 
0036 public:
0037     ~AbstractByteArrayChecksumAlgorithm() override;
0038 
0039 public: // API to be implemented
0040     virtual bool calculateChecksum(QString* result, const Okteta::AbstractByteArrayModel* model, const Okteta::AddressRange& range) const = 0;
0041     /** used by the editor to get write access to the parameters */
0042     virtual AbstractByteArrayChecksumParameterSet* parameterSet() = 0;
0043     virtual void loadConfig(const KConfigGroup& configGroup);
0044     virtual void saveConfig(KConfigGroup& configGroup) const;
0045 
0046 public:
0047     QString name() const;
0048     QString id() const;
0049 
0050 Q_SIGNALS: // TODO: add check for signal to tests
0051     void calculatedBytes(int bytes) const;
0052 
0053 private:
0054     const std::unique_ptr<class AbstractByteArrayChecksumAlgorithmPrivate> d;
0055 };
0056 
0057 #endif