CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
working_image_factory.cpp
Go to the documentation of this file.
1
10#include "config/app_config.h"
11#include <spdlog/spdlog.h>
12
14
15std::unique_ptr<IWorkingImageHardware> WorkingImageFactory::create()
16{
18
19 spdlog::trace("[WorkingImageFactory::create]: Using global backend config: {}", static_cast<int>(backend));
20
21 return create(backend);
22}
23
24std::unique_ptr<IWorkingImageHardware> WorkingImageFactory::create(
25 Common::MemoryType backend
26 )
27{
28 // Look up creator for the requested backend
29 auto it { s_registry.find(backend) };
30
31 if (it == s_registry.end()) {
32 spdlog::error("[WorkingImageFactory::create]: No creator registered for backend type {}. Unable to create working image.",
33 static_cast<int>(backend));
34 return nullptr;
35 }
36
37 try {
38 auto creator { it->second };
39 return creator();
40 } catch (const std::exception& e) {
41 spdlog::critical("[WorkingImageFactory::create]: Exception thrown by creator for backend {}: {}",
42 static_cast<int>(backend), e.what());
43 return nullptr;
44 }
45}
46
49 CreatorFunction creator
50 )
51{
52 if (s_registry.contains(type)) {
53 spdlog::warn("[WorkingImageFactory::registerCreator]: Overriding existing creator for backend type {}.", static_cast<int>(type));
54 }
55 s_registry[type] = std::move(creator);
56}
57
58} // namespace CaptureMoment::Core::ImageProcessing
Application-wide configuration singleton.
Common::MemoryType getProcessingBackend() const noexcept
Gets the configured processing backend.
static AppConfig & instance()
Gets the singleton instance of AppConfig.
static void registerCreator(Common::MemoryType type, CreatorFunction creator)
Registers a creator function for a specific backend type.
std::function< std::unique_ptr< IWorkingImageHardware >()> CreatorFunction
Definition of a creator function.
static std::unique_ptr< IWorkingImageHardware > create()
Creates a working image using the application's global configuration.
MemoryType
Enum representing the memory type where image data is stored.
Definition memory_type.h:24
Factory for creating IWorkingImageHardware instances using a Registry Pattern.
CaptureMoment — footer