[Liblas-commits] hg: Added FIXME comment to make use of shared_ptr for robust lib...

liblas-commits at liblas.org liblas-commits at liblas.org
Sat Jul 31 21:11:45 EDT 2010


changeset 75fd8e2efbe1 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=75fd8e2efbe1
summary: Added FIXME comment to make use of shared_ptr for robust libtif resources management. Tidy up.

diffstat:

 include/liblas/lasspatialreference.hpp |  13 ++++---
 src/lasspatialreference.cpp            |  57 ++++++++++++++++-----------------
 2 files changed, 34 insertions(+), 36 deletions(-)

diffs (158 lines):

diff -r c0853bafd094 -r 75fd8e2efbe1 include/liblas/lasspatialreference.hpp
--- a/include/liblas/lasspatialreference.hpp	Sun Aug 01 02:02:25 2010 +0100
+++ b/include/liblas/lasspatialreference.hpp	Sun Aug 01 02:10:36 2010 +0100
@@ -105,7 +105,7 @@
     ~SpatialReference();
 
     /// Constructor creating SpatialReference instance from given Variable-Length Record.
-    SpatialReference(const std::vector<VariableRecord>& vlrs);
+    SpatialReference(std::vector<VariableRecord> const& vlrs);
 
     /// Copy constryctor.
     SpatialReference(SpatialReference const& other);
@@ -147,9 +147,9 @@
     /// -1 if no value is available.
     /// \param verticalUnits - the EPSG vertical units code, often 9001 for Metre.
     void SetVerticalCS(int verticalCSType, 
-                       std::string const& citation = "",
+                       std::string const& citation = std::string(0),
                        int verticalDatum = -1,
-                       int verticalUnits = 9001 );
+                       int verticalUnits = 9001);
 
     /// Sets the SRS using GDAL's SetFromUserInput function. If GDAL is not linked, this 
     /// operation has no effect.
@@ -175,21 +175,22 @@
     /// VLR records that pertain to the GeoTIFF keys, and extraneous 
     /// VLR records will not be copied.
     /// \param vlrs - A list of VLRs that contains VLRs describing GeoTIFF keys
-    void SetVLRs(const std::vector<VariableRecord>& vlrs);
+    void SetVLRs(std::vector<VariableRecord> const& vlrs);
     
     /// Add a VLR representing GeoTIFF keys to the SRS
-    void AddVLR(const VariableRecord& vlr);
+    void AddVLR(VariableRecord const& vlr);
     
     /// Return a copy of the LASVLRs that SpatialReference maintains
     std::vector<VariableRecord> GetVLRs() const;
 
 private:
 
+    // FIXME: Define as shared_ptr<GTIF> with custom deleter to get rid of bloated mem management, unsafe anyway --mloskot
     GTIF* m_gtiff;
     ST_TIFF* m_tiff;
 
     std::vector<VariableRecord> m_vlrs;
-    bool IsGeoVLR(const VariableRecord& vlr) const;
+    bool IsGeoVLR(VariableRecord const& vlr) const;
 
     /// Reset the VLRs of the SpatialReference using the existing GTIF* and ST_TIF*
     /// Until this method is called, 
diff -r c0853bafd094 -r 75fd8e2efbe1 src/lasspatialreference.cpp
--- a/src/lasspatialreference.cpp	Sun Aug 01 02:02:25 2010 +0100
+++ b/src/lasspatialreference.cpp	Sun Aug 01 02:10:36 2010 +0100
@@ -49,17 +49,32 @@
 #include <string>
 #include <vector>
 
-namespace liblas
-{
+namespace liblas {
 
-SpatialReference::SpatialReference() :
-    m_gtiff(0),
-    m_tiff(0)
+SpatialReference::SpatialReference()
+    : m_gtiff(0)
+    , m_tiff(0)
 {
     assert(0 == m_gtiff);
     assert(0 == m_tiff);
 }
 
+SpatialReference::SpatialReference(std::vector<VariableRecord> const& vlrs) 
+    : m_gtiff(0)
+    , m_tiff(0)
+{
+    SetVLRs(vlrs);
+    GetGTIF();
+}
+
+SpatialReference::SpatialReference(SpatialReference const& other) 
+    : m_gtiff(0)
+    , m_tiff(0)
+{
+    SetVLRs(other.GetVLRs());
+    GetGTIF();
+}
+
 SpatialReference& SpatialReference::operator=(SpatialReference const& rhs)
 {
     if (&rhs != this)
@@ -86,22 +101,6 @@
 #endif
 }
 
-SpatialReference::SpatialReference(SpatialReference const& other) 
-{
-    m_tiff = 0;
-    m_gtiff = 0;
-    SetVLRs(other.GetVLRs());
-    GetGTIF();
-}
-
-SpatialReference::SpatialReference(std::vector<VariableRecord> const& vlrs) 
-{
-    m_tiff = 0;
-    m_gtiff = 0;
-    SetVLRs(vlrs);
-    GetGTIF();
-}
-
 /// Keep a copy of the VLRs that are related to GeoTIFF SRS information.
 void SpatialReference::SetVLRs(std::vector<VariableRecord> const& vlrs)
 {
@@ -295,8 +294,8 @@
     m_gtiff = (GTIF*)pgtiff;
     m_tiff = (ST_TIFF*)ptiff;
     ResetVLRs();
-    m_gtiff = NULL;
-    m_tiff = NULL;
+    m_gtiff = 0;
+    m_tiff = 0;
 }
 const GTIF* SpatialReference::GetGTIF()
 {
@@ -421,7 +420,7 @@
 #endif
 }
 
-void SpatialReference::SetFromUserInput( std::string const& v)
+void SpatialReference::SetFromUserInput(std::string const& v)
 {
 #ifdef HAVE_GDAL
 
@@ -476,11 +475,10 @@
 #endif
 }
 
-void SpatialReference::SetVerticalCS( int verticalCSType, 
-                                         std::string const& citation,
-                                         int verticalDatum,
-                                         int verticalUnits )
-
+void SpatialReference::SetVerticalCS(int verticalCSType, 
+                                     std::string const& citation,
+                                     int verticalDatum,
+                                     int verticalUnits)
 {
     if (!m_gtiff)
     {
@@ -519,7 +517,6 @@
 #endif /* def HAVE_LIBGEOTIFF */
 }
                                          
-
 std::string SpatialReference::GetProj4() const 
 {
 #ifdef HAVE_GDAL


More information about the Liblas-commits mailing list