CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
operation_factory.h
Go to the documentation of this file.
1
8#pragma once
9
12#include <memory>
13#include <unordered_map>
14#include <functional>
15#include <expected>
16
17namespace CaptureMoment::Core {
18
19namespace Operations {
20
21// Forward declarations
22class IOperation;
23struct OperationDescriptor;
24
33public:
39 template <typename T>
41 m_creators[type] = []() -> std::unique_ptr<IOperation> {
42 return std::make_unique<T>();
43 };
44 }
45
51 void registerCreator(OperationType type, std::function<std::unique_ptr<IOperation>()> creator) {
52 m_creators[type] = std::move(creator);
53 }
54
59 [[nodiscard]] std::expected<std::unique_ptr<IOperation>, ErrorHandling::CoreError> create(const OperationDescriptor& descriptor) const;
60
61private:
62 using OperationCreator = std::function<std::unique_ptr<IOperation>()>;
63 std::unordered_map<OperationType, OperationCreator> m_creators;
64};
65
66} // namespace Operations
67
68} // namespace CaptureMoment::Core
Factory Pattern - creates operations from OperationDescriptor.
void registerCreator(OperationType type, std::function< std::unique_ptr< IOperation >()> creator)
Register an operation creator for a given type using a lambda/function.
void registerOperation(OperationType type)
Register an operation creator for a given type using a template.
std::expected< std::unique_ptr< IOperation >, ErrorHandling::CoreError > create(const OperationDescriptor &descriptor) const
Create an operation instance from descriptor.
Central error handling system for CaptureMoment Core library.
CoreError
Enumeration of all error codes for CaptureMoment Core.
Definition core_error.h:36
OperationType
Identifies the type of an image processing operation.
Manages the lifecycle of a single IWorkingImage instance.
Enumeration of image processing operation types.
A universal container for operation settings with unique identifier.
CaptureMoment — footer