[Liblas-commits] hg-main-tree: add getIteratorSupport method to Stage:: to make i...

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Mar 25 12:30:01 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/7373e867d8a5
changeset: 446:7373e867d8a5
user:      Howard Butler <hobu.inc at gmail.com>
date:      Fri Mar 25 11:29:51 2011 -0500
description:
add getIteratorSupport method to Stage:: to make it easier to add new iterator types

diffstat:

 include/libpc/Chipper.hpp                  |   8 ++++++++
 include/libpc/Iterator.hpp                 |   2 ++
 include/libpc/Stage.hpp                    |   1 +
 include/libpc/drivers/faux/Reader.hpp      |  11 +++++++++--
 include/libpc/drivers/las/Reader.hpp       |   8 ++++++++
 include/libpc/drivers/liblas/Reader.hpp    |   8 ++++++++
 include/libpc/drivers/mrsid/Reader.hpp     |  11 +++++++++++
 include/libpc/drivers/oci/Reader.hpp       |  10 ++++++++++
 include/libpc/filters/CacheFilter.hpp      |   9 +++++++++
 include/libpc/filters/ColorFilter.hpp      |   8 ++++++++
 include/libpc/filters/CropFilter.hpp       |   8 ++++++++
 include/libpc/filters/DecimationFilter.hpp |   8 ++++++++
 include/libpc/filters/MosaicFilter.hpp     |   7 +++++++
 include/libpc/types.hpp                    |   7 +++++++
 test/unit/FauxReaderTest.cpp               |  22 ++++++++++++++++++++++
 test/unit/LiblasReaderTest.cpp             |  12 ++++++++++++
 16 files changed, 138 insertions(+), 2 deletions(-)

diffs (truncated from 310 to 300 lines):

diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/Chipper.hpp
--- a/include/libpc/Chipper.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/Chipper.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -156,6 +156,14 @@
 
     const std::string& getName() const ;
 
+    inline boost::uint8_t getIteratorSupport () const
+    {   
+        // FIXME: make this represent what this reader actually supports!
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Block; 
+        return mask;
+    }
+
     bool supportsSequentialIterator() const { return true; }
     bool supportsRandomIterator() const { return false; }
     libpc::SequentialIterator* createSequentialIterator() const;
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/Iterator.hpp
--- a/include/libpc/Iterator.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/Iterator.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -42,6 +42,8 @@
 class Stage;
 class PointBuffer;
 
