IDS peak AFL v1.8.0
Loading...
Searching...
No Matches
peak_afl_brightness_component.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <peak_afl/peak_afl.hpp>
16
18
19namespace peak
20{
21namespace pipeline
22{
23namespace modules
24{
25namespace autofeature
26{
27
55
69{
70 switch (type)
71 {
73 return "ComponentExposure";
75 return "ComponentAnalogGain";
77 return "ComponentDigitalGain";
79 return "ComponentCombinedGain";
81 return "ComponentHostGain";
83 return "ComponentGain";
84 default:
85 break;
86 }
87
88 throw peak::common::InternalErrorException("Invalid component type!");
89}
90
109inline std::ostream& operator<<(std::ostream& os, BrightnessComponentType type)
110{
111 return os << ToString(type);
112}
113
114namespace detail
115{
116
118{
119 switch (componentType)
120 {
135 default:
136 throw peak::common::InvalidParameterException("Unknown brightness component type");
137 }
138}
139
140class GenericAutoBrightness;
141
142} // namespace detail
143
173{
174public:
179
184
194 {
195 m_parent->UnRegisterComponentCallback(detail::ToCType(m_componentType));
196 }
197
202 using FinishedCallback = std::function<void()>;
208
210 friend detail::GenericAutoBrightness;
211
220 {
221 return m_componentType;
222 }
223
232 {
233 m_parent->BrightnessComponentSetMode(detail::ToCType(m_componentType), detail::ToCType(mode));
234 }
235
244 {
245 return detail::ToControllerMode(m_parent->BrightnessComponentGetMode(detail::ToCType(m_componentType)));
246 }
247
255 void SetLimit(const IntervalD& interval)
256 {
257 m_limit->Set(interval);
258 }
259
268 {
269 return m_limit->Get();
270 }
271
280 {
281 archive.SetString("Mode", ToString(GetMode()));
282
283 auto limitArchive = archive.CreateArchive();
284 m_limit->Serialize(*limitArchive);
285
286 archive.SetArchive("Limit", limitArchive);
287 }
288
297 {
298 auto limitArchive = archive.GetArchive("Limit");
299 m_limit->Deserialize(*limitArchive);
300
301 SetMode(detail::ToControllerMode(archive.GetString("Mode")));
302 }
303
313 {
314 return m_FinishedCallbackManager.RegisterCallback(callback);
315 }
316
325 {
326 m_FinishedCallbackManager.UnregisterCallback(callbackHandle);
327 }
328
329private:
339 BrightnessComponent(const std::shared_ptr<peak::afl::Controller>& parent, BrightnessComponentType componentType,
340 std::unique_ptr<features::BrightnessLimit> limit)
341 : m_parent{ parent }
342 , m_componentType(componentType)
343 , m_limit{ std::move(limit) }
344 {
345 m_parent->RegisterComponentCallback(detail::ToCType(m_componentType), [this]() { m_FinishedCallbackManager.TriggerCallbacks(); });
346 }
347
349 peak::core::TTriggerCallbackManager<BrightnessComponent::FinishedCallbackHandle, BrightnessComponent::FinishedCallback>
350 m_FinishedCallbackManager;
351
353 std::shared_ptr<peak::afl::Controller> m_parent;
355 BrightnessComponentType m_componentType{};
357 std::unique_ptr<features::BrightnessLimit> m_limit{};
358};
359} // namespace autofeature
360} // namespace modules
361} // namespace pipeline
362} // namespace peak
void RegisterComponentCallback(peak_afl_controller_brightness_component component, const callback::FinishedCallback &callback)
Set component callback for a controller.
Definition peak_afl.hpp:2459
Thrown when an unexpected internal error occurs.
Definition peak_common_exceptions.hpp:74
Thrown when a function receives an invalid parameter.
Definition peak_common_exceptions.hpp:50
Interface for a hierarchical key-value archive system.
Definition peak_common_iarchive.hpp:59
virtual PEAK_COMMON_NO_DISCARD std::shared_ptr< IArchive > GetArchive(const std::string &key) const =0
Retrieves a nested archive by key.
virtual PEAK_COMMON_NO_DISCARD std::string GetString(const std::string &key) const =0
Retrieves a string value by key.
virtual PEAK_COMMON_NO_DISCARD std::shared_ptr< IArchive > CreateArchive() const =0
Creates a new, empty archive instance.
virtual void SetArchive(const std::string &key, const std::shared_ptr< IArchive > &value)=0
Stores a nested archive object.
virtual void SetString(const std::string &key, const std::string &value)=0
Stores a UTF-8 string.
std::function< void()> FinishedCallback
Callback function type for component completion notifications.
Definition peak_afl_brightness_component.hpp:202
void Serialize(peak::common::serialization::IArchive &archive) const
Serializes component configuration to archive.
Definition peak_afl_brightness_component.hpp:279
BrightnessComponent(BrightnessComponent &&)=delete
Move constructor deleted to prevent moving.
BrightnessComponent & operator=(BrightnessComponent &&)=delete
Move assignment deleted to prevent moving.
FinishedCallbackHandle RegisterFinishedCallback(const BrightnessComponent::FinishedCallback &callback)
Registers a callback for component completion.
Definition peak_afl_brightness_component.hpp:312
void SetMode(ControllerMode mode)
Sets the control mode for this component.
Definition peak_afl_brightness_component.hpp:231
void Deserialize(const peak::common::serialization::IArchive &archive)
Deserializes component configuration from archive.
Definition peak_afl_brightness_component.hpp:296
FinishedCallback * FinishedCallbackHandle
Handle type for managing callback registrations.
Definition peak_afl_brightness_component.hpp:207
IntervalD GetLimit()
Gets the current value limits.
Definition peak_afl_brightness_component.hpp:267
~BrightnessComponent()
Destructor that properly unregisters callbacks.
Definition peak_afl_brightness_component.hpp:193
PEAK_COMMON_NO_DISCARD ControllerMode GetMode() const
Gets the current control mode.
Definition peak_afl_brightness_component.hpp:243
void UnregisterFinishedCallback(BrightnessComponent::FinishedCallbackHandle callbackHandle)
Unregisters a previously registered callback.
Definition peak_afl_brightness_component.hpp:324
PEAK_COMMON_NO_DISCARD BrightnessComponentType GetType() const
Gets the brightness component type.
Definition peak_afl_brightness_component.hpp:219
BrightnessComponent & operator=(const BrightnessComponent &)=delete
Copy assignment deleted to prevent copying.
void SetLimit(const IntervalD &interval)
Sets the value limits for this component.
Definition peak_afl_brightness_component.hpp:255
BrightnessComponent(const BrightnessComponent &)=delete
Copy constructor deleted to prevent copying.
ControllerMode
Controller operation mode enumeration.
Definition peak_afl_icontroller.hpp:60
PEAK_COMMON_NO_DISCARD std::string ToString(ControllerType mode)
Converts ControllerType enumeration to string representation.
Definition peak_afl_icontroller.hpp:79
BrightnessComponentType
Brightness component type enumeration.
Definition peak_afl_brightness_component.hpp:39
@ CombinedGain
Combined gain component - both analog and digital (combined) gain.
Definition peak_afl_brightness_component.hpp:49
@ Gain
Automatic gain component - automatic gain control.
Definition peak_afl_brightness_component.hpp:53
@ Invalid
Invalid or uninitialized component type.
Definition peak_afl_brightness_component.hpp:41
@ AnalogGain
Analog gain component - hardware gain applied before digitization.
Definition peak_afl_brightness_component.hpp:45
@ DigitalGain
Digital gain component - gain applied after digitization.
Definition peak_afl_brightness_component.hpp:47
@ HostGain
Host gain component - software-based gain processing.
Definition peak_afl_brightness_component.hpp:51
@ Exposure
Exposure time component - controls sensor integration time.
Definition peak_afl_brightness_component.hpp:43
peak_afl_controller_brightness_component
Brightness control components.
Definition peak_afl.h:609
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_INVALID
Invalid or uninitialized component.
Definition peak_afl.h:616
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_ANALOG_GAIN
Analog gain control.
Definition peak_afl.h:651
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_GAIN
Generic gain control.
Definition peak_afl.h:639
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_COMBINED_GAIN
Combined analog and digital gain.
Definition peak_afl.h:675
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_HOST_GAIN
Host-based software gain.
Definition peak_afl.h:687
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_DIGITAL_GAIN
Digital gain control.
Definition peak_afl.h:663
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_EXPOSURE
Camera exposure time control.
Definition peak_afl.h:628
#define PEAK_COMMON_NO_DISCARD
Compatability macro for the nodiscard attribute.
Definition peak_common_defines.hpp:91
Interface definitions and implementations for individual module types used within a pipeline.
Definition peak_afl_generic_auto_brightness.hpp:39
Interfaces and implementations for defining and controlling data processing pipelines.
Definition peak_afl_generic_auto_brightness.hpp:37
peak::common::detail::IntervalT< double > IntervalD
Type alias for double-precision interval values.
Definition peak_afl_ifeature.hpp:29