MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
DataProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace MayaFlux::Kakshya {
4
5class SignalSourceContainer;
6
7/**
8 * @class DataProcessor
9 * @brief Interface for processing data within SignalSourceContainer objects
10 *
11 * DataProcessor defines the interface for components that transform data stored in
12 * SignalSourceContainer objects. While conceptually similar to BufferProcessor in the
13 * audio buffer domain, DataProcessor operates with greater independence and flexibility,
14 * designed specifically for on-demand processing of arbitrary data sources.
15 *
16 * Key differences from BufferProcessor:
17 * - Independence from engine cycle: DataProcessors can be invoked on demand rather than
18 * being tied to the audio engine's processing cycle
19 * - Broader data scope: Operates on arbitrary data sources beyond audio buffers
20 * - Lifecycle management: Includes explicit attach/detach methods for resource management
21 * - State tracking: Maintains processing state for asynchronous operations
22 * - Self-contained: Can operate without dependency on BufferManager or other engine components
23 *
24 * DataProcessors enable flexible data transformation workflows that can operate independently
25 * of the real-time audio processing path, making them ideal for tasks like:
26 * - File loading and format conversion
27 * - Offline processing of large datasets
28 * - Background analysis and feature extraction
29 * - Scheduled or event-driven processing
30 * - Integration with external data sources and sinks
31 */
32class MAYAFLUX_API DataProcessor {
33public:
34 /**
35 * @brief Virtual destructor for proper cleanup
36 */
37 virtual ~DataProcessor() = default;
38
39 /**
40 * @brief Called when this processor is attached to a container
41 * @param container Container this processor is being attached to
42 *
43 * This method provides an opportunity for the processor to:
44 * - Initialize container-specific state
45 * - Allocate resources needed for processing
46 * - Validate the container's data structure
47 * - Configure processing parameters based on container properties
48 * - Store references or metadata needed for processing
49 *
50 * Unlike BufferProcessor which may be attached implicitly through chains,
51 * DataProcessor attachment is typically an explicit operation that triggers
52 * immediate initialization.
53 */
54 virtual void on_attach(std::shared_ptr<SignalSourceContainer> container) = 0;
55
56 /**
57 * @brief Called when this processor is detached from a container
58 * @param container Container this processor is being detached from
59 *
60 * This method allows the processor to:
61 * - Release container-specific resources
62 * - Finalize any pending operations
63 * - Clean up state information
64 * - Perform any necessary cleanup before the processor is removed
65 *
66 * Explicit detachment provides cleaner resource management compared to
67 * BufferProcessor's implicit detachment through chain removal.
68 */
69 virtual void on_detach(std::shared_ptr<SignalSourceContainer> container) = 0;
70
71 /**
72 * @brief Processes the data in the container
73 * @param container Container whose data should be processed
74 *
75 * This is the main processing method that transforms the container's data.
76 * Unlike BufferProcessor which is typically invoked automatically during
77 * the engine's processing cycle, DataProcessor's process method is called
78 * explicitly when processing is needed, enabling on-demand operation.
79 *
80 * This method may:
81 * - Transform data in place within the container
82 * - Generate new data based on the container's content
83 * - Analyze the container's data and store results
84 * - Update the container's metadata or state
85 */
86 virtual void process(std::shared_ptr<SignalSourceContainer> container) = 0;
87
88 /**
89 * @brief Checks if the processor is currently performing processing
90 * @return true if processing is in progress, false otherwise
91 *
92 * This state tracking enables asynchronous processing models where
93 * a processor might operate in a background thread or over multiple
94 * invocations. It allows clients to check if processing has completed
95 * without blocking.
96 *
97 * BufferProcessors lack this state tracking as they operate synchronously
98 * within the engine's processing cycle.
99 */
100 virtual bool is_processing() const = 0;
101};
102
103}
virtual bool is_processing() const =0
Checks if the processor is currently performing processing.
virtual void on_detach(std::shared_ptr< SignalSourceContainer > container)=0
Called when this processor is detached from a container.
virtual void process(std::shared_ptr< SignalSourceContainer > container)=0
Processes the data in the container.
virtual void on_attach(std::shared_ptr< SignalSourceContainer > container)=0
Called when this processor is attached to a container.
virtual ~DataProcessor()=default
Virtual destructor for proper cleanup.
Interface for processing data within SignalSourceContainer objects.