[Liblas-commits] hg: dummy up index_filter_iterator
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Oct 7 15:27:44 EDT 2010
changeset 9f5bd70a3a6d in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=9f5bd70a3a6d
summary: dummy up index_filter_iterator
diffstat:
include/liblas/iterator.hpp | 84 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 84 insertions(+), 0 deletions(-)
diffs (101 lines):
diff -r ee84a773841d -r 9f5bd70a3a6d include/liblas/iterator.hpp
--- a/include/liblas/iterator.hpp Thu Oct 07 13:55:46 2010 -0500
+++ b/include/liblas/iterator.hpp Thu Oct 07 14:27:35 2010 -0500
@@ -44,6 +44,7 @@
#include <liblas/lasreader.hpp>
#include <liblas/laswriter.hpp>
+#include <liblas/lasindex.hpp>
#include <iterator>
#include <cassert>
@@ -213,6 +214,89 @@
liblas::Writer* m_writer;
};
+template <typename T>
+class index_filter_iterator
+{
+public:
+
+ typedef std::input_iterator_tag iterator_category;
+ typedef T value_type;
+ typedef T const* pointer;
+ typedef T const& reference;
+ typedef ptrdiff_t difference_type;
+
+ /// Initializes iterator pointing to pass-the-end.
+ index_filter_iterator()
+ : m_index(0)
+ {}
+
+ /// Initializes iterator pointing to beginning of Index's filtered points sequence.
+ /// No ownership transfer of index object occurs.
+ index_filter_iterator(liblas::Index& index)
+ : m_index(&index)
+ {
+ assert(0 != m_index);
+ getval();
+ }
+
+ /// Dereference operator.
+ /// It is implemented in terms of Index::GetNextID function.
+ reference operator*() const
+ {
+ assert(0 != m_index);
+ if (0 != m_index)
+ {
+ // return m_index->GetNextID();
+ }
+
+ throw std::runtime_error("index is null and iterator not dereferencable");
+ }
+
+ /// Pointer-to-member operator.
+ /// It is implemented in terms of Index::GetPoint function.
+ pointer operator->() const
+ {
+ return &(operator*());
+ }
+
+ /// Pre-increment operator.
+ /// Moves iterator to next record by calling Index::GetNextID.
+ index_filter_iterator& operator++()
+ {
+ assert(0 != m_index);
+ getval();
+ return (*this);
+ }
+
+ /// Post-increment operator.
+ /// Moves iterator to next record by calling Index::FindNextID.
+ index_filter_iterator operator++(int)
+ {
+ index_filter_iterator tmp(*this);
+ ++(*this);
+ return tmp;
+ }
+
+ /// Compare passed iterator to this.
+ /// Determine if both iterators apply to the same instance of liblas::Index class.
+ bool equal(index_filter_iterator const& rhs) const
+ {
+ return m_index == rhs.m_index;
+ }
+
+private:
+
+ void getval()
+ {
+ // if (0 != m_index && !(m_index->FindNextID()))
+ // {
+ // m_index = 0;
+ // }
+ }
+
+ liblas::Index* m_index;
+};
+
// Declare specializations for user's convenience
/// Public specialization of LASReader input iterator for liblas::LASPoint type.
More information about the Liblas-commits
mailing list