ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCompactCellContainer::compact_output_iterator Class Reference

Simple iterator-like object for writing to the container. More...

#include <CaloCompactCellContainer.h>

Collaboration diagram for CaloCompactCellContainer::compact_output_iterator:

Public Member Functions

 compact_output_iterator ()
 Default constructor.
 compact_output_iterator (std::vector< value_type >::iterator it)
 Constructor.
void set (CaloCompactCell::value_type x)
 Set the next value, and advance the iterator.
compact_output_iterator & operator++ ()
 Advance the iterator.
int used () const
 Return the number of underlying value_type words used.

Private Attributes

std::vector< value_type >::iterator m_it
 The iterator in the underlying container type.
int m_count
 Count; used to tell how many more times we need to shift m_word.

Detailed Description

Simple iterator-like object for writing to the container.

This allows writing one CaloCompactCell::value_type object at a time to the container. There is a set method which writes one value to the container (and advances the iterator).

Definition at line 182 of file CaloCompactCellContainer.h.

Constructor & Destructor Documentation

◆ compact_output_iterator() [1/2]

CaloCompactCellContainer::compact_output_iterator::compact_output_iterator ( )
inline

Default constructor.

This makes an invalid iterator.

Definition at line 301 of file CaloCompactCellContainer.h.

302{
303}

◆ compact_output_iterator() [2/2]

CaloCompactCellContainer::compact_output_iterator::compact_output_iterator ( std::vector< value_type >::iterator it)
inline

Constructor.

Parameters
itvalue_type iterator at the start of the data (after the header).

Definition at line 307 of file CaloCompactCellContainer.h.

309 : m_it (it),
310 m_count (0)
311{
312}
std::vector< value_type >::iterator m_it
The iterator in the underlying container type.
int m_count
Count; used to tell how many more times we need to shift m_word.

Member Function Documentation

◆ operator++()

CaloCompactCellContainer::compact_output_iterator & CaloCompactCellContainer::compact_output_iterator::operator++ ( )
inline

Advance the iterator.

Definition at line 335 of file CaloCompactCellContainer.h.

336{
337 const int ratio =
338 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
339 if (((++m_count)%ratio) == 0)
340 ++m_it;
341 return *this;
342}
int value_type
value type for the internal data

◆ set()

void CaloCompactCellContainer::compact_output_iterator::set ( CaloCompactCell::value_type x)
inline

Set the next value, and advance the iterator.

Parameters
xThe value to copy to the container.

Definition at line 315 of file CaloCompactCellContainer.h.

317{
318 // Constants.
319 const int mask = static_cast<CaloCompactCell::value_type>(-1);
320 const int ratio =
321 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
322 const int shift = 8*sizeof (CaloCompactCell::value_type) * (m_count%ratio);
323
324 // Mask the value into the current word.
325 *m_it = (*m_it & ~(mask<<shift)) | (x << shift);
326
327 // Advance the iterator.
328 if (((++m_count)%ratio) == 0)
329 ++m_it;
330}
#define x
virtual void shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the container.

◆ used()

int CaloCompactCellContainer::compact_output_iterator::used ( ) const
inline

Return the number of underlying value_type words used.

Definition at line 346 of file CaloCompactCellContainer.h.

347{
348 const int ratio =
349 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
350 return (m_count + ratio - 1) / ratio;
351}

Member Data Documentation

◆ m_count

int CaloCompactCellContainer::compact_output_iterator::m_count
private

Count; used to tell how many more times we need to shift m_word.

Definition at line 225 of file CaloCompactCellContainer.h.

◆ m_it

std::vector<value_type>::iterator CaloCompactCellContainer::compact_output_iterator::m_it
private

The iterator in the underlying container type.

Definition at line 222 of file CaloCompactCellContainer.h.


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