[Liblas-commits] hg-main-tree: added generic verbose and debug options

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Jul 29 00:15:31 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/22d422c3be7e
changeset: 960:22d422c3be7e
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Jul 28 21:03:27 2011 -0700
description:
added generic verbose and debug options
Subject: hg-main-tree: made root element ReaderPipeline or WriterPipeline

details:   http://hg.libpc.orghg-main-tree/rev/36fc7fac39f9
changeset: 961:36fc7fac39f9
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Jul 28 21:03:54 2011 -0700
description:
made root element ReaderPipeline or WriterPipeline

diffstat:

 include/pdal/PipelineReader.hpp |  20 +++----
 include/pdal/StageBase.hpp      |  11 ++++
 mpg-config.bat                  |   2 +-
 src/PipelineReader.cpp          |  93 +++++++++++++++++++++-------------------
 src/PipelineWriter.cpp          |   2 +-
 src/StageBase.cpp               |  20 ++++++++
 test/data/pipeline_bad01.xml    |   4 +-
 test/data/pipeline_bad02.xml    |   4 +-
 test/data/pipeline_bad03.xml    |   4 +-
 test/data/pipeline_bad04.xml    |   4 +-
 test/data/pipeline_bad05.xml    |   4 +-
 test/data/pipeline_bad06.xml    |   4 +-
 test/data/pipeline_bad07.xml    |   4 +-
 test/data/pipeline_bad08.xml    |   4 +-
 test/data/pipeline_bad09.xml    |   6 +-
 test/data/pipeline_bad10.xml    |   4 +-
 test/data/pipeline_read.xml     |   4 +-
 test/data/pipeline_write.xml    |   4 +-
 18 files changed, 115 insertions(+), 83 deletions(-)

diffs (truncated from 593 to 300 lines):

diff -r f2fb65bf789c -r 36fc7fac39f9 include/pdal/PipelineReader.hpp
--- a/include/pdal/PipelineReader.hpp	Wed Jul 27 17:28:00 2011 -0700
+++ b/include/pdal/PipelineReader.hpp	Thu Jul 28 21:03:54 2011 -0700
@@ -69,18 +69,16 @@
     void readReaderPipeline(const std::string&);
 
 private:
-    boost::property_tree::ptree parsePipelineElement(const std::string& filename);
-    Writer* parseWriterRoot(const boost::property_tree::ptree&);
-    Stage* parseStageRoot(const boost::property_tree::ptree&);
+    Writer* parseElement_WriterPipeline(const boost::property_tree::ptree&);
+    Stage* parseElement_ReaderPipeline(const boost::property_tree::ptree&);
+    Stage* parseElement_anystage(const std::string& name, const boost::property_tree::ptree& subtree);
+    Reader* parseElement_Reader(const boost::property_tree::ptree& tree);
+    Filter* parseElement_Filter(const boost::property_tree::ptree& tree);
+    MultiFilter* parseElement_MultiFilter(const boost::property_tree::ptree& tree);
+    Writer* parseElement_Writer(const boost::property_tree::ptree& tree);
 
-    Stage* parseStageElement(const std::string& name, const boost::property_tree::ptree& subtree);
-    Reader* parseReaderElement(const boost::property_tree::ptree& tree);
-    Filter* parseFilterElement(const boost::property_tree::ptree& tree);
-    MultiFilter* parseMultiFilterElement(const boost::property_tree::ptree& tree);
-    Writer* parseWriterElement(const boost::property_tree::ptree& tree);
-
-    Option<std::string> parseOptionElement(const boost::property_tree::ptree& tree);
-    std::string parseTypeElement(const boost::property_tree::ptree& tree);
+    Option<std::string> parseElement_Option(const boost::property_tree::ptree& tree);
+    std::string parseElement_Type(const boost::property_tree::ptree& tree);
 
 private:
     PipelineManager& m_manager;
diff -r f2fb65bf789c -r 36fc7fac39f9 include/pdal/StageBase.hpp
--- a/include/pdal/StageBase.hpp	Wed Jul 27 17:28:00 2011 -0700
+++ b/include/pdal/StageBase.hpp	Thu Jul 28 21:03:54 2011 -0700
@@ -57,6 +57,15 @@
     // recursively visit all child stages to populate the tree.
     virtual boost::property_tree::ptree generatePTree() const = 0;
 
