Audacity 3.2.0
BlockHasher.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 BlockHasher.h
7
8 Dmitry Vedenko
9
10**********************************************************************/
11#pragma once
12
13#include <cstdint>
14#include <functional>
15#include <string>
16#include <memory>
17#include <vector>
18#include <unordered_map>
19
20#include "CloudSyncDTO.h"
21
23{
24class BlockHashCache /* not final */
25{
26public:
27 virtual ~BlockHashCache() = default;
28
29 virtual bool GetHash(int64_t blockId, std::string& hash) const = 0;
30 virtual void UpdateHash(int64_t blockId, const std::string& hash) = 0;
31};
32
33class BlockHasher final
34{
35public:
38
39 BlockHasher(const BlockHasher&) = delete;
43
44 bool ComputeHashes(BlockHashCache& cache, std::vector<LockedBlock> blocks, std::function<void()> onComplete);
45 bool IsReady() const;
46
47 std::vector<std::pair<int64_t, std::string>> TakeResult();
48
49private:
50 class Workers;
51 std::unique_ptr<Workers> mWorkers;
52};
53} // namespace audacity::cloud::audiocom::sync
virtual void UpdateHash(int64_t blockId, const std::string &hash)=0
virtual bool GetHash(int64_t blockId, std::string &hash) const =0
bool ComputeHashes(BlockHashCache &cache, std::vector< LockedBlock > blocks, std::function< void()> onComplete)
BlockHasher & operator=(const BlockHasher &)=delete
std::unique_ptr< Workers > mWorkers
Definition: BlockHasher.h:50
BlockHasher & operator=(BlockHasher &&)=delete
BlockHasher(const BlockHasher &)=delete
std::vector< std::pair< int64_t, std::string > > TakeResult()