42#include <condition_variable>
56class WorkingImageContext;
126 [[nodiscard]] std::future<bool>
applyOperations(std::vector<Operations::OperationDescriptor>&& ops);
133 [[nodiscard]]
bool loadImage(std::string_view path);
155 [[nodiscard]] std::expected<void, ErrorHandling::CoreError>
resetToOriginal();
221 [[nodiscard]]
bool executeProcessing(std::vector<Operations::OperationDescriptor> ops);
226 void waitForPendingProcessing();
235 std::atomic<bool> m_stop_requested{
false};
240 mutable std::mutex m_work_mutex;
245 std::condition_variable m_work_cv;
254 mutable std::mutex m_state_mutex;
259 std::unique_ptr<Pipeline::PipelineContext> m_pipeline_context;
264 std::unique_ptr<Workers::WorkerContext> m_worker_context;
269 std::unique_ptr<ImageProcessing::WorkingImageContext> m_working_image_context;
274 std::string m_original_image_path;
281 std::optional<std::vector<Operations::OperationDescriptor>> m_pending_work;
288 std::shared_ptr<std::promise<bool>> m_active_promise;
297 std::atomic<bool> m_is_idle{
true};
302 std::unique_ptr<Managers::ISourceManager> m_source_manager;
309 std::thread m_worker_thread;
320 std::mutex m_idle_mutex;
325 std::condition_variable m_idle_cv;
Manages the working image lifecycle and coordinates asynchronous processing.
bool loadImage(std::string_view path)
Loads an image file into the internal SourceManager.
Common::ImageChan getSourceChannels() const
Gets the number of channels of the original source image.
~StateImageManager()
Destructor.
std::expected< void, ErrorHandling::CoreError > commitWorkingImageToSource()
Commits the current working image (with applied operations) back to the SourceManager.
Common::ImageDim getSourceWidth() const
Gets the width of the original source image.
Common::ImageDim getSourceHeight() const
Gets the height of the original source image.
std::expected< void, ErrorHandling::CoreError > resetToOriginal()
Resets the image to its original state (synchronous).
StateImageManager & operator=(const StateImageManager &)=delete
StateImageManager()
Constructs a StateImageManager.
std::expected< std::unique_ptr< Common::ImageRegion >, ErrorHandling::CoreError > getDownsampledDisplayImage(Common::ImageDim target_width, Common::ImageDim target_height)
Gets a downsampled version of the working image for display. Uses GPU-accelerated downsampling,...
StateImageManager(const StateImageManager &)=delete
std::string getImageSourcePath() const
Gets the path of the image source.
std::future< bool > applyOperations(std::vector< Operations::OperationDescriptor > &&ops)
Applies a list of operations to the current image using move semantics.
std::expected< std::unique_ptr< Common::ImageRegion >, ErrorHandling::CoreError > getWorkingImageAsRegion() const
Exports the current working image data to CPU memory as an ImageRegion.
Abstract interface for managing image sources.
Abstract interface representing an image used as a working buffer, abstracting hardware location.
Common type definitions for all image types in CaptureMoment.
std::uint8_t ImageChan
Type for channel count.
std::size_t ImageDim
Type for image dimensions (width, height).
@ ImageProcessing
Errors related to Image Processing, GPU, or Memory.
CoreError
Enumeration of all error codes for CaptureMoment Core.
Manages the lifecycle of a single IWorkingImage instance.
Descriptor of an operation with its parameters and unique identifier.
Factory for creating operations (Dependency Injection)