[Liblas-commits] hg: replace reprojection transform with
boost::shared_ptr instea...
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Jul 14 11:54:25 EDT 2010
changeset baa0a0a95713 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=baa0a0a95713
summary: replace reprojection transform with boost::shared_ptr instead of naked pointer
diffstat:
include/liblas/lasreader.hpp | 9 ++++++---
include/liblas/laswriter.hpp | 3 +--
src/lasreader.cpp | 36 +++++++++++++++++++++---------------
3 files changed, 28 insertions(+), 20 deletions(-)
diffs (142 lines):
diff -r 1c965145fba9 -r baa0a0a95713 include/liblas/lasreader.hpp
--- a/include/liblas/lasreader.hpp Wed Jul 14 10:49:25 2010 -0500
+++ b/include/liblas/lasreader.hpp Wed Jul 14 10:54:19 2010 -0500
@@ -52,8 +52,6 @@
#include <liblas/lasspatialreference.hpp>
#include <liblas/lastransform.hpp>
-
-
// std
#include <iosfwd>
#include <string>
@@ -61,8 +59,13 @@
#include <vector>
#include <cstddef>
+#include <boost/shared_ptr.hpp>
+
namespace liblas {
+typedef boost::shared_ptr< liblas::TransformI > TransformPtr;
+
+
/// Defines public interface to LAS reader implementation.
class Reader
{
@@ -179,7 +182,7 @@
std::vector<liblas::FilterI*>* m_filters;
std::vector<liblas::TransformI*>* m_transforms;
- liblas::TransformI* m_reprojection_transform;
+ TransformPtr m_reprojection_transform;
SpatialReference m_out_srs;
SpatialReference m_in_srs;
diff -r 1c965145fba9 -r baa0a0a95713 include/liblas/laswriter.hpp
--- a/include/liblas/laswriter.hpp Wed Jul 14 10:49:25 2010 -0500
+++ b/include/liblas/laswriter.hpp Wed Jul 14 10:54:19 2010 -0500
@@ -131,8 +131,7 @@
std::vector<liblas::TransformI*>* m_transforms;
TransformPtr m_reprojection_transform;
- // liblas::TransformI* m_reprojection_transform;
-
+
SpatialReference m_out_srs;
SpatialReference m_in_srs;
diff -r 1c965145fba9 -r baa0a0a95713 src/lasreader.cpp
--- a/src/lasreader.cpp Wed Jul 14 10:49:25 2010 -0500
+++ b/src/lasreader.cpp Wed Jul 14 10:54:19 2010 -0500
@@ -63,7 +63,7 @@
bCustomHeader(false),
m_filters(0),
m_transforms(0),
- m_reprojection_transform(0)
+ m_reprojection_transform(TransformPtr())
{
Init();
}
@@ -75,7 +75,7 @@
bCustomHeader(false),
m_filters(0),
m_transforms(0),
- m_reprojection_transform(0)
+ m_reprojection_transform(TransformPtr())
{
Init();
}
@@ -87,7 +87,7 @@
bCustomHeader(false),
m_filters(0),
m_transforms(0),
- m_reprojection_transform(0)
+ m_reprojection_transform(TransformPtr())
{
m_header = header;
bCustomHeader = true;
@@ -100,8 +100,6 @@
// std::auto_ptr with incomplete type (Reader).
delete m_empty_point;
- if (m_reprojection_transform != 0)
- delete m_reprojection_transform;
}
Header const& Reader::GetHeader() const
@@ -299,6 +297,13 @@
m_out_srs = srs;
m_pimpl->Reset(m_header);
+ // Check the very first transform and see if it is
+ // the reprojection transform. If it is, we're going to
+ // nuke it and replace it with a new one
+
+ // If there was nothing there, we're going to make a new reprojection
+ // transform and put in on the transforms list (or make a new transforms
+ // list if *that* isn't there).
TransformI* possible_reprojection_transform = 0;
if (m_transforms != 0) {
@@ -307,29 +312,30 @@
}
}
- if (m_reprojection_transform == possible_reprojection_transform && m_reprojection_transform != 0) {
+ if (m_reprojection_transform.get() == possible_reprojection_transform && m_reprojection_transform.get() != 0) {
// remove it from the transforms list
std::vector<TransformI*>::iterator i = m_transforms->begin();
m_transforms->erase(i);
}
- if (m_reprojection_transform != 0)
- {
- delete m_reprojection_transform;
- }
-
- m_reprojection_transform = new ReprojectionTransform(m_in_srs, m_out_srs);
+ // overwrite our reprojection transform
+ m_reprojection_transform = TransformPtr(new ReprojectionTransform(m_in_srs, m_out_srs));
if (m_transforms != 0) {
if (m_transforms->size() > 0) {
- m_transforms->insert(m_transforms->begin(), m_reprojection_transform);
+ // Insert the new reprojection transform to the beginning of the
+ // vector there are already transforms there.
+ m_transforms->insert(m_transforms->begin(), m_reprojection_transform.get());
} else {
- m_transforms->push_back(m_reprojection_transform);
+ // List exists, but its size is 0
+ m_transforms->push_back(m_reprojection_transform.get());
}
} else {
+ // transforms don't exist yet, make a new one and put our
+ // reprojection transform on it.
m_transforms = new std::vector<liblas::TransformI*>;
- m_transforms->push_back(m_reprojection_transform);
+ m_transforms->push_back(m_reprojection_transform.get());
}
return true;
}
More information about the Liblas-commits
mailing list