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