openMSX
FilePool.hh
Go to the documentation of this file.
1#ifndef FILEPOOL_HH
2#define FILEPOOL_HH
3
4#include "Command.hh"
5#include "EventListener.hh"
6#include "FilePoolCore.hh"
7#include "StringSetting.hh"
8#include "Observer.hh"
9#include <string_view>
10
11namespace openmsx {
12
13class CommandController;
14class Reactor;
15class Sha1SumCommand;
16
17class FilePool final : private Observer<Setting>, private EventListener
18{
19public:
20 FilePool(CommandController& controller, Reactor& reactor);
21 ~FilePool();
22
27 [[nodiscard]] File getFile(FileType fileType, const Sha1Sum& sha1sum);
28
33 [[nodiscard]] Sha1Sum getSha1Sum(File& file);
34
35private:
36 [[nodiscard]] FilePoolCore::Directories getDirectories() const;
37 void reportProgress(std::string_view message);
38
39 // Observer<Setting>
40 void update(const Setting& setting) noexcept override;
41
42 // EventListener
43 int signalEvent(const Event& event) override;
44
45private:
46 FilePoolCore core;
47 StringSetting filePoolSetting;
48 Reactor& reactor;
49
50 class Sha1SumCommand final : public Command {
51 public:
52 explicit Sha1SumCommand(CommandController& commandController);
53 void execute(std::span<const TclObject> tokens, TclObject& result) override;
54 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
55 void tabCompletion(std::vector<std::string>& tokens) const override;
56 } sha1SumCommand;
57
58 bool quit = false;
59};
60
61} // namespace openmsx
62
63#endif
BaseSetting * setting
Definition: Interpreter.cc:28
std::vector< Dir > Directories
Definition: FilePoolCore.hh:44
FilePool(CommandController &controller, Reactor &reactor)
Definition: FilePool.cc:31
Sha1Sum getSha1Sum(File &file)
Calculate sha1sum for the given File object.
Definition: FilePool.cc:58
File getFile(FileType fileType, const Sha1Sum &sha1sum)
Search file with the given sha1sum.
Definition: FilePool.cc:53
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:10
Contains the main loop of openMSX.
Definition: Reactor.hh:68
This class represents the result of a sha1 calculation (a 160-bit value).
Definition: sha1.hh:23
This file implemented 3 utility functions:
Definition: Autofire.cc:9