CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
operation_descriptor.h
Go to the documentation of this file.
1
8#pragma once
9
12
13#include <string>
14#include <unordered_map>
15#include <variant>
16#include <expected>
17#include <cstdint>
18#include <atomic>
19
20namespace CaptureMoment::Core {
21
22namespace Operations {
23
28using OperationValue = std::variant<float, int, bool, std::string>;
29
55 uint64_t id{0};
56
62
67 std::string name;
68
73 bool enabled{true};
74
78 std::unordered_map<std::string, OperationValue> params;
79
87 static uint64_t generateId() {
88 static std::atomic<uint64_t> counter{1};
89 return counter.fetch_add(1, std::memory_order_relaxed);
90 }
91
98 template <typename T>
99 [[nodiscard]] std::expected<T, ErrorHandling::CoreError> getParam(const std::string& key) const
100 {
101 auto it = params.find(key);
102 if (it == params.end()) {
103 return std::unexpected(ErrorHandling::CoreError::Unexpected);
104 }
105
106 if (std::holds_alternative<T>(it->second)) {
107 return std::get<T>(it->second);
108 } else {
109 return std::unexpected(ErrorHandling::CoreError::Unexpected);
110 }
111 }
112
117 template <typename T>
118 void setParam(const std::string& key, const T& value) {
119 params[key] = value;
120 }
121};
122
123} // namespace Operations
124
125} // namespace CaptureMoment::Core
Central error handling system for CaptureMoment Core library.
@ Unexpected
An unexpected error occurred.
std::variant< float, int, bool, std::string > OperationValue
Supported types for operation parameters. Using variant instead of std::any for compile-time type saf...
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.
OperationType type
The operation type (e.g., Brightness, Contrast, Saturation). Used by the factory to create the approp...
void setParam(const std::string &key, const T &value)
Helper to set a parameter value.
static uint64_t generateId()
Generates a unique identifier for a new operation.
bool enabled
Whether this operation is currently active. Disabled operations are skipped during pipeline execution...
std::expected< T, ErrorHandling::CoreError > getParam(const std::string &key) const
Helper to get a parameter value safely with error handling.
std::string name
Human-readable name for display purposes. May include parameter values, e.g., "Brightness (100%)".
std::unordered_map< std::string, OperationValue > params
Generic parameter storage using variant (Type Safe).
CaptureMoment — footer