[Liblas-commits] hg: 3 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Jul 26 15:13:31 EDT 2010


changeset 954b85863f39 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=954b85863f39
summary: remove dead code

changeset fb2b1b3a34ff in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=fb2b1b3a34ff
summary: add polymorphic primitives to forward declarations

changeset d28899d2cbb5 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=d28899d2cbb5
summary: remove more header copying from the reader implementation, ReaderI must now return boost::shared_ptr<liblas::Header> objects

diffstat:

 include/liblas/detail/fwd.hpp           |   4 ++++
 include/liblas/detail/reader/reader.hpp |   4 ++--
 include/liblas/lasreader.hpp            |   2 +-
 include/liblas/liblas.hpp               |   7 ++++++-
 src/detail/reader/reader.cpp            |  22 +++++++++++-----------
 src/lasreader.cpp                       |  16 ++++++++--------
 test/unit/lasreader_iterator_test.cpp   |   3 ---
 7 files changed, 32 insertions(+), 26 deletions(-)

diffs (206 lines):

diff -r 19e55b8af7d2 -r d28899d2cbb5 include/liblas/detail/fwd.hpp
--- a/include/liblas/detail/fwd.hpp	Mon Jul 26 11:58:44 2010 -0500
+++ b/include/liblas/detail/fwd.hpp	Mon Jul 26 14:13:20 2010 -0500
@@ -55,6 +55,10 @@
 class Classification;
 class VariableRecord;
 class Bounds;
+class TransformI;
+class FilterI;
+class ReaderI;
+class WriterI;
 
 namespace detail {
 
diff -r 19e55b8af7d2 -r d28899d2cbb5 include/liblas/detail/reader/reader.hpp
--- a/include/liblas/detail/reader/reader.hpp	Mon Jul 26 11:58:44 2010 -0500
+++ b/include/liblas/detail/reader/reader.hpp	Mon Jul 26 14:13:20 2010 -0500
@@ -63,7 +63,7 @@
     ReaderImpl(std::istream& ifs);
     ~ReaderImpl();
 
-    liblas::Header const& ReadHeader();
+    HeaderPtr ReadHeader();
     liblas::Point const& ReadNextPoint(const liblas::Header& header);
     liblas::Point const& ReadPointAt(std::size_t n, const liblas::Header& header);
     void Seek(std::size_t n, const liblas::Header& header);
@@ -102,7 +102,7 @@
     CachedReaderImpl(std::istream& ifs, std::size_t cache_size);
     // ~CachedReaderImpl();
 
-    liblas::Header const& ReadHeader();
+    HeaderPtr ReadHeader();
     liblas::Point const& ReadNextPoint(const liblas::Header& header);
     liblas::Point const& ReadPointAt(std::size_t n, const liblas::Header& header);
     // void SetOutputSRS(const SpatialReference& srs, const liblas::Header& header);
diff -r 19e55b8af7d2 -r d28899d2cbb5 include/liblas/lasreader.hpp
--- a/include/liblas/lasreader.hpp	Mon Jul 26 11:58:44 2010 -0500
+++ b/include/liblas/lasreader.hpp	Mon Jul 26 14:13:20 2010 -0500
@@ -172,7 +172,7 @@
 
     const std::auto_ptr<ReaderI> m_pimpl;
 
-    Header* m_header;
+    HeaderPtr m_header;
     Point* m_point;
     Point* m_empty_point;
     
diff -r 19e55b8af7d2 -r d28899d2cbb5 include/liblas/liblas.hpp
--- a/include/liblas/liblas.hpp	Mon Jul 26 11:58:44 2010 -0500
+++ b/include/liblas/liblas.hpp	Mon Jul 26 14:13:20 2010 -0500
@@ -47,9 +47,14 @@
 
 #include <liblas/cstdint.hpp>
 #include <liblas/detail/fwd.hpp>
+
 #include <fstream>
 #include <string>
 
+#include <boost/shared_ptr.hpp>
+
+typedef boost::shared_ptr< liblas::Header > HeaderPtr;
+
 /// Namespace grouping all elements of libLAS public interface.
 /// \note
 /// User's may notice there is namespace \em detail nested
@@ -154,7 +159,7 @@
 {
 public:
 
-    virtual Header const& ReadHeader() = 0;
+    virtual HeaderPtr ReadHeader() = 0;
     virtual Point const& ReadNextPoint(const Header& header) = 0;
     virtual Point const& ReadPointAt(std::size_t n, const Header& header) = 0;
     virtual void Seek(std::size_t n, const Header& header) = 0;
diff -r 19e55b8af7d2 -r d28899d2cbb5 src/detail/reader/reader.cpp
--- a/src/detail/reader/reader.cpp	Mon Jul 26 11:58:44 2010 -0500
+++ b/src/detail/reader/reader.cpp	Mon Jul 26 14:13:20 2010 -0500
@@ -90,14 +90,14 @@
     } 
 }
 
