MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
QuickProcess.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace MayaFlux::Buffers {
7
8template <typename FuncType>
10public:
11 QuickProcess(FuncType function)
12 : m_function(std::move(function))
13 {
14 }
15
16 void processing_function(const std::shared_ptr<Buffer>& buffer) override
17 {
18 if constexpr (std::is_same_v<FuncType, AudioProcessingFunction>) {
19 if (auto audio_buf = std::dynamic_pointer_cast<AudioBuffer>(buffer)) {
20 m_function(audio_buf);
21 }
22 } else {
23 if (auto vk_buf = std::dynamic_pointer_cast<VKBuffer>(buffer)) {
24 m_function(vk_buf);
25 }
26 }
27 }
28
29 void on_attach(const std::shared_ptr<Buffer>& /*buffer*/) override
30 {
31 if constexpr (std::is_same_v<FuncType, AudioProcessingFunction>) {
33 } else {
35 }
36 }
37
38 [[nodiscard]] bool is_compatible_with(const std::shared_ptr<Buffer>& buffer) const override
39 {
40 if constexpr (std::is_same_v<FuncType, AudioProcessingFunction>) {
41 return std::dynamic_pointer_cast<AudioBuffer>(buffer) != nullptr;
42 } else {
43 return std::dynamic_pointer_cast<VKBuffer>(buffer) != nullptr;
44 }
45 }
46
47private:
48 FuncType m_function;
49};
50
51}
Central computational transformation interface for continuous buffer processing.
void on_attach(const std::shared_ptr< Buffer > &) override
Called when this processor is attached to a buffer.
void processing_function(const std::shared_ptr< Buffer > &buffer) override
The core processing function that must be implemented by derived classes.
bool is_compatible_with(const std::shared_ptr< Buffer > &buffer) const override
Checks if this processor can handle the specified buffer type.
@ AUDIO_BACKEND
Standard audio processing backend configuration.
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.