MLBookProc 1.1
 
Loading...
Searching...
No Matches
Hasher.h
1/*
2 * Copyright (C) 2024-2025 Yury Bobylev <bobilev_yury@mail.ru>
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation, version 3.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16
17#ifndef HASHER_H
18#define HASHER_H
19
20#include <AuxFunc.h>
21#include <filesystem>
22#include <functional>
23#include <memory>
24#include <string>
25#ifndef USE_OPENMP
26#include <atomic>
27#endif
28
34class Hasher
35{
36public:
41 Hasher(const std::shared_ptr<AuxFunc> &af);
42
50 std::string
51 buf_hashing(const std::string &buf);
52
60 std::string
61 file_hashing(const std::filesystem::path &filepath);
62
66 void
68
69protected:
70#ifndef USE_OPENMP
76 std::atomic<bool> cancel;
77#else
83 bool cancel;
84#endif
85
91 std::function<void()> stop_all_signal;
92
93private:
94 std::shared_ptr<AuxFunc> af;
95};
96
97#endif // HASHER_H
std::function< void()> stop_all_signal
Stop signal for heir classes.
Definition Hasher.h:91
std::string buf_hashing(const std::string &buf)
Creates hash sum for given buffer.
Hasher(const std::shared_ptr< AuxFunc > &af)
Hasher constructor.
std::string file_hashing(const std::filesystem::path &filepath)
Creates hash sum for given file.
void cancelAll()
Stops all operations.
std::atomic< bool > cancel
Stops all operations if true.
Definition Hasher.h:76