-liblas::Header const& ReaderImpl::ReadHeader()
+HeaderPtr ReaderImpl::ReadHeader()
 {
     m_header_reader->read();
-    const liblas::Header& header = m_header_reader->GetHeader();
+    HeaderPtr h = HeaderPtr( new Header(m_header_reader->GetHeader()));
     
-    Reset(header);
+    Reset(*(h.get()));
     
-    return header;
+    return h;
 }
 
 liblas::Point const& ReaderImpl::ReadNextPoint(const liblas::Header& header)
@@ -171,28 +171,28 @@
 }
 
 
-liblas::Header const& CachedReaderImpl::ReadHeader()
+HeaderPtr CachedReaderImpl::ReadHeader()
 {
-    const liblas::Header& header = ReaderImpl::ReadHeader();
+    HeaderPtr hptr = ReaderImpl::ReadHeader();
     
     // If we were given no cache size, try to cache the whole thing
     if (m_cache_size == 0) {
-        m_cache_size = header.GetPointRecordsCount();
+        m_cache_size = hptr->GetPointRecordsCount();
     }
 
-    if (m_cache_size > header.GetPointRecordsCount()) {
-        m_cache_size = header.GetPointRecordsCount();
+    if (m_cache_size > hptr->GetPointRecordsCount()) {
+        m_cache_size = hptr->GetPointRecordsCount();
     }
     m_cache.resize(m_cache_size);
     
     // Mark all positions as uncached and build up the mask
     // to the size of the number of points in the file
-    for (uint32_t i = 0; i < header.GetPointRecordsCount(); ++i) {
+    for (uint32_t i = 0; i < hptr->GetPointRecordsCount(); ++i) {
         m_mask.push_back(0);
     }
 
     
-    return header;
+    return hptr;
 }
 
 void CachedReaderImpl::CacheData(liblas::uint32_t position, const liblas::Header& header) 
diff -r 19e55b8af7d2 -r d28899d2cbb5 src/lasreader.cpp
--- a/src/lasreader.cpp	Mon Jul 26 11:58:44 2010 -0500
+++ b/src/lasreader.cpp	Mon Jul 26 14:13:20 2010 -0500
@@ -58,7 +58,7 @@
 
 Reader::Reader(std::istream& ifs) :
     m_pimpl(new detail::CachedReaderImpl(ifs,3)),
-    m_header(0),
+    m_header(HeaderPtr()),
     m_point(0),
     m_empty_point(new Point()),
     bCustomHeader(false),
@@ -71,7 +71,7 @@
 
 Reader::Reader(ReaderI* reader) :
     m_pimpl(reader),
-    m_header(0),
+    m_header(HeaderPtr()),
     m_point(0),
     m_empty_point(new Point()),
     bCustomHeader(false),
@@ -84,7 +84,7 @@
 
 Reader::Reader(std::istream& ifs, Header& header) :
     m_pimpl(new detail::CachedReaderImpl(ifs,3)),
-    m_header(new Header()),    
+    m_header(HeaderPtr( )),    
     m_point(0),
     m_empty_point(new Point()),
     bCustomHeader(true),
@@ -94,7 +94,7 @@
 {
     // if we have a custom header, create a slot for it and then copy 
     // the header we were given
-    *m_header = header;
+    m_header = HeaderPtr(new Header(header));
     Init();
 }
 
@@ -104,9 +104,9 @@
     // std::auto_ptr with incomplete type (Reader).
     delete m_empty_point;
     
-    if (m_header != 0) {
-        delete m_header;
-    }
+    // if (m_header != 0) {
+    //     delete m_header;
+    // }
 }
 
 Header const& Reader::GetHeader() const
@@ -251,7 +251,7 @@
         custom_header = *m_header;
     }
 
-    m_header = new Header(m_pimpl->ReadHeader());
+    m_header = HeaderPtr(m_pimpl->ReadHeader());
 
         // throw std::runtime_error("public header block reading failure");
 
diff -r 19e55b8af7d2 -r d28899d2cbb5 test/unit/lasreader_iterator_test.cpp
--- a/test/unit/lasreader_iterator_test.cpp	Mon Jul 26 11:58:44 2010 -0500
+++ b/test/unit/lasreader_iterator_test.cpp	Mon Jul 26 14:13:20 2010 -0500
@@ -383,9 +383,6 @@
 
         Header const& h = reader_.GetHeader();
         bbox_t lasbbox = h.GetExtent();
-        // bbox_t lasbbox(point_t(h.GetMinX(), h.GetMinY(), h.GetMinZ()),
-        //                point_t(h.GetMaxX(), h.GetMaxY(), h.GetMaxZ()));
-
 
         // I don't know why this is failing -- hobu
 


More information about the Liblas-commits mailing list