+    // set by the "debug" option, which is a boolean
+    bool isDebug() const;
+    
+    // set by the "verbose" option, which is in range [0..255]
+    // 0 means no verbosity at all; the meanings of other values are 
+    // defined by the individual stages
+    bool isVerbose() const; // true iff verbosity>0 
+    boost::uint8_t getVerboseLevel() const; 
+
     // For Name, Description, and DefaultOptions:
     //   each concrete class should provide a static function s_getX() which returns a static object
     //   each concrete class should provide a virtual getX() which returns s_getX()
@@ -96,6 +105,8 @@
 
 private:
     Options m_options;
+    bool m_debug;
+    boost::uint8_t m_verbose;
 
     StageBase& operator=(const StageBase&); // not implemented
     StageBase(const StageBase&); // not implemented
diff -r f2fb65bf789c -r 36fc7fac39f9 mpg-config.bat
--- a/mpg-config.bat	Wed Jul 27 17:28:00 2011 -0700
+++ b/mpg-config.bat	Thu Jul 28 21:03:54 2011 -0700
@@ -7,7 +7,7 @@
 set BUILD_TYPE=Debug
 
 set UTILS_DIR=c:\Utils
-set DEV_DIR=d:\dev
+set DEV_DIR=c:\dev
 set OSGEO4W_DIR=C:\OSGeo4W
 
 rem *** These packages are needed from OSGeo4W
diff -r f2fb65bf789c -r 36fc7fac39f9 src/PipelineReader.cpp
--- a/src/PipelineReader.cpp	Wed Jul 27 17:28:00 2011 -0700
+++ b/src/PipelineReader.cpp	Thu Jul 28 21:03:54 2011 -0700
@@ -53,7 +53,8 @@
     
 // ------------------------------------------------------------------------
 
-    
+// this class helps keep tracks of what child nodes we've seen, so we
+// can keep all the error checking in one place
 class PipelineReader::StageParserContext
 {
 public:
@@ -132,7 +133,7 @@
 }
 
 
-Option<std::string> PipelineReader::parseOptionElement(const boost::property_tree::ptree& tree)
+Option<std::string> PipelineReader::parseElement_Option(const boost::property_tree::ptree& tree)
 {
     // cur is an option element, such as this:
     //     <option>
@@ -148,7 +149,7 @@
 }
 
 
-std::string PipelineReader::parseTypeElement(const boost::property_tree::ptree& tree)
+std::string PipelineReader::parseElement_Type(const boost::property_tree::ptree& tree)
 {
     // tree is this:
     //     <type>drivers.foo.writer</type>
@@ -159,21 +160,21 @@
 }
 
 
