OGS
GeoLib::Polyline::SegmentIterator Class Referencefinal

Detailed Description

Definition at line 42 of file Polyline.h.

#include <Polyline.h>

Collaboration diagram for GeoLib::Polyline::SegmentIterator:
[legend]

Public Types

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

Public Member Functions

 SegmentIterator (Polyline const &polyline, std::size_t segment_number)
 
 SegmentIterator (SegmentIterator const &src)
 
 SegmentIterator ()=delete
 
 ~SegmentIterator ()=default
 
SegmentIteratoroperator= (SegmentIterator const &rhs)
 
std::size_t getSegmentNumber () const
 
SegmentIteratoroperator++ ()
 
LineSegment operator* () const
 
LineSegment operator* ()
 
bool operator== (SegmentIterator const &other) const
 
bool operator!= (SegmentIterator const &other) const
 
SegmentIteratoroperator+= (std::vector< GeoLib::Point >::difference_type n)
 
SegmentIterator operator+ (std::vector< GeoLib::Point >::difference_type n)
 
SegmentIteratoroperator-= (std::vector< GeoLib::Point >::difference_type n)
 
SegmentIterator operator- (std::vector< GeoLib::Point >::difference_type n)
 

Private Attributes

GeoLib::Polyline const * _polyline
 
std::vector< GeoLib::Point * >::size_type _segment_number
 

Member Typedef Documentation

◆ difference_type

Definition at line 47 of file Polyline.h.

◆ iterator_category

using GeoLib::Polyline::SegmentIterator::iterator_category = std::forward_iterator_tag

Definition at line 45 of file Polyline.h.

◆ pointer

◆ reference

◆ value_type

Constructor & Destructor Documentation

◆ SegmentIterator() [1/3]

GeoLib::Polyline::SegmentIterator::SegmentIterator ( Polyline const & polyline,
std::size_t segment_number )
explicit

Definition at line 361 of file Polyline.cpp.

363 : _polyline(&polyline),
365 static_cast<std::vector<GeoLib::Point*>::size_type>(segment_number))
366{
367}
GeoLib::Polyline const * _polyline
Definition Polyline.h:86
std::vector< GeoLib::Point * >::size_type _segment_number
Definition Polyline.h:87

◆ SegmentIterator() [2/3]

GeoLib::Polyline::SegmentIterator::SegmentIterator ( SegmentIterator const & src)

Definition at line 369 of file Polyline.cpp.

370 : _polyline(src._polyline), _segment_number(src._segment_number)
371{
372}

◆ SegmentIterator() [3/3]

GeoLib::Polyline::SegmentIterator::SegmentIterator ( )
delete

◆ ~SegmentIterator()

GeoLib::Polyline::SegmentIterator::~SegmentIterator ( )
default

Member Function Documentation

◆ getSegmentNumber()

std::size_t GeoLib::Polyline::SegmentIterator::getSegmentNumber ( ) const

◆ operator!=()

bool GeoLib::Polyline::SegmentIterator::operator!= ( SegmentIterator const & other) const

Definition at line 413 of file Polyline.cpp.

414{
415 return other._segment_number != _segment_number ||
416 other._polyline != _polyline;
417}

References _polyline, and _segment_number.

◆ operator*() [1/2]

LineSegment GeoLib::Polyline::SegmentIterator::operator* ( )

Definition at line 403 of file Polyline.cpp.

404{
406}
LineSegment getSegment(std::size_t i) const
Definition Polyline.cpp:166

◆ operator*() [2/2]

LineSegment GeoLib::Polyline::SegmentIterator::operator* ( ) const

Definition at line 398 of file Polyline.cpp.

399{
401}

◆ operator+()

Polyline::SegmentIterator GeoLib::Polyline::SegmentIterator::operator+ ( std::vector< GeoLib::Point >::difference_type n)

Definition at line 439 of file Polyline.cpp.

441{
442 SegmentIterator t(*this);
443 t += n;
444 return t;
445}

◆ operator++()

Polyline::SegmentIterator & GeoLib::Polyline::SegmentIterator::operator++ ( )

Definition at line 392 of file Polyline.cpp.

393{
395 return *this;
396}

◆ operator+=()

Polyline::SegmentIterator & GeoLib::Polyline::SegmentIterator::operator+= ( std::vector< GeoLib::Point >::difference_type n)

Definition at line 419 of file Polyline.cpp.

421{
422 if (n < 0)
423 {
425 static_cast<std::vector<GeoLib::Point>::size_type>(-n);
426 }
427 else
428 {
430 static_cast<std::vector<GeoLib::Point>::size_type>(n);
431 }
433 {
434 OGS_FATAL("");
435 }
436 return *this;
437}
#define OGS_FATAL(...)
Definition Error.h:26
std::size_t getNumberOfSegments() const
Definition Polyline.cpp:114

References OGS_FATAL.

◆ operator-()

Polyline::SegmentIterator GeoLib::Polyline::SegmentIterator::operator- ( std::vector< GeoLib::Point >::difference_type n)

Definition at line 467 of file Polyline.cpp.

469{
470 Polyline::SegmentIterator t(*this);
471 t -= n;
472 return t;
473}

◆ operator-=()

Polyline::SegmentIterator & GeoLib::Polyline::SegmentIterator::operator-= ( std::vector< GeoLib::Point >::difference_type n)

Definition at line 447 of file Polyline.cpp.

449{
450 if (n >= 0)
451 {
453 static_cast<std::vector<GeoLib::Point>::size_type>(n);
454 }
455 else
456 {
458 static_cast<std::vector<GeoLib::Point>::size_type>(-n);
459 }
461 {
462 OGS_FATAL("");
463 }
464 return *this;
465}

References OGS_FATAL.

◆ operator=()

Polyline::SegmentIterator & GeoLib::Polyline::SegmentIterator::operator= ( SegmentIterator const & rhs)

Definition at line 374 of file Polyline.cpp.

376{
377 if (&rhs == this)
378 {
379 return *this;
380 }
381
382 _polyline = rhs._polyline;
383 _segment_number = rhs._segment_number;
384 return *this;
385}

References _polyline, and _segment_number.

◆ operator==()

bool GeoLib::Polyline::SegmentIterator::operator== ( SegmentIterator const & other) const

Definition at line 408 of file Polyline.cpp.

409{
410 return !(*this != other);
411}

Member Data Documentation

◆ _polyline

GeoLib::Polyline const* GeoLib::Polyline::SegmentIterator::_polyline
private

Definition at line 86 of file Polyline.h.

Referenced by operator!=(), and operator=().

◆ _segment_number

std::vector<GeoLib::Point*>::size_type GeoLib::Polyline::SegmentIterator::_segment_number
private

Definition at line 87 of file Polyline.h.

Referenced by operator!=(), and operator=().


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