[Liblas-commits] hg: replace naked pointer to header/point
reader/writer detail i...
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Jul 14 11:34:54 EDT 2010
changeset e07b656ef222 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=e07b656ef222
summary: replace naked pointer to header/point reader/writer detail implementations with boost::shared_ptr
diffstat:
include/liblas/detail/reader/reader.hpp | 19 +++++++------------
include/liblas/detail/writer/writer.hpp | 13 +++++++++----
src/detail/reader/reader.cpp | 9 +++------
src/detail/writer/writer.cpp | 20 ++++++++------------
4 files changed, 27 insertions(+), 34 deletions(-)
diffs (174 lines):
diff -r 44578bc94c3f -r e07b656ef222 include/liblas/detail/reader/reader.hpp
--- a/include/liblas/detail/reader/reader.hpp Tue Jul 13 15:29:28 2010 -0500
+++ b/include/liblas/detail/reader/reader.hpp Wed Jul 14 10:34:40 2010 -0500
@@ -49,10 +49,13 @@
// std
#include <iosfwd>
-
+#include <boost/shared_ptr.hpp>
namespace liblas { namespace detail {
+typedef boost::shared_ptr< reader::Point > PointReaderPtr;
+typedef boost::shared_ptr< reader::Header > HeaderReaderPtr;
+
class ReaderImpl : public ReaderI
{
public:
@@ -68,9 +71,6 @@
std::istream& GetStream() const;
void Reset(liblas::Header const& header);
- // void SetSRS(const SpatialReference& srs, const liblas::Header& header);
- // void SetInputSRS(const SpatialReference& srs);
- // void SetOutputSRS(const SpatialReference& srs, const liblas::Header& header);
protected:
void CreateTransform();
@@ -83,14 +83,9 @@
std::istream& m_ifs;
uint32_t m_size;
uint32_t m_current;
- // SpatialReference m_out_srs;
- // SpatialReference m_in_srs;
- // OGRCoordinateTransformationH m_transform;
- // OGRSpatialReferenceH m_in_ref;
- // OGRSpatialReferenceH m_out_ref;
-
- detail::reader::Point* m_point_reader;
- detail::reader::Header* m_header_reader;
+
+ PointReaderPtr m_point_reader;
+ HeaderReaderPtr m_header_reader;
private:
diff -r 44578bc94c3f -r e07b656ef222 include/liblas/detail/writer/writer.hpp
--- a/include/liblas/detail/writer/writer.hpp Tue Jul 13 15:29:28 2010 -0500
+++ b/include/liblas/detail/writer/writer.hpp Wed Jul 14 10:34:40 2010 -0500
@@ -47,9 +47,16 @@
#include <liblas/detail/writer/point.hpp>
#include <liblas/detail/writer/header.hpp>
+#include <boost/shared_ptr.hpp>
+
+
namespace liblas { namespace detail {
+
+typedef boost::shared_ptr< writer::Point > PointWriterPtr;
+typedef boost::shared_ptr< writer::Header > HeaderWriterPtr;
+
class WriterImpl : public WriterI
{
public:
@@ -68,13 +75,11 @@
PointRecord m_record;
std::ostream& m_ofs;
-
- writer::Point* m_point_writer;
- writer::Header* m_header_writer;
+ PointWriterPtr m_point_writer;
+ HeaderWriterPtr m_header_writer;
private:
- // void CreateTransform();
liblas::uint32_t m_pointCount;
// block copying operations
diff -r 44578bc94c3f -r e07b656ef222 src/detail/reader/reader.cpp
--- a/src/detail/reader/reader.cpp Tue Jul 13 15:29:28 2010 -0500
+++ b/src/detail/reader/reader.cpp Wed Jul 14 10:34:40 2010 -0500
@@ -59,17 +59,14 @@
ReaderImpl::ReaderImpl(std::istream& ifs) :
m_ifs(ifs), m_size(0), m_current(0),
- m_point_reader(0),
- m_header_reader(new reader::Header(m_ifs))
+ m_point_reader(PointReaderPtr()),
+ m_header_reader(HeaderReaderPtr(new reader::Header(m_ifs)))
{
}
ReaderImpl::~ReaderImpl()
{
-
- delete m_point_reader;
- delete m_header_reader;
}
std::istream& ReaderImpl::GetStream() const
@@ -89,7 +86,7 @@
// If we reset the reader, we're ready to start reading points, so
// we'll create a point reader at this point.
if (m_point_reader == 0) {
- m_point_reader = new reader::Point(m_ifs, header);
+ m_point_reader = PointReaderPtr(new reader::Point(m_ifs, header));
}
}
diff -r 44578bc94c3f -r e07b656ef222 src/detail/writer/writer.cpp
--- a/src/detail/writer/writer.cpp Tue Jul 13 15:29:28 2010 -0500
+++ b/src/detail/writer/writer.cpp Wed Jul 14 10:34:40 2010 -0500
@@ -46,6 +46,7 @@
#include <liblas/lasheader.hpp>
#include <liblas/laspoint.hpp>
#include <liblas/liblas.hpp>
+
// std
#include <vector>
#include <fstream>
@@ -57,8 +58,8 @@
WriterImpl::WriterImpl(std::ostream& ofs) :
m_ofs(ofs),
- m_point_writer(0),
- m_header_writer(0),
+ m_point_writer(PointWriterPtr( )),
+ m_header_writer(HeaderWriterPtr()),
m_pointCount(0)
{
}
@@ -66,11 +67,12 @@
liblas::Header const& WriterImpl::WriteHeader(liblas::Header const& header)
{
+ m_header_writer = HeaderWriterPtr(new writer::Header(m_ofs,m_pointCount, header) );
+
if (m_header_writer == 0) {
- m_header_writer = new detail::writer::Header(m_ofs,m_pointCount, header );
+ m_header_writer = HeaderWriterPtr(new writer::Header(m_ofs,m_pointCount, header) );
} else {
- delete m_header_writer;
- m_header_writer = new detail::writer::Header(m_ofs,m_pointCount, header );
+ m_header_writer = HeaderWriterPtr(new writer::Header(m_ofs,m_pointCount, header) );
}
m_header_writer->write();
return m_header_writer->GetHeader();
@@ -90,7 +92,7 @@
void WriterImpl::WritePoint(liblas::Point const& point, const liblas::Header& header)
{
if (m_point_writer == 0) {
- m_point_writer = new detail::writer::Point(m_ofs, m_pointCount, header);
+ m_point_writer = PointWriterPtr(new writer::Point(m_ofs, m_pointCount, header));
}
m_point_writer->write(point);
@@ -99,12 +101,6 @@
WriterImpl::~WriterImpl()
{
- if (m_point_writer != 0)
- delete m_point_writer;
-
- if (m_header_writer != 0)
- delete m_header_writer;
-
}
std::ostream& WriterImpl::GetStream() const
More information about the Liblas-commits
mailing list