MercuryTimeStepIterator< NDIMS > Class Template Reference

#include <MercuryData.h>

Public Member Functions

bool operator!= (MercuryTimeStepIterator< NDIMS > other) const
 Not-equals operator, as defined for ForwardIterators. More...
 
MercuryTimeStep< NDIMS > & operator* ()
 Dereference operator, as defined for ForwardIterators. More...
 
const MercuryTimeStep< NDIMS > & operator* () const
 Const dereference operator, as defined for constant ForwardIterators. More...
 
void operator++ ()
 Pre-increment operator, as defined for ForwardIterators This method populates the time step, including all the particles in there. It also resizes the backing storage mechanism. More...
 

Private Member Functions

 MercuryTimeStepIterator ()
 
 MercuryTimeStepIterator (MercuryDataFile *pData)
 

Private Attributes

MercuryTimeStep< NDIMS > lastReadTimeStep_
 
bool isEOFTimeStep_
 
MercuryDataFiledataFile_
 

Friends

class MercuryDataFile
 

Detailed Description

template<std::size_t NDIMS>
class MercuryTimeStepIterator< NDIMS >

Lazy time step iterator Only loads the current time step and discards this as soon as it is incremented. This is a ForwardIterator as described by the C++11 standard This iterator invalidates any references to its dereferenced value when incremented.

Author
dducks

Constructor & Destructor Documentation

◆ MercuryTimeStepIterator() [1/2]

template<std::size_t NDIMS>
MercuryTimeStepIterator< NDIMS >::MercuryTimeStepIterator ( )
inlineprivate

EOF TimeStepIterator constructor, as used by MercuryDataFile::end()

381  : isEOFTimeStep_(true), dataFile_(nullptr)
382  {
383  }
MercuryDataFile * dataFile_
Definition: MercuryData.h:407
bool isEOFTimeStep_
Definition: MercuryData.h:403

◆ MercuryTimeStepIterator() [2/2]

template<std::size_t NDIMS>
MercuryTimeStepIterator< NDIMS >::MercuryTimeStepIterator ( MercuryDataFile pData)
inlineprivate

Beginning-of-file TimeStepIterator constructor, as used by MercuryDataFile::begin()

Parameters
[in]pDataPointer to the MercuryDataFile, which is required for the backing std::ifstream
390  : lastReadTimeStep_(0,pData), isEOFTimeStep_(false), dataFile_(pData)
391  {
392  ++(*this);
393  lastReadTimeStep_.ID_ = 0;
394  }
MercuryTimeStep< NDIMS > lastReadTimeStep_
Definition: MercuryData.h:399

References MercuryTimeStepIterator< NDIMS >::lastReadTimeStep_.

Member Function Documentation

◆ operator!=()

template<std::size_t NDIMS>
bool MercuryTimeStepIterator< NDIMS >::operator!= ( MercuryTimeStepIterator< NDIMS >  other) const
inline

Not-equals operator, as defined for ForwardIterators.

349  {
350  return (isEOFTimeStep_ != other.isEOFTimeStep_);
351  }

References MercuryTimeStepIterator< NDIMS >::isEOFTimeStep_.

◆ operator*() [1/2]

template<std::size_t NDIMS>
MercuryTimeStep<NDIMS>& MercuryTimeStepIterator< NDIMS >::operator* ( )
inline

Dereference operator, as defined for ForwardIterators.

357  {
358  return lastReadTimeStep_;
359  }

References MercuryTimeStepIterator< NDIMS >::lastReadTimeStep_.

◆ operator*() [2/2]

template<std::size_t NDIMS>
const MercuryTimeStep<NDIMS>& MercuryTimeStepIterator< NDIMS >::operator* ( ) const
inline

Const dereference operator, as defined for constant ForwardIterators.

365  {
366  return lastReadTimeStep_;
367  }

References MercuryTimeStepIterator< NDIMS >::lastReadTimeStep_.

◆ operator++()

template<std::size_t NDIMS>
void MercuryTimeStepIterator< NDIMS >::operator++

Pre-increment operator, as defined for ForwardIterators This method populates the time step, including all the particles in there. It also resizes the backing storage mechanism.

553 {
554  lastReadTimeStep_.ID_++;
555 
557  std::getline(dataFile_->file_, line);
558 
559  std::istringstream lineStream(line);
560 
561  lineStream >> lastReadTimeStep_;
562 
563  //I hope we didn't went beyond end of file...
564  if (lineStream.eof())
565  {
566 // logger(WARN, "The time step header detected an EOF.. Usually this"
567 // " means that the format was not what it appeared to be."
568 // "\nproceed with caution!");
569  }
570  //Resize the backing storage container to make sure we can actually
571  //fit all the particles in there.
572  lastReadTimeStep_.storage_.resize(lastReadTimeStep_.numParticles_);
573  //Well, now that we're set up, read all the particles
575  {
576  //line by line, because no data format can be trusted.
577  std::getline(dataFile_->file_, line);
578  lineStream.clear();
579  lineStream.str(line);
580 
581  lineStream >> part;
582  }
583 
584  if (dataFile_->file_.eof())
585  isEOFTimeStep_ = true;
586 }
std::ifstream file_
Definition: MercuryData.h:543
line
Definition: calibrate.py:103
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
Definition: MercuryData.h:21

References MercuryTimeStepIterator< NDIMS >::dataFile_, MercuryDataFile::file_, MercuryTimeStepIterator< NDIMS >::isEOFTimeStep_, MercuryTimeStepIterator< NDIMS >::lastReadTimeStep_, calibrate::line, and oomph::Global_string_for_annotation::string().

Friends And Related Function Documentation

◆ MercuryDataFile

template<std::size_t NDIMS>
friend class MercuryDataFile
friend

Member Data Documentation

◆ dataFile_

template<std::size_t NDIMS>
MercuryDataFile* MercuryTimeStepIterator< NDIMS >::dataFile_
private

Pointer to the MercuryDataFile and the backing std::ifstream, which is required for reading

Referenced by MercuryTimeStepIterator< NDIMS >::operator++().

◆ isEOFTimeStep_

template<std::size_t NDIMS>
bool MercuryTimeStepIterator< NDIMS >::isEOFTimeStep_
private

◆ lastReadTimeStep_

template<std::size_t NDIMS>
MercuryTimeStep<NDIMS> MercuryTimeStepIterator< NDIMS >::lastReadTimeStep_
private

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