-Stage* PipelineReader::parseStageElement(const std::string& name, const boost::property_tree::ptree& subtree)
+Stage* PipelineReader::parseElement_anystage(const std::string& name, const boost::property_tree::ptree& subtree)
 {
     Stage* stage = NULL;
 
     if (name == "Filter")
     {
-        stage = parseFilterElement(subtree);
+        stage = parseElement_Filter(subtree);
     }
     else if (name == "MultiFilter")
     {
-        stage = parseMultiFilterElement(subtree);
+        stage = parseElement_MultiFilter(subtree);
     }
     else if (name == "Reader")
     {
-        stage = parseReaderElement(subtree);
+        stage = parseElement_Reader(subtree);
     }
     else
     {
@@ -184,7 +185,7 @@
 }
 
 
-Reader* PipelineReader::parseReaderElement(const boost::property_tree::ptree& tree)
+Reader* PipelineReader::parseElement_Reader(const boost::property_tree::ptree& tree)
 {
     Options options;
     std::string type;
@@ -200,11 +201,11 @@
         if (name == "Type")
         {
             context.addType();
-            type = parseTypeElement(subtree);
+            type = parseElement_Type(subtree);
         }
         else if (name == "Option")
         {
-            Option<std::string> option = parseOptionElement(subtree);
+            Option<std::string> option = parseElement_Option(subtree);
             options.add(option);
         }
         else
@@ -222,7 +223,7 @@
 }
 
 
-Filter* PipelineReader::parseFilterElement(const boost::property_tree::ptree& tree)
+Filter* PipelineReader::parseElement_Filter(const boost::property_tree::ptree& tree)
 {
     Options options;
     std::string type = "";
@@ -239,17 +240,17 @@
         if (name == "Type")
         {
             context.addType();
-            type = parseTypeElement(subtree);
+            type = parseElement_Type(subtree);
         }
         else if (name == "Option")
         {
-            Option<std::string> option = parseOptionElement(subtree);
+            Option<std::string> option = parseElement_Option(subtree);
             options.add(option);
         }
         else if (name == "Filter" || name == "MultiFilter" || name == "Reader")
         {
             context.addStage();
-            prevStage = parseStageElement(name, subtree);
+            prevStage = parseElement_anystage(name, subtree);
         }
         else
         {
@@ -266,7 +267,7 @@
 }
 
 
-MultiFilter* PipelineReader::parseMultiFilterElement(const boost::property_tree::ptree& tree)
+MultiFilter* PipelineReader::parseElement_MultiFilter(const boost::property_tree::ptree& tree)
 {
     Options options;
     std::string type = "";
@@ -282,17 +283,17 @@
         if (name == "Type")
         {
             context.addType();
-            type = parseTypeElement(subtree);
+            type = parseElement_Type(subtree);
         }
         else if (name == "Option")
         {
-            Option<std::string> option = parseOptionElement(subtree);
+            Option<std::string> option = parseElement_Option(subtree);
             options.add(option);
         }
         else if (name == "Filter" || name == "MultiFilter" || name == "Reader")
         {
             context.addStage();
-            Stage* prevStage = parseStageElement(name, subtree);
+            Stage* prevStage = parseElement_anystage(name, subtree);
             prevStages.push_back(prevStage);
         }
         else
@@ -310,7 +311,7 @@
 }
 
 
-Writer* PipelineReader::parseWriterElement(const boost::property_tree::ptree& tree)
+Writer* PipelineReader::parseElement_Writer(const boost::property_tree::ptree& tree)
 {
     Options options;
     std::string type = "";
@@ -326,17 +327,17 @@
         if (name == "Type")
         {
             context.addType();
-            type = parseTypeElement(subtree);
+            type = parseElement_Type(subtree);
         }
         else if (name == "Option")
         {
-            Option<std::string> option = parseOptionElement(subtree);
+            Option<std::string> option = parseElement_Option(subtree);
             options.add(option);
         }
         else if (name == "Filter" || name == "MultiFilter" || name == "Reader")
         {
             context.addStage();
-            prevStage = parseStageElement(name, subtree);
+            prevStage = parseElement_anystage(name, subtree);
         }
         else
         {
@@ -353,7 +354,7 @@
 }
 
 
-Writer* PipelineReader::parseWriterRoot(const boost::property_tree::ptree& tree)
+Writer* PipelineReader::parseElement_WriterPipeline(const boost::property_tree::ptree& tree)
 {
     Writer* writer = NULL;
 
@@ -363,7 +364,7 @@
         if (iter->first == "Writer")
         {
             const boost::property_tree::ptree subtree = iter->second;
-            writer = parseWriterElement(subtree);
+            writer = parseElement_Writer(subtree);
         }
         else
         {
@@ -381,56 +382,49 @@
 }
 
 
-Stage* PipelineReader::parseStageRoot(const boost::property_tree::ptree& tree)
+Stage* PipelineReader::parseElement_ReaderPipeline(const boost::property_tree::ptree& tree)
 {
     Stage* stage = NULL;
 
     boost::property_tree::ptree::const_iterator iter = tree.begin();
+    const std::string& name = iter->first;
+    const boost::property_tree::ptree subtree = iter->second;
 
     {
-        const std::string& name = iter->first;
-        const boost::property_tree::ptree& subtree = iter->second;
-
         if (name == "Reader" || name == "Filter" || name == "MultiFilter")
         {
-            stage = parseStageElement(name, subtree);
+            stage = parseElement_anystage(name, subtree);
         }
         else
         {
-            throw pipeline_xml_error("xml reader invalid child of Pipeline element");
+            throw pipeline_xml_error("xml reader invalid child of ReaderPipeline element");
         }
     }
-
+    
     ++iter;
     if (iter != tree.end())
     {
-        throw pipeline_xml_error("extra nodes at front of stage pipeline");
+        throw pipeline_xml_error("extra nodes at front of writer pipeline");
     }
 
     return stage;
 }
 
 


More information about the Liblas-commits mailing list