[Liblas-commits] hg: back ReadNextPoint by a shared_ptr instead of
a reference
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Jul 26 22:37:55 EDT 2010
changeset b039dfdada40 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=b039dfdada40
summary: back ReadNextPoint by a shared_ptr instead of a reference
diffstat:
include/liblas/detail/reader/reader.hpp | 8 ++++----
include/liblas/liblas.hpp | 2 +-
src/detail/reader/reader.cpp | 18 +++++++++---------
src/lasreader.cpp | 2 +-
4 files changed, 15 insertions(+), 15 deletions(-)
diffs (127 lines):
diff -r be85dc4a99c3 -r b039dfdada40 include/liblas/detail/reader/reader.hpp
--- a/include/liblas/detail/reader/reader.hpp Mon Jul 26 20:46:02 2010 -0500
+++ b/include/liblas/detail/reader/reader.hpp Mon Jul 26 21:37:43 2010 -0500
@@ -64,7 +64,7 @@
~ReaderImpl();
HeaderPtr ReadHeader();
- liblas::Point const& ReadNextPoint(HeaderPtr header);
+ PointPtr ReadNextPoint(HeaderPtr header);
liblas::Point const& ReadPointAt(std::size_t n, HeaderPtr header);
void Seek(std::size_t n, HeaderPtr header);
@@ -103,7 +103,7 @@
// ~CachedReaderImpl();
HeaderPtr ReadHeader();
- liblas::Point const& ReadNextPoint(HeaderPtr header);
+ PointPtr ReadNextPoint(HeaderPtr header);
liblas::Point const& ReadPointAt(std::size_t n, HeaderPtr header);
// void SetOutputSRS(const SpatialReference& srs, const liblas::Header& header);
@@ -117,7 +117,7 @@
// Blocked copying operations, declared but not defined.
CachedReaderImpl(CachedReaderImpl const& other);
CachedReaderImpl& operator=(CachedReaderImpl const& rhs);
- liblas::Point const& ReadCachedPoint(liblas::uint32_t position, HeaderPtr header);
+ PointPtr ReadCachedPoint(liblas::uint32_t position, HeaderPtr header);
void CacheData(liblas::uint32_t position, HeaderPtr header);
@@ -126,7 +126,7 @@
std::vector<uint8_t>::size_type m_cache_start_position;
std::vector<uint8_t>::size_type m_cache_read_position;
- std::vector<liblas::Point> m_cache;
+ std::vector<PointPtr> m_cache;
};
diff -r be85dc4a99c3 -r b039dfdada40 include/liblas/liblas.hpp
--- a/include/liblas/liblas.hpp Mon Jul 26 20:46:02 2010 -0500
+++ b/include/liblas/liblas.hpp Mon Jul 26 21:37:43 2010 -0500
@@ -162,7 +162,7 @@
public:
virtual HeaderPtr ReadHeader() = 0;
- virtual Point const& ReadNextPoint(HeaderPtr header) = 0;
+ virtual PointPtr ReadNextPoint(HeaderPtr header) = 0;
virtual Point const& ReadPointAt(std::size_t n, HeaderPtr header) = 0;
virtual void Seek(std::size_t n, HeaderPtr header) = 0;
diff -r be85dc4a99c3 -r b039dfdada40 src/detail/reader/reader.cpp
--- a/src/detail/reader/reader.cpp Mon Jul 26 20:46:02 2010 -0500
+++ b/src/detail/reader/reader.cpp Mon Jul 26 21:37:43 2010 -0500
@@ -100,7 +100,7 @@
return h;
}
-liblas::Point const& ReaderImpl::ReadNextPoint(HeaderPtr header)
+PointPtr ReaderImpl::ReadNextPoint(HeaderPtr header)
{
if (0 == m_current)
{
@@ -112,9 +112,9 @@
if (m_current < m_size)
{
m_point_reader->read();
- const liblas::Point& point = m_point_reader->GetPoint();
+ PointPtr ptr(new liblas::Point(m_point_reader->GetPoint()));
++m_current;
- return point;
+ return ptr;
} else if (m_current == m_size ){
throw std::out_of_range("file has no more points to read, end of file reached");
@@ -230,7 +230,7 @@
}
-liblas::Point const& CachedReaderImpl::ReadCachedPoint(liblas::uint32_t position, HeaderPtr header) {
+PointPtr CachedReaderImpl::ReadCachedPoint(liblas::uint32_t position, HeaderPtr header) {
int32_t cache_position = position - m_cache_start_position ;
@@ -286,15 +286,15 @@
}
-liblas::Point const& CachedReaderImpl::ReadNextPoint(HeaderPtr header)
+PointPtr CachedReaderImpl::ReadNextPoint(HeaderPtr header)
{
if (m_cache_read_position == m_size ){
throw std::out_of_range("file has no more points to read, end of file reached");
}
- liblas::Point const& point = ReadCachedPoint(m_cache_read_position, header);
+ PointPtr ptr = ReadCachedPoint(m_cache_read_position, header);
++m_cache_read_position;
- return point;
+ return ptr;
}
liblas::Point const& CachedReaderImpl::ReadPointAt(std::size_t n, HeaderPtr header)
@@ -312,9 +312,9 @@
throw std::runtime_error(out);
}
- liblas::Point const& point = ReadCachedPoint(n, header);
+ PointPtr ptr = ReadCachedPoint(n, header);
m_cache_read_position = n;
- return point;
+ return *ptr;
}
void CachedReaderImpl::Reset(HeaderPtr header)
diff -r be85dc4a99c3 -r b039dfdada40 src/lasreader.cpp
--- a/src/lasreader.cpp Mon Jul 26 20:46:02 2010 -0500
+++ b/src/lasreader.cpp Mon Jul 26 21:37:43 2010 -0500
@@ -135,7 +135,7 @@
}
try {
- m_point = const_cast<Point*>(&(m_pimpl->ReadNextPoint(m_header)));
+ m_point = m_pimpl->ReadNextPoint(m_header).get();
if (bHaveFilters) {
if (m_filters->size() != 0) {
// We have filters, filter this point. All filters must
More information about the Liblas-commits
mailing list