DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator Struct Reference

#include <IterableQueueModel.hpp>

Public Types

using iterator_category = std::forward_iterator_tag
 
using difference_type = std::ptrdiff_t
 
using value_type = T
 
using pointer = T*
 
using reference = T&
 

Public Member Functions

 Iterator (IterableQueueModel< T > &queue, uint32_t index)
 
reference operator* () const
 
pointer operator-> ()
 
Iteratoroperator++ ()
 
Iterator operator++ (int amount)
 
bool good ()
 
uint32_t get_index ()
 

Private Attributes

IterableQueueModel< T > & m_queue
 
uint32_t m_index
 

Friends

bool operator== (const Iterator &a, const Iterator &b)
 
bool operator!= (const Iterator &a, const Iterator &b)
 

Detailed Description

template<class T>
struct dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator

Definition at line 243 of file IterableQueueModel.hpp.

Member Typedef Documentation

◆ difference_type

template<class T >
using dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::difference_type = std::ptrdiff_t

Definition at line 246 of file IterableQueueModel.hpp.

◆ iterator_category

template<class T >
using dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::iterator_category = std::forward_iterator_tag

Definition at line 245 of file IterableQueueModel.hpp.

◆ pointer

template<class T >
using dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::pointer = T*

Definition at line 248 of file IterableQueueModel.hpp.

◆ reference

template<class T >
using dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::reference = T&

Definition at line 249 of file IterableQueueModel.hpp.

◆ value_type

template<class T >
using dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::value_type = T

Definition at line 247 of file IterableQueueModel.hpp.

Constructor & Destructor Documentation

◆ Iterator()

template<class T >
dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::Iterator ( IterableQueueModel< T > & queue,
uint32_t index )
inline

Member Function Documentation

◆ get_index()

template<class T >
uint32_t dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::get_index ( )
inline

Definition at line 292 of file IterableQueueModel.hpp.

292{ return m_index; } // NOLINT(build/unsigned)

◆ good()

template<class T >
bool dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::good ( )
inline

Definition at line 282 of file IterableQueueModel.hpp.

283 {
284 auto const currentRead = m_queue.readIndex_.load(std::memory_order_relaxed);
285 auto const currentWrite = m_queue.writeIndex_.load(std::memory_order_relaxed);
286 return (*this != m_queue.end()) &&
287 ((m_index >= currentRead && m_index < currentWrite) ||
288 (m_index >= currentRead && currentWrite < currentRead) ||
289 (currentWrite < currentRead && m_index < currentRead && m_index < currentWrite));
290 }

◆ operator*()

template<class T >
reference dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::operator* ( ) const
inline

Definition at line 256 of file IterableQueueModel.hpp.

256{ return m_queue.records_[m_index]; }

◆ operator++() [1/2]

template<class T >
Iterator & dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::operator++ ( )
inline

Definition at line 258 of file IterableQueueModel.hpp.

259 {
260 if (good()) {
261 m_index++;
262 if (m_index == m_queue.size_) {
263 m_index = 0;
264 }
265 }
266 if (!good()) {
267 m_index = std::numeric_limits<uint32_t>::max(); // NOLINT(build/unsigned)
268 }
269 return *this;
270 }

◆ operator++() [2/2]

template<class T >
Iterator dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::operator++ ( int amount)
inline

Definition at line 271 of file IterableQueueModel.hpp.

272 {
273 Iterator tmp = *this;
274 for (int i = 0; i < amount; ++i) {
275 ++(*this);
276 }
277 return tmp;
278 }
Iterator(IterableQueueModel< T > &queue, uint32_t index)

◆ operator->()

template<class T >
pointer dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::operator-> ( )
inline

Definition at line 257 of file IterableQueueModel.hpp.

257{ return &m_queue.records_[m_index]; }

Friends And Related Symbol Documentation

◆ operator!=

template<class T >
bool operator!= ( const Iterator & a,
const Iterator & b )
friend

Definition at line 280 of file IterableQueueModel.hpp.

280{ return a.m_index != b.m_index; }

◆ operator==

template<class T >
bool operator== ( const Iterator & a,
const Iterator & b )
friend

Definition at line 279 of file IterableQueueModel.hpp.

279{ return a.m_index == b.m_index; }

Member Data Documentation

◆ m_index

template<class T >
uint32_t dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::m_index
private

Definition at line 296 of file IterableQueueModel.hpp.

◆ m_queue

template<class T >
IterableQueueModel<T>& dunedaq::datahandlinglibs::IterableQueueModel< T >::Iterator::m_queue
private

Definition at line 295 of file IterableQueueModel.hpp.


The documentation for this struct was generated from the following file: