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 [[nodiscard]] Sha1Sum getSha1Sum(const std::string& filename);
35
36 [[nodiscard]] FilePoolCore::Directories getDirectories() const;
37
38private:
39 void reportProgress(std::string_view message, float fraction);
40
41 // Observer<Setting>
42 void update(const Setting& setting) noexcept override;
43
44 // EventListener
45 int signalEvent(const Event& event) override;
46
47private:
48 FilePoolCore core;
49 StringSetting filePoolSetting;
50 Reactor& reactor;
51
52 class Sha1SumCommand final : public Command {
53 public:
54 explicit Sha1SumCommand(CommandController& commandController);
55 void execute(std::span<const TclObject> tokens, TclObject& result) override;
56 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
57 void tabCompletion(std::vector<std::string>& tokens) const override;
58 } sha1SumCommand;
59
60 bool quit = false;
61};
62
63} // namespace openmsx
64
65#endif
BaseSetting * setting
Definition: Interpreter.cc:28
std::vector< Dir > Directories
Definition: FilePoolCore.hh:44
FilePool(CommandController &controller, Reactor &reactor)
Definition: FilePool.cc:31
FilePoolCore::Directories getDirectories() const
Definition: FilePool.cc:89
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:72
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
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition: Event.hh:450