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 "Observer.hh"
8#include "StringSetting.hh"
9
10#include <optional>
11#include <string_view>
12
13namespace openmsx {
14
15class CommandController;
16class Reactor;
17class Sha1SumCommand;
18
19class FilePool final : private Observer<Setting>, private EventListener
20{
21public:
22 FilePool(CommandController& controller, Reactor& reactor);
23 ~FilePool();
24
29 [[nodiscard]] File getFile(FileType fileType, const Sha1Sum& sha1sum);
30
35 [[nodiscard]] Sha1Sum getSha1Sum(File& file);
36 [[nodiscard]] std::optional<Sha1Sum> getSha1Sum(const std::string& filename);
37
38 [[nodiscard]] FilePoolCore::Directories getDirectories() const;
39
40private:
41 void reportProgress(std::string_view message, float fraction);
42
43 // Observer<Setting>
44 void update(const Setting& setting) noexcept override;
45
46 // EventListener
47 bool signalEvent(const Event& event) override;
48
49private:
50 FilePoolCore core;
51 StringSetting filePoolSetting;
52 Reactor& reactor;
53
54 class Sha1SumCommand final : public Command {
55 public:
56 explicit Sha1SumCommand(CommandController& commandController);
57 void execute(std::span<const TclObject> tokens, TclObject& result) override;
58 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
59 void tabCompletion(std::vector<std::string>& tokens) const override;
60 } sha1SumCommand;
61
62 bool quit = false;
63};
64
65} // namespace openmsx
66
67#endif
BaseSetting * setting
std::vector< Dir > Directories
FilePoolCore::Directories getDirectories() const
Definition FilePool.cc:94
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:75
This class represents the result of a sha1 calculation (a 160-bit value).
Definition sha1.hh:24
This file implemented 3 utility functions:
Definition Autofire.cc:11
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, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:445