+
+
 class LIBPC_DLL Iterator
 {
 public:
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/Stage.hpp
--- a/include/libpc/Stage.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/Stage.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -66,6 +66,7 @@
     const Header& getHeader() const;
     Header& getHeader();
 
+    virtual boost::uint8_t getIteratorSupport () const { return 0; }
     virtual bool supportsSequentialIterator() const { return false; }
     virtual bool supportsRandomIterator() const { return false; }
     virtual SequentialIterator* createSequentialIterator() const { return NULL; }
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/drivers/faux/Reader.hpp
--- a/include/libpc/drivers/faux/Reader.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/drivers/faux/Reader.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -41,7 +41,6 @@
 #include <libpc/Bounds.hpp>
 #include <libpc/Dimension.hpp>
 
-
 namespace libpc
 {
     class PointBuffer;
@@ -81,7 +80,15 @@
     const std::string& getName() const;
 
     Mode getMode() const;
-
+    
+    boost::uint8_t getIteratorSupport () 
+    {   
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Sequential;  
+        mask |= StageIterator_Random; 
+        return mask;
+    }
+    
     bool supportsSequentialIterator() const { return true; }
     bool supportsRandomIterator() const { return true; }
     libpc::SequentialIterator* createSequentialIterator() const;
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/drivers/las/Reader.hpp
--- a/include/libpc/drivers/las/Reader.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/drivers/las/Reader.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -60,6 +60,14 @@
 
     const LasHeader& getLasHeader() const;
 
+    boost::uint8_t getIteratorSupport () const
+    {   
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Sequential;  
+        mask |= StageIterator_Random; 
+        return mask;
+    }
+
     bool supportsSequentialIterator() const { return true; }
     bool supportsRandomIterator() const { return true; }
     libpc::SequentialIterator* createSequentialIterator() const;
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/drivers/liblas/Reader.hpp
--- a/include/libpc/drivers/liblas/Reader.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/drivers/liblas/Reader.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -72,6 +72,14 @@
     bool hasColorData() const;
     bool hasWaveData() const;
 
+    boost::uint8_t getIteratorSupport () const
+    {   
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Sequential;  
+        mask |= StageIterator_Random; 
+        return mask;
+    }
+
     bool supportsSequentialIterator() const { return true; }
     bool supportsRandomIterator() const { return true; }
     libpc::SequentialIterator* createSequentialIterator() const;
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/drivers/mrsid/Reader.hpp
--- a/include/libpc/drivers/mrsid/Reader.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/drivers/mrsid/Reader.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -60,6 +60,17 @@
 
     void seekToPoint(boost::uint64_t pointNum);
     Iterator* createIterator(const Bounds<double>& bounds);
+
+    boost::uint8_t getIteratorSupport () const
+    {   
+        // FIXME: make this represent what this reader actually supports!
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Sequential;  
+        mask |= StageIterator_Random; 
+        mask |= StageIterator_Block; 
+        return mask;
+    }
+    
 protected:
     boost::uint32_t readBuffer(PointBuffer&);
 
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/drivers/oci/Reader.hpp
--- a/include/libpc/drivers/oci/Reader.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/drivers/oci/Reader.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -60,6 +60,16 @@
  
     void seekToPoint(boost::uint64_t pointNum);
 
+    boost::uint8_t getIteratorSupport () const
+    {   
+        // FIXME: make this represent what this reader actually supports!
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Sequential;  
+        mask |= StageIterator_Random; 
+        mask |= StageIterator_Block; 
+        return mask;
+    }
+
 private:
 
     Reader& operator=(const Reader&); // not implemented
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/filters/CacheFilter.hpp
--- a/include/libpc/filters/CacheFilter.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/filters/CacheFilter.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -86,6 +86,15 @@
                        boost::uint64_t& numCacheInsertMisses,
                        boost::uint64_t& numCacheInsertHits) const;
 
+    boost::uint8_t getIteratorSupport () const
+    {   
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Sequential;  
+        mask |= StageIterator_Random; 
+        return mask;
+    }
+    
+
     bool supportsSequentialIterator() const { return true; }
     bool supportsRandomIterator() const { return true; }
     libpc::SequentialIterator* createSequentialIterator() const;
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/filters/ColorFilter.hpp
--- a/include/libpc/filters/ColorFilter.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/filters/ColorFilter.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -62,6 +62,14 @@
 
     void getColor(float value, boost::uint8_t& red, boost::uint8_t& green, boost::uint8_t& blue) const;
 
+    inline boost::uint8_t getIteratorSupport () const
+    {   
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Sequential;  
+        return mask;
+    }
+    
+
     bool supportsSequentialIterator() const { return true; }
     bool supportsRandomIterator() const { return false; }
     libpc::SequentialIterator* createSequentialIterator() const;
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/filters/CropFilter.hpp
--- a/include/libpc/filters/CropFilter.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/filters/CropFilter.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -59,6 +59,14 @@
 
     const std::string& getName() const;
 
+    inline boost::uint8_t getIteratorSupport () 
+    {   
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Sequential;  
+        return mask;
+    }
+    
+
     bool supportsSequentialIterator() const { return true; }
     bool supportsRandomIterator() const { return false; }
     libpc::SequentialIterator* createSequentialIterator() const;
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/filters/DecimationFilter.hpp
--- a/include/libpc/filters/DecimationFilter.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/filters/DecimationFilter.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -57,6 +57,14 @@
 
     const std::string& getName() const;
 
+    inline boost::uint8_t getIteratorSupport () const
+    {   
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Sequential;  
+        return mask;
+    }
+    
+
     bool supportsSequentialIterator() const { return true; }
     bool supportsRandomIterator() const { return false; }
     libpc::SequentialIterator* createSequentialIterator() const;
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/filters/MosaicFilter.hpp
--- a/include/libpc/filters/MosaicFilter.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/filters/MosaicFilter.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -59,6 +59,13 @@
 
     const std::vector<const Stage*>& getPrevStages() const;
 
+    inline boost::uint8_t getIteratorSupport () const
+    {   
+        boost::uint8_t mask(0); 
+        mask |= StageIterator_Sequential;  
+        return mask;
+    }
+    
     bool supportsSequentialIterator() const { return true; }
     bool supportsRandomIterator() const { return false; }  // BUG: could be true
     libpc::SequentialIterator* createSequentialIterator() const;
diff -r f3bcb01c42a5 -r 7373e867d8a5 include/libpc/types.hpp
--- a/include/libpc/types.hpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/include/libpc/types.hpp	Fri Mar 25 11:29:51 2011 -0500
@@ -46,6 +46,13 @@
     PointCount_Unknown      // the stage has an unknown count, and getNumPoints will return 0
 };
 
+enum StageIteratorType
+{
+    StageIterator_Sequential = (1u << 0),
+    StageIterator_Random = (1u << 1),
+    StageIterator_Block = (1u << 2),
+    StageIterator_Unknown = (1u << 8)
+};
 
 } // namespace
 
diff -r f3bcb01c42a5 -r 7373e867d8a5 test/unit/FauxReaderTest.cpp
--- a/test/unit/FauxReaderTest.cpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/test/unit/FauxReaderTest.cpp	Fri Mar 25 11:29:51 2011 -0500
@@ -41,6 +41,8 @@
 #include <libpc/drivers/faux/Reader.hpp>
 #include <libpc/drivers/faux/Iterator.hpp>
 
+#include <iostream>
+
 using namespace libpc;
 
 BOOST_AUTO_TEST_SUITE(FauxReaderTest)
@@ -348,4 +350,24 @@
     return;
 }
 
+
+
+BOOST_AUTO_TEST_CASE(test_iterator_checks)
+{
+    Bounds<double> bounds(1.0, 2.0, 3.0, 101.0, 152.0, 203.0);
+    libpc::drivers::faux::Reader reader(bounds, 750, libpc::drivers::faux::Reader::Ramp);
+
+    const Schema& schema = reader.getHeader().getSchema();
+    SchemaLayout layout(schema);
+
+    PointBuffer data(layout, 750);
+    
+    boost::uint8_t iterators = reader.getIteratorSupport();
+    
+    BOOST_CHECK_EQUAL(iterators & StageIterator_Sequential != 0, true);
+    BOOST_CHECK_EQUAL(iterators & StageIterator_Random != 0, true);
+
+    return;
+}
+
 BOOST_AUTO_TEST_SUITE_END()
diff -r f3bcb01c42a5 -r 7373e867d8a5 test/unit/LiblasReaderTest.cpp
--- a/test/unit/LiblasReaderTest.cpp	Fri Mar 25 08:59:12 2011 -0700
+++ b/test/unit/LiblasReaderTest.cpp	Fri Mar 25 11:29:51 2011 -0500
@@ -431,4 +431,16 @@
     return;
 }
 
+BOOST_AUTO_TEST_CASE(test_iterator_checks)
+{
+    LiblasReader reader(TestConfig::g_data_path + "1.2-with-color.las");


More information about the Liblas-commits mailing list