Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgPointIterator.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SgPointIterator.h
00003     Class SgPointIterator. */
00004 //----------------------------------------------------------------------------
00005 
00006 #ifndef SG_POINTITERATOR_H
00007 #define SG_POINTITERATOR_H
00008 
00009 #include "SgPoint.h"
00010 
00011 //----------------------------------------------------------------------------
00012 
00013 /** Iterate through an array of points
00014     terminated by END_POINT (defined to be zero for performance). */
00015 class SgPointIterator
00016 {
00017 public:
00018     SgPointIterator(const SgPoint* first);
00019 
00020     virtual ~SgPointIterator();
00021 
00022     /** Advance the state of the iteration to the next element. */
00023     void operator++();
00024 
00025     /** Return the value of the current element. */
00026     SgPoint operator*() const;
00027 
00028     /** Return true if iteration is valid, otherwise false. */
00029     operator bool() const;
00030 
00031 private:
00032     const SgPoint* m_point;
00033 
00034     /** Not implemented. */
00035     SgPointIterator(const SgPointIterator&);
00036 
00037     /** Not implemented. */
00038     SgPointIterator& operator=(const SgPointIterator&);
00039 };
00040 
00041 inline SgPointIterator::SgPointIterator(const SgPoint* first)
00042     : m_point(first)
00043 {
00044 }
00045 
00046 inline SgPointIterator::~SgPointIterator()
00047 {
00048 }
00049 
00050 inline void SgPointIterator::operator++()
00051 {
00052     ++m_point;
00053 }
00054 
00055 inline SgPoint SgPointIterator::operator*() const
00056 {
00057     return *m_point;
00058 }
00059 
00060 inline SgPointIterator::operator bool() const
00061 {
00062     return *m_point != SG_ENDPOINT;
00063 }
00064 
00065 //----------------------------------------------------------------------------
00066 
00067 /** Iterate through an array of points with the range defined by pointers. */
00068 class SgPointRangeIterator
00069 {
00070 public:
00071     /** Constructor.
00072         @param first Pointer to first element.
00073         @param end Pointer to last element + 1. */
00074     SgPointRangeIterator(const SgPoint* first, const SgPoint* end);
00075 
00076     virtual ~SgPointRangeIterator();
00077 
00078     /** Advance the state of the iteration to the next element. */
00079     void operator++();
00080 
00081     /** Return the value of the current element. */
00082     SgPoint operator*() const;
00083 
00084     /** Return true if iteration is valid, otherwise false. */
00085     operator bool() const;
00086 
00087 private:
00088     const SgPoint* m_point;
00089 
00090     const SgPoint* m_end;
00091 
00092     /** Not implemented. */
00093     SgPointRangeIterator(const SgPointRangeIterator&);
00094 
00095     /** Not implemented. */
00096     SgPointRangeIterator& operator=(const SgPointRangeIterator&);
00097 };
00098 
00099 inline SgPointRangeIterator::SgPointRangeIterator(const SgPoint* first,
00100                                                   const SgPoint* end)
00101     : m_point(first),
00102       m_end(end)
00103 {
00104 }
00105 
00106 inline SgPointRangeIterator::~SgPointRangeIterator()
00107 {
00108 }
00109 
00110 inline void SgPointRangeIterator::operator++()
00111 {
00112     ++m_point;
00113 }
00114 
00115 inline SgPoint SgPointRangeIterator::operator*() const
00116 {
00117     return *m_point;
00118 }
00119 
00120 inline SgPointRangeIterator::operator bool() const
00121 {
00122     return m_point != m_end;
00123 }
00124 
00125 //----------------------------------------------------------------------------
00126 
00127 #endif // SG_POINTITERATOR_H


Sun Mar 13 2011 Doxygen 1.7.1