IDS peak AFL v2.1.0
Loading...
Searching...
No Matches
peak_afl_brightness_component.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
12
14
15namespace peak
16{
17namespace pipeline
18{
19namespace modules
20{
21namespace autofeature
22{
50
63PEAK_COMMON_NO_DISCARD inline std::string ToString(BrightnessComponentType type)
64{
65 switch (type)
66 {
68 return "ComponentExposure";
70 return "ComponentAnalogGain";
72 return "ComponentDigitalGain";
74 return "ComponentCombinedGain";
76 return "ComponentHostGain";
78 return "ComponentGain";
79 default:
80 break;
81 }
82
84}
85
104inline std::ostream& operator<<(std::ostream& os, BrightnessComponentType type)
105{
106 return os << ToString(type);
107}
108
109namespace detail
110{
111PEAK_COMMON_NO_DISCARD inline peak_afl_controller_brightness_component ToCType(BrightnessComponentType componentType)
112{
113 // clang-format off
114 PEAK_AFL_BEGIN_DISABLE_DEPRECATED_WARNINGS
115 switch (componentType)
116 {
131 }
132 PEAK_AFL_END_DISABLE_DEPRECATED_WARNINGS
133 // clang-format on
134
135 throw peak::afl::error::InvalidParameterException("Unknown brightness component type", PEAK_AFL_STATUS_INVALID_PARAMETER);
136}
137
138class GenericAutoBrightness;
139} // namespace detail
140
170{
171public:
176
181
191 {
192 m_parent->UnRegisterComponentCallback(detail::ToCType(m_componentType));
193 }
194
199 using FinishedCallback = std::function<void()>;
205
207 friend class detail::GenericAutoBrightness;
208
216 PEAK_COMMON_NO_DISCARD BrightnessComponentType GetType() const
217 {
218 return m_componentType;
219 }
220
229 {
230 m_parent->BrightnessComponentSetMode(detail::ToCType(m_componentType), detail::ToCType(mode));
231 }
232
240 PEAK_COMMON_NO_DISCARD ControllerMode GetMode() const
241 {
242 return detail::ToControllerMode(m_parent->BrightnessComponentGetMode(detail::ToCType(m_componentType)));
243 }
244
252 void SetLimit(const IntervalD& interval)
253 {
254 m_limit->Set(interval);
255 }
256
265 {
266 return m_limit->Get();
267 }
268
277 {
278 archive.SetString("Mode", ToString(GetMode()));
279
280 auto limitArchive = archive.CreateArchive();
281 m_limit->Serialize(*limitArchive);
282
283 archive.SetArchive("Limit", limitArchive);
284 }
285
294 {
295 auto limitArchive = archive.GetArchive("Limit");
296 m_limit->Deserialize(*limitArchive);
297
298 SetMode(detail::ToControllerMode(archive.GetString("Mode")));
299 }
300
310 {
311 return m_FinishedCallbackManager.RegisterCallback(callback);
312 }
313
322 {
323 m_FinishedCallbackManager.UnregisterCallback(callbackHandle);
324 }
325
326private:
336 BrightnessComponent(const std::shared_ptr<peak::afl::Controller>& parent, BrightnessComponentType componentType,
337 std::unique_ptr<features::BrightnessLimit> limit)
338 : m_parent{ parent }
339 , m_componentType(componentType)
340 , m_limit{ std::move(limit) }
341 {
342 m_parent->RegisterComponentCallback(detail::ToCType(m_componentType), [this]() { m_FinishedCallbackManager.TriggerCallbacks(); });
343 }
344
346 peak::core::TTriggerCallbackManager<BrightnessComponent::FinishedCallbackHandle, BrightnessComponent::FinishedCallback>
347 m_FinishedCallbackManager;
348
350 std::shared_ptr<peak::afl::Controller> m_parent;
352 BrightnessComponentType m_componentType{};
354 std::unique_ptr<features::BrightnessLimit> m_limit{};
355};
356} // namespace autofeature
357} // namespace modules
358} // namespace pipeline
359} // namespace peak
void RegisterComponentCallback(peak_afl_controller_brightness_component component, const callback::FinishedCallback &callback)
Set component callback for a controller.
Definition peak_afl.hpp:2960
The exception thrown for signaling an unspecified error.
Definition peak_afl.hpp:385
The exception thrown for passing an invalid parameter to a function.
Definition peak_afl.hpp:436
Interface for a hierarchical key-value archive system.
Definition peak_common_iarchive.hpp:54
virtual std::shared_ptr< IArchive > GetArchive(const std::string &key) const =0
Retrieves a nested archive by key.
virtual std::string GetString(const std::string &key) const =0
Retrieves a string value by key.
virtual 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:199
void Serialize(peak::common::serialization::IArchive &archive) const
Serializes component configuration to archive.
Definition peak_afl_brightness_component.hpp:276
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:309
void SetMode(ControllerMode mode)
Sets the control mode for this component.
Definition peak_afl_brightness_component.hpp:228
void Deserialize(const peak::common::serialization::IArchive &archive)
Deserializes component configuration from archive.
Definition peak_afl_brightness_component.hpp:293
FinishedCallback * FinishedCallbackHandle
Handle type for managing callback registrations.
Definition peak_afl_brightness_component.hpp:204
IntervalD GetLimit()
Gets the current value limits.
Definition peak_afl_brightness_component.hpp:264
BrightnessComponentType GetType() const
Gets the brightness component type.
Definition peak_afl_brightness_component.hpp:216
~BrightnessComponent()
Destructor that properly unregisters callbacks.
Definition peak_afl_brightness_component.hpp:190
void UnregisterFinishedCallback(BrightnessComponent::FinishedCallbackHandle callbackHandle)
Unregisters a previously registered callback.
Definition peak_afl_brightness_component.hpp:321
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:252
ControllerMode GetMode() const
Gets the current control mode.
Definition peak_afl_brightness_component.hpp:240
BrightnessComponent(const BrightnessComponent &)=delete
Copy constructor deleted to prevent copying.
peak_afl_controller_brightness_component
Brightness control components.
Definition peak_afl.h:874
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_INVALID
Invalid or uninitialized component.
Definition peak_afl.h:881
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_ANALOG_GAIN
Analog gain control.
Definition peak_afl.h:916
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_GAIN
Generic gain control.
Definition peak_afl.h:904
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_COMBINED_GAIN
Combined analog and digital gain.
Definition peak_afl.h:940
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_HOST_GAIN
Host-based software gain.
Definition peak_afl.h:952
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_DIGITAL_GAIN
Digital gain control.
Definition peak_afl.h:928
@ PEAK_AFL_CONTROLLER_BRIGHTNESS_COMPONENT_EXPOSURE
Camera exposure time control.
Definition peak_afl.h:893
@ PEAK_AFL_STATUS_INVALID_PARAMETER
Invalid parameter provided.
Definition peak_afl.h:416
@ PEAK_AFL_STATUS_ERROR
General error occurred.
Definition peak_afl.h:396
ControllerMode
Controller operation mode enumeration.
Definition peak_afl_icontroller.hpp:55
std::string ToString(ControllerType mode)
Converts ControllerType enumeration to string representation.
Definition peak_afl_icontroller.hpp:74
BrightnessComponentType
Brightness component type enumeration.
Definition peak_afl_brightness_component.hpp:34
@ CombinedGain
Combined gain component - both analog and digital (combined) gain.
Definition peak_afl_brightness_component.hpp:44
@ Gain
Automatic gain component - automatic gain control.
Definition peak_afl_brightness_component.hpp:48
@ Invalid
Invalid or uninitialized component type.
Definition peak_afl_brightness_component.hpp:36
@ AnalogGain
Analog gain component - hardware gain applied before digitization.
Definition peak_afl_brightness_component.hpp:40
@ DigitalGain
Digital gain component - gain applied after digitization.
Definition peak_afl_brightness_component.hpp:42
@ HostGain
Host gain component - software-based gain processing.
Definition peak_afl_brightness_component.hpp:46
@ Exposure
Exposure time component - controls sensor integration time.
Definition peak_afl_brightness_component.hpp:38
Interface definitions and implementations for individual module types used within a pipeline.
Definition peak_afl_generic_auto_brightness.hpp:35
Interfaces and implementations for defining and controlling data processing pipelines.
Definition peak_afl_generic_auto_brightness.hpp:33
peak::common::detail::IntervalT< double > IntervalD
Type alias for double-precision interval values.
Definition peak_afl_ifeature.hpp:24