Message ID | 20221115090755.2921-4-naush@raspberrypi.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Naush Thanks for the updated patch. On Tue, 15 Nov 2022 at 09:08, Naushir Patuck via libcamera-devel <libcamera-devel@lists.libcamera.org> wrote: > > Convert ControlRingBuffer to a templated class to allow arbitrary ring buffer > array types to be defined. Rename ControlRingBuffer to RingBuffer to indicate > this. > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Thanks David > --- > .../pipeline/raspberrypi/delayed_controls.h | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/src/libcamera/pipeline/raspberrypi/delayed_controls.h b/src/libcamera/pipeline/raspberrypi/delayed_controls.h > index f7f246482968..238b86ab6cb4 100644 > --- a/src/libcamera/pipeline/raspberrypi/delayed_controls.h > +++ b/src/libcamera/pipeline/raspberrypi/delayed_controls.h > @@ -56,17 +56,18 @@ private: > }; > > static constexpr int listSize = 16; > - class ControlRingBuffer : public std::array<Info, listSize> > + template<typename T> > + class RingBuffer : public std::array<T, listSize> > { > public: > - Info &operator[](unsigned int index) > + T &operator[](unsigned int index) > { > - return std::array<Info, listSize>::operator[](index % listSize); > + return std::array<T, listSize>::operator[](index % listSize); > } > > - const Info &operator[](unsigned int index) const > + const T &operator[](unsigned int index) const > { > - return std::array<Info, listSize>::operator[](index % listSize); > + return std::array<T, listSize>::operator[](index % listSize); > } > }; > > @@ -76,7 +77,7 @@ private: > > uint32_t queueCount_; > uint32_t writeCount_; > - std::unordered_map<const ControlId *, ControlRingBuffer> values_; > + std::unordered_map<const ControlId *, RingBuffer<Info>> values_; > }; > > } /* namespace RPi */ > -- > 2.25.1 >
diff --git a/src/libcamera/pipeline/raspberrypi/delayed_controls.h b/src/libcamera/pipeline/raspberrypi/delayed_controls.h index f7f246482968..238b86ab6cb4 100644 --- a/src/libcamera/pipeline/raspberrypi/delayed_controls.h +++ b/src/libcamera/pipeline/raspberrypi/delayed_controls.h @@ -56,17 +56,18 @@ private: }; static constexpr int listSize = 16; - class ControlRingBuffer : public std::array<Info, listSize> + template<typename T> + class RingBuffer : public std::array<T, listSize> { public: - Info &operator[](unsigned int index) + T &operator[](unsigned int index) { - return std::array<Info, listSize>::operator[](index % listSize); + return std::array<T, listSize>::operator[](index % listSize); } - const Info &operator[](unsigned int index) const + const T &operator[](unsigned int index) const { - return std::array<Info, listSize>::operator[](index % listSize); + return std::array<T, listSize>::operator[](index % listSize); } }; @@ -76,7 +77,7 @@ private: uint32_t queueCount_; uint32_t writeCount_; - std::unordered_map<const ControlId *, ControlRingBuffer> values_; + std::unordered_map<const ControlId *, RingBuffer<Info>> values_; }; } /* namespace RPi */
Convert ControlRingBuffer to a templated class to allow arbitrary ring buffer array types to be defined. Rename ControlRingBuffer to RingBuffer to indicate this. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> --- .../pipeline/raspberrypi/delayed_controls.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)