LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Protected Member Functions | Private Types | Private Attributes | Friends | List of all members
lsst::afw::math::SpatialCellCandidateIterator Class Reference

An iterator that only returns usable members of the SpatialCell. More...

#include <SpatialCell.h>

Public Member Functions

void operator++ ()
 
size_t operator- (SpatialCellCandidateIterator const &rhs) const
 
boost::shared_ptr
< SpatialCellCandidate const > 
operator* () const
 
boost::shared_ptr
< SpatialCellCandidate
operator* ()
 Return the CellCandidate::Ptr. More...
 
bool operator== (SpatialCellCandidateIterator const &rhs) const
 Are two SpatialCellCandidateIterators equal? More...
 
bool operator!= (SpatialCellCandidateIterator const &rhs) const
 Are two SpatialCellCandidateIterators unequal? More...
 

Protected Member Functions

 SpatialCellCandidateIterator (CandidateList::iterator iterator, CandidateList::iterator end, bool ignoreBad)
 ctor; designed to be used to pass begin to SpatialCellCandidateIterator More...
 
 SpatialCellCandidateIterator (CandidateList::iterator iterator, CandidateList::iterator end, bool ignoreBad, bool)
 ctor; designed to be used to pass end to SpatialCellCandidateIterator More...
 

Private Types

typedef std::vector
< boost::shared_ptr
< SpatialCellCandidate > > 
CandidateList
 

Private Attributes

CandidateList::iterator _iterator
 
CandidateList::iterator _end
 
bool _ignoreBad
 

Friends

class SpatialCell
 

Detailed Description

An iterator that only returns usable members of the SpatialCell.

Definition at line 247 of file SpatialCell.h.

Member Typedef Documentation

typedef std::vector<boost::shared_ptr< SpatialCellCandidate > > lsst::afw::math::SpatialCellCandidateIterator::CandidateList
private

Definition at line 249 of file SpatialCell.h.

Constructor & Destructor Documentation

lsst::afw::math::SpatialCellCandidateIterator::SpatialCellCandidateIterator ( CandidateList::iterator  iterator,
CandidateList::iterator  end,
bool  ignoreBad 
)
protected

ctor; designed to be used to pass begin to SpatialCellCandidateIterator

Parameters
iteratorWhere this iterator should start
endOne-past-the-end of iterator's range
ignoreBadShould we pass over bad Candidates?

Definition at line 324 of file SpatialCell.cc.

329  : _iterator(iterator), _end(end), _ignoreBad(ignoreBad) {
330  for (; _iterator != _end; ++_iterator) {
331  (*_iterator)->instantiate();
332 
333  if (!(_ignoreBad && (*_iterator)->isBad())) { // found a good candidate, or don't care
334  return;
335  }
336  }
337 }
lsst::afw::math::SpatialCellCandidateIterator::SpatialCellCandidateIterator ( CandidateList::iterator  iterator,
CandidateList::iterator  end,
bool  ignoreBad,
bool   
)
protected

ctor; designed to be used to pass end to SpatialCellCandidateIterator

Parameters
iteratorstart of of iterator's range; not used
endWhere this iterator should start
ignoreBadShould we pass over bad Candidates?

Definition at line 340 of file SpatialCell.cc.

346  : _iterator(end), _end(end), _ignoreBad(ignoreBad) {
347  if (ignoreBad) {
348  // We could decrement end if there are bad Candidates at the end of the list, but it's probably
349  // not worth the trouble
350  }
351 }

Member Function Documentation

bool lsst::afw::math::SpatialCellCandidateIterator::operator!= ( SpatialCellCandidateIterator const &  rhs) const
inline

Are two SpatialCellCandidateIterators unequal?

Definition at line 264 of file SpatialCell.h.

264  {
265  return _iterator != rhs._iterator;
266  }
SpatialCellCandidate::ConstPtr lsst::afw::math::SpatialCellCandidateIterator::operator* ( ) const

Dereference the iterator to return the Candidate (if there is one)

Exceptions
lsst::pex::exceptions::NotFoundErrorif no candidate is available

Definition at line 389 of file SpatialCell.cc.

389  {
390  if (_iterator == _end) {
391  throw LSST_EXCEPT(lsst::pex::exceptions::NotFoundError, "Iterator points to end");
392  }
393 
394  return *_iterator;
395 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
SpatialCellCandidate::Ptr lsst::afw::math::SpatialCellCandidateIterator::operator* ( )

Return the CellCandidate::Ptr.

Definition at line 398 of file SpatialCell.cc.

398  {
399  if (_iterator == _end) {
400  throw LSST_EXCEPT(lsst::pex::exceptions::NotFoundError, "Iterator points to end");
401  }
402 
403  return *_iterator;
404 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void lsst::afw::math::SpatialCellCandidateIterator::operator++ ( )

Advance the iterator, maybe skipping over candidates labelled BAD

Definition at line 356 of file SpatialCell.cc.

356  {
357  if (_iterator != _end) {
358  ++_iterator;
359  }
360 
361  for (; _iterator != _end; ++_iterator) {
362  (*_iterator)->instantiate();
363 
364  if (!(_ignoreBad && (*_iterator)->isBad())) { // found a good candidate, or don't care
365  return;
366  }
367  }
368 }
size_t lsst::afw::math::SpatialCellCandidateIterator::operator- ( SpatialCellCandidateIterator const &  rhs) const

Return the number of candidate between this and rhs

Definition at line 373 of file SpatialCell.cc.

373  {
374  size_t n = 0;
375  for (SpatialCellCandidateIterator ptr = rhs; ptr != *this; ++ptr) {
376  if (!(_ignoreBad && (*ptr)->isBad())) { // found a good candidate, or don't care
377  ++n;
378  }
379  }
380 
381  return n;
382 }
SpatialCellCandidateIterator(CandidateList::iterator iterator, CandidateList::iterator end, bool ignoreBad)
ctor; designed to be used to pass begin to SpatialCellCandidateIterator
Definition: SpatialCell.cc:324
bool lsst::afw::math::SpatialCellCandidateIterator::operator== ( SpatialCellCandidateIterator const &  rhs) const
inline

Are two SpatialCellCandidateIterators equal?

Definition at line 260 of file SpatialCell.h.

260  {
261  return _iterator == rhs._iterator;
262  }

Friends And Related Function Documentation

friend class SpatialCell
friend

Definition at line 248 of file SpatialCell.h.

Member Data Documentation

CandidateList::iterator lsst::afw::math::SpatialCellCandidateIterator::_end
private

Definition at line 274 of file SpatialCell.h.

bool lsst::afw::math::SpatialCellCandidateIterator::_ignoreBad
private

Definition at line 275 of file SpatialCell.h.

CandidateList::iterator lsst::afw::math::SpatialCellCandidateIterator::_iterator
private

Definition at line 273 of file SpatialCell.h.


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