File Scanner 1.0.0
A high-performance C++ malicious file scanner.
Loading...
Searching...
No Matches
scanner.h
Go to the documentation of this file.
1#ifndef SRC_SCANNER_LIB_SCANNER_H_
2#define SRC_SCANNER_LIB_SCANNER_H_
3
4#include <cstdint>
5
6#include <atomic>
7#include <filesystem>
8#include <future>
9
10#include "scanner/interfaces.h"
12
13namespace scanner {
14
22class Scanner final : public IScanner {
23public:
31 explicit Scanner(IHashDatabase& db, ILogger& logger, IFileHasher& hasher,
32 std::size_t num_threads);
33
39 ScanResult Scan(const std::filesystem::path& scan_path) override;
40
41private:
53 void ProducerTask(const std::filesystem::path& scan_path, ThreadPool& pool,
54 std::promise<void>& producer_promise);
55
65 void ConsumerTask(const std::filesystem::path& path);
66
70 std::size_t num_threads_;
71
72 std::atomic<std::uint64_t> total_files_processed_{0};
73 std::atomic<std::uint64_t> malicious_files_detected_{0};
74 std::atomic<std::uint64_t> errors_{0};
75};
76
77} // namespace scanner
78
79#endif // SRC_SCANNER_LIB_SCANNER_H_
Defines the contract for a component that can hash a file's content.
Definition interfaces.h:18
Defines the contract for a database of malicious signatures.
Definition interfaces.h:35
Defines the contract for a component that logs malicious detections.
Definition interfaces.h:64
Defines the primary contract for the file scanning engine.
Definition interfaces.h:83
The concrete, internal implementation of the IScanner interface.
Definition scanner.h:22
std::atomic< std::uint64_t > errors_
Definition scanner.h:74
std::atomic< std::uint64_t > malicious_files_detected_
Definition scanner.h:73
void ProducerTask(const std::filesystem::path &scan_path, ThreadPool &pool, std::promise< void > &producer_promise)
The task executed by the producer thread.
Definition scanner.cpp:36
std::size_t num_threads_
Definition scanner.h:70
ILogger & logger_
Definition scanner.h:68
void ConsumerTask(const std::filesystem::path &path)
The task executed by consumer threads in the pool.
Definition scanner.cpp:20
IHashDatabase & db_
Definition scanner.h:67
std::atomic< std::uint64_t > total_files_processed_
Definition scanner.h:72
IFileHasher & hasher_
Definition scanner.h:69
ScanResult Scan(const std::filesystem::path &scan_path) override
Scans the specified directory.
Definition scanner.cpp:60
Manages a pool of worker threads to execute tasks concurrently.
Definition thread_pool.h:26
Definition domain.h:12
Holds the final statistics of a completed scan operation.
Definition domain.h:18