MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
COMBackend.hpp
Go to the documentation of this file.
1#pragma once
2
3#ifdef MAYAFLUX_PLATFORM_WINDOWS
4
5#include "SystemBackend.hpp"
6
7namespace MayaFlux::Core {
8
9/**
10 * @class COMBackend
11 * @brief Windows SystemBackend via IFileOpenDialog / IFileSaveDialog (Shell COM).
12 *
13 * Uses the modern Vista-era Shell COM interfaces from shobjidl_core.h.
14 * CoInitializeEx is called once per call on the dispatch thread; the
15 * dialog is modal and blocks until the user completes or dismisses it.
16 * The result is delivered via callback before the thread exits.
17 *
18 * initialize() / shutdown() manage nothing persistent - COM is initialised
19 * per-call on the dispatch thread. They exist to satisfy SystemBackend.
20 */
21class MAYAFLUX_API COMBackend final : public SystemBackend {
22public:
23 COMBackend() = default;
24 ~COMBackend() override = default;
25
26 COMBackend(const COMBackend&) = delete;
27 COMBackend& operator=(const COMBackend&) = delete;
28 COMBackend(COMBackend&&) noexcept = default;
29 COMBackend& operator=(COMBackend&&) noexcept = default;
30
31 [[nodiscard]] bool initialize() override;
32 void shutdown() override;
33 [[nodiscard]] bool is_initialized() const override { return m_initialized; }
34
35 void open_file(
36 FileDialogCallback callback,
37 std::vector<SystemFileFilter> filters,
38 std::filesystem::path start_dir) override;
39
40 void save_file(
41 FileDialogCallback callback,
42 std::string suggested_name,
43 std::vector<SystemFileFilter> filters,
44 std::filesystem::path start_dir) override;
45
46private:
47 bool m_initialized { false };
48
49 void invoke_dialog(
50 bool is_save,
51 FileDialogCallback callback,
52 const std::vector<SystemFileFilter>& filters,
53 const std::filesystem::path& start_dir,
54 const std::string& suggested_name);
55};
56
57} // namespace MayaFlux::Core
58
59#endif // MAYAFLUX_PLATFORM_WINDOWS
void initialize()
Definition main.cpp:11
void open_file(ChooserCallback callback, std::vector< ChooserFilter > filters, std::filesystem::path start_dir)
Present a native open-file dialog, delivering the result via callback.
Definition Chooser.cpp:8
void save_file(ChooserCallback callback, std::string suggested_name, std::vector< ChooserFilter > filters, std::filesystem::path start_dir)
Present a native save-file dialog, delivering the result via callback.
Definition Chooser.cpp:23