[Liblas-commits] hg-main-tree: some riffing around with boost::multi_index to con...

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Jul 12 17:00:56 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/34e04ba6b651
changeset: 855:34e04ba6b651
user:      Howard Butler <hobu.inc at gmail.com>
date:      Tue Jul 12 16:00:41 2011 -0500
description:
some riffing around with boost::multi_index to contain the pdal::Dimensions for the pdal::Schema

diffstat:

 include/pdal/Schema.hpp |   5 +++++
 src/Schema.cpp          |  38 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 1 deletions(-)

diffs (103 lines):

diff -r 650c22afc8ac -r 34e04ba6b651 include/pdal/Schema.hpp
--- a/include/pdal/Schema.hpp	Tue Jul 12 09:29:29 2011 -0500
+++ b/include/pdal/Schema.hpp	Tue Jul 12 16:00:41 2011 -0500
@@ -88,6 +88,10 @@
       >
 > IndexMap;
 
+// typedef IndexMap::index<name>::type index_by_name;
+// typedef IndexMap::index<position>::type index_by_position;
+typedef IndexMap::index<index>::type index_by_index;
+
 }} // pdal::schema::index
 
 /// Schema definition
@@ -137,6 +141,7 @@
 
 private:
     std::vector<Dimension> m_dimensions;
+    pdal::schema::index::IndexMap m_index;
 
     // this is a mapping from field name to index position in the
     // m_dimensions array (or -1 if field not present)
diff -r 650c22afc8ac -r 34e04ba6b651 src/Schema.cpp
--- a/src/Schema.cpp	Tue Jul 12 09:29:29 2011 -0500
+++ b/src/Schema.cpp	Tue Jul 12 16:00:41 2011 -0500
@@ -42,9 +42,12 @@
 #include <pdal/Schema.hpp>
 
 #include <iostream>
+#include <algorithm>
 
 #include <pdal/exceptions.hpp>
 
+#include <boost/lambda/lambda.hpp>
+
 #ifdef PDAL_HAVE_LIBXML2
 #include <pdal/XMLSchema.hpp>
 #endif
@@ -53,12 +56,13 @@
 {
 
 
-Schema::Schema()
+Schema::Schema() 
 {
     for (int i=0; i<Dimension::Field_LAST; i++)
     {
         m_indexTable[i] = -1;
     }
+    m_index.reserve(512);
     return;
 }
 
@@ -146,10 +150,19 @@
     const Dimension::Field field = dim.getField();
     assert(m_indexTable[field] == -1);
     m_indexTable[field] = (int)index;
+    
+    schema::index::index_by_index & idx = m_index.get<schema::index::index>();
+    idx.push_back(dim);
 
     return;
 }
 
+bool SameDimension(Dimension const& dim1, Dimension const& dim2)
+{
+    if (dim1 == dim2) return true;
+    return false;
+}
+
 
 void Schema::removeDimension(Dimension const& dim)
 {
@@ -160,6 +173,29 @@
     //std::size_t index = getDimensionIndex(dim);
     //m_dimensions[index] = Dimension(Dimension::Field_INVALID, Dimension::Int32);
 
+    // Add/reset the dimension ptr on the dimensions map
+    schema::index::index_by_index & idx = m_index.get<schema::index::index>();
+
+    schema::index::index_by_index::iterator it = idx.begin();
+
+    while (it != idx.end())
+    {
+        if (*it == dim)
+        {
+            idx.erase(it);
+            break;
+            
+        }
+        ++it;
+    }
+
+    
+    // 
+    // if (it != name_index.end())
+    //     name_index.replace(it, dim);
+    // else 
+    //     m_index.insert(d);    
+
     return;
 }
 


More information about the Liblas-commits mailing list