MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Depot.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file API/Depot.hpp
5 * @brief Audio file loading and container management API
6 *
7 * This header provides the public API for working with IOManager,
8 * container creation, and file type checking within the MayaFlux engine.
9 * It includes:
10 * - `create_container<ContainerType>(args...)`: Template function to create signal source containers.
11 * - `is_audio(filepath)`: Check if a file is an audio file based on its extension.
12 * - `is_image(filepath)`: Check if a file is an image file based on its extension.
13 * - `get_io_manager()`: Access the global IOManager instance for file loading and buffer management.
14 */
15
16namespace MayaFlux {
17
18namespace Core {
19 class VKImage;
20}
21
22namespace IO {
23 class IOManager;
24 struct ImageWriteOptions;
25 using TextureResolver = std::function<std::shared_ptr<Core::VKImage>(const std::string&)>; // add
26}
27
28namespace Kakshya {
33}
34
35namespace Buffers {
37 class TextureBuffer;
38 class MeshBuffer;
39}
40
41namespace Nodes::Network {
42 class MeshNetwork;
43}
44
45/**
46 * @brief creates a new container of the specified type
47 * @tparam ContainerType Type of container to create (must be derived from SignalSourceContainer)
48 * @tparam Args Constructor argument types
49 * @param args Constructor arguments for the container
50 * @return Shared pointer to the created container
51 */
52template <typename ContainerType, typename... Args>
53 requires std::derived_from<ContainerType, Kakshya::SignalSourceContainer>
54auto create_container(Args&&... args) -> std::shared_ptr<ContainerType>
55{
56 return std::make_shared<ContainerType>(std::forward<Args>(args)...);
57}
58
59/**
60 * @brief Constructs and initializes per-channel SoundContainerBuffers without registering them.
61 * @param container Source container.
62 * @return One buffer per channel, unregistered, ready for manual routing.
63 */
64MAYAFLUX_API std::vector<std::shared_ptr<Buffers::SoundContainerBuffer>>
65prepare_audio_buffers(const std::shared_ptr<Kakshya::SoundFileContainer>& container);
66
67/**
68 * @brief Checks if the given file is an audio file based on its extension
69 * @param filepath Path to the file to check
70 * @return true if the file is recognized as an audio file, false otherwise
71 */
72MAYAFLUX_API bool is_audio(const std::filesystem::path& filepath);
73
74/**
75 * @brief Checks if the given file is an image file based on its extension
76 * @param filepath Path to the file to check
77 * @return true if the file is recognized as an image file, false otherwise
78 */
79MAYAFLUX_API bool is_image(const std::filesystem::path& filepath);
80
81// ─────────────────────────────────────────────────────────────────────────
82// Dialog-backed load — open
83// ─────────────────────────────────────────────────────────────────────────
84
85/**
86 * @brief Present a native open-file dialog filtered to audio formats and load
87 * the chosen file via IOManager::load_audio().
88 *
89 * Blocks until the user confirms or cancels. Returns nullptr on cancellation,
90 * backend error, or if Portal::System is not initialized.
91 */
92MAYAFLUX_API std::shared_ptr<Kakshya::SoundFileContainer> choose_audio();
93
94/**
95 * @brief Present a native open-file dialog filtered to video formats and load
96 * the chosen file via IOManager::load_video().
97 *
98 * Blocks until the user confirms or cancels. Returns nullptr on cancellation,
99 * backend error, or if Portal::System is not initialized.
100 */
101MAYAFLUX_API std::shared_ptr<Kakshya::VideoFileContainer> choose_video();
102
103/**
104 * @brief Present a native open-file dialog filtered to image formats and load
105 * the chosen file via IOManager::load_image().
106 *
107 * Blocks until the user confirms or cancels. Returns nullptr on cancellation,
108 * backend error, or if Portal::System is not initialized.
109 */
110MAYAFLUX_API std::shared_ptr<Buffers::TextureBuffer> choose_image();
111
112/**
113 * @brief Present a native open-file dialog filtered to 3D model formats and load
114 * the chosen file via IOManager::load_mesh().
115 *
116 * Blocks until the user confirms or cancels. Returns an empty vector on
117 * cancellation, backend error, or if Portal::System is not initialized.
118 */
119MAYAFLUX_API std::vector<std::shared_ptr<Buffers::MeshBuffer>> choose_mesh();
120
121/**
122 * @brief Present a native open-file dialog filtered to 3D model formats and load
123 * the chosen file as a MeshNetwork via IOManager::load_mesh_network().
124 *
125 * @param resolver Optional texture resolver; null uses the IOManager default.
126 *
127 * Blocks until the user confirms or cancels. Returns nullptr on cancellation,
128 * backend error, or if Portal::System is not initialized.
129 */
130MAYAFLUX_API std::shared_ptr<Nodes::Network::MeshNetwork>
131choose_mesh_network(IO::TextureResolver resolver = nullptr);
132
133// ─────────────────────────────────────────────────────────────────────────
134// Dialog-backed save
135// ─────────────────────────────────────────────────────────────────────────
136
137/**
138 * @brief Present a native save-file dialog and write @p container to the
139 * chosen path via IOManager::write().
140 *
141 * Blocks until the user confirms or cancels. The encode task is queued
142 * asynchronously; this function returns once the path is chosen and the
143 * task is enqueued. Returns false on cancellation, backend error, or if
144 * Portal::System is not initialized.
145 *
146 * @param container Source container to encode.
147 * @param suggested_name Filename pre-filled in the dialog name field.
148 */
149MAYAFLUX_API bool save_audio(
150 const std::shared_ptr<Kakshya::SoundStreamContainer>& container,
151 const std::string& suggested_name = "output.wav");
152
153/**
154 * @brief Present a native save-file dialog filtered to image formats and save
155 * @p buffer to the chosen path via IOManager::save_image().
156 *
157 * Blocks until the user confirms or cancels. The encode task is queued
158 * asynchronously. Returns false on cancellation, backend error, or if
159 * Portal::System is not initialized.
160 *
161 * @param buffer Source TextureBuffer to encode.
162 * @param suggested_name Filename pre-filled in the dialog name field.
163 */
164MAYAFLUX_API bool save_image(
165 const std::shared_ptr<Buffers::TextureBuffer>& buffer,
166 const std::string& suggested_name = "output.png");
167
168/**
169 * @brief Present a native save-file dialog filtered to image formats and save
170 * @p buffer to the chosen path via IOManager::save_image().
171 *
172 * Blocks until the user confirms or cancels. The encode task is queued
173 * asynchronously. Returns false on cancellation, backend error, or if
174 * Portal::System is not initialized.
175 *
176 * @param buffer Source TextureBuffer to encode.
177 * @param suggested_name Filename pre-filled in the dialog name field.
178 * @param options Format-specific writer options forwarded to IOManager.
179 */
180MAYAFLUX_API bool save_image(
181 const std::shared_ptr<Buffers::TextureBuffer>& buffer,
182 const std::string& suggested_name,
183 const IO::ImageWriteOptions& options);
184
185/**
186 * @brief Retrieves the global IOManager instance for file loading and buffer management
187 * @return Shared pointer to the IOManager instance
188 *
189 * Provides access to the central IOManager responsible for all file loading operations,
190 * container management, and buffer integration. This is the primary interface for
191 * performing file I/O tasks within the MayaFlux engine.
192 */
193MAYAFLUX_API std::shared_ptr<IO::IOManager> get_io_manager();
194
195}
VKBuffer subclass that owns a MeshData and manages its GPU upload.
AudioBuffer implementation backed by a StreamContainer.
A hybrid buffer managing both a textured quad geometry and its pixel data.
Optional orchestration layer for IO reader lifetime and IOService dispatch.
Definition IOManager.hpp:96
Data-driven interface for managing arbitrary processable signal sources.
File-backed audio container with complete streaming functionality.
Concrete base implementation for streaming audio containers.
File-backed video container — semantic marker over VideoStreamContainer.
NodeNetwork subclass whose nodes are named, hierarchically transformable mesh slots.
std::function< std::shared_ptr< Core::VKImage >(const std::string &)> TextureResolver
Callable that maps a raw material texture path to a GPU image.
Definition Depot.hpp:25
@ Core
Core engine, backend, subsystems.
bool is_image(const fs::path &filepath)
Definition Depot.cpp:108
std::shared_ptr< Kakshya::VideoFileContainer > choose_video()
Present a native open-file dialog filtered to video formats and load the chosen file via IOManager::l...
Definition Depot.cpp:133
bool save_image(const std::shared_ptr< Buffers::TextureBuffer > &buffer, const std::string &suggested_name)
Present a native save-file dialog filtered to image formats and save buffer to the chosen path via IO...
Definition Depot.cpp:207
std::shared_ptr< Nodes::Network::MeshNetwork > choose_mesh_network(IO::TextureResolver resolver)
Present a native open-file dialog filtered to 3D model formats and load the chosen file as a MeshNetw...
Definition Depot.cpp:166
bool is_audio(const fs::path &filepath)
Definition Depot.cpp:113
std::vector< std::shared_ptr< Buffers::MeshBuffer > > choose_mesh()
Present a native open-file dialog filtered to 3D model formats and load the chosen file via IOManager...
Definition Depot.cpp:155
std::shared_ptr< Kakshya::SoundFileContainer > choose_audio()
Present a native open-file dialog filtered to audio formats and load the chosen file via IOManager::l...
Definition Depot.cpp:122
auto create_container(Args &&... args) -> std::shared_ptr< ContainerType >
creates a new container of the specified type
Definition Depot.hpp:54
bool save_audio(const std::shared_ptr< Kakshya::SoundStreamContainer > &container, const std::string &suggested_name)
Present a native save-file dialog and write container to the chosen path via IOManager::write().
Definition Depot.cpp:183
std::shared_ptr< IO::IOManager > get_io_manager()
Retrieves the global IOManager instance for file loading and buffer management.
Definition Depot.cpp:256
std::shared_ptr< Buffers::TextureBuffer > choose_image()
Present a native open-file dialog filtered to image formats and load the chosen file via IOManager::l...
Definition Depot.cpp:144
std::vector< std::shared_ptr< Buffers::SoundContainerBuffer > > prepare_audio_buffers(const std::shared_ptr< Kakshya::SoundFileContainer > &container)
Constructs and initializes per-channel SoundContainerBuffers without registering them.
Definition Depot.cpp:86
Main namespace for the Maya Flux audio engine.
Definition Runtime.cpp:12
Configuration for image writing.