[Liblas-commits] hg-main-tree: factor PipelineManager into separate
classes
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Jul 27 17:33:19 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/3f0d06373ce2
changeset: 958:3f0d06373ce2
user: Michael P. Gerlek <mpg at flaxen.com>
date: Wed Jul 27 14:33:15 2011 -0700
description:
factor PipelineManager into separate classes
diffstat:
include/pdal/PipelineManager.hpp | 35 +--
include/pdal/PipelineReader.hpp | 95 ++++++++
include/pdal/PipelineWriter.hpp | 64 +++++
src/CMakeLists.txt | 4 +
src/PipelineManager.cpp | 410 +---------------------------------
src/PipelineReader.cpp | 451 ++++++++++++++++++++++++++++++++++++++
src/PipelineWriter.cpp | 94 +++++++
test/unit/CMakeLists.txt | 2 +
test/unit/PipelineManagerTest.cpp | 115 +---------
test/unit/PipelineReaderTest.cpp | 158 +++++++++++++
test/unit/PipelineWriterTest.cpp | 75 ++++++
11 files changed, 968 insertions(+), 535 deletions(-)
diffs (truncated from 1653 to 300 lines):
diff -r bd76cb7782e6 -r 3f0d06373ce2 include/pdal/PipelineManager.hpp
--- a/include/pdal/PipelineManager.hpp Wed Jul 27 12:58:49 2011 -0700
+++ b/include/pdal/PipelineManager.hpp Wed Jul 27 14:33:15 2011 -0700
@@ -53,9 +53,6 @@
class PDAL_DLL PipelineManager
{
-private:
- class StageParserContext;
-
public:
PipelineManager();
~PipelineManager();
@@ -66,32 +63,16 @@
MultiFilter* addMultiFilter(const std::string& type, const std::vector<const Stage*>& prevStages, const Options&);
Writer* addWriter(const std::string& type, const Stage& prevStage, const Options&);
- // Use this to fill in a pipeline manager with an XML file that
- // contains a <Writer> as the last pipeline stage.
- Writer& readWriterPipeline(const std::string&);
+ // returns true iff the pipeline endpoint is a writer
+ bool isWriterPipeline() const;
- // Use this to fill in a pipeline manager with an XML file that
- // don't contain a <Writer>. (Even though this is called "parse
- // READER pipeline", it actually returns a Stage; it can be used
- // where the last pipeline stage is a Reader or Filter.)
- const Stage& readReaderPipeline(const std::string&);
+ // return the pipeline writer endpoint (or NULL, if not a writer pipeline)
+ Writer* getWriter() const;
- void writeWriterPipeline(const std::string& filename) const;
+ // return the pipeline reader endpoint (or NULL, if not a reader pipeline)
+ const Stage* getStage() const;
private:
- boost::property_tree::ptree parsePipelineElement(const std::string& filename);
- Writer* parseWriterRoot(const boost::property_tree::ptree&);
- Stage* parseStageRoot(const boost::property_tree::ptree&);
-
- 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);
-
StageFactory m_factory;
typedef std::vector<Reader*> ReaderList;
@@ -103,6 +84,10 @@
MultiFilterList m_multifilters;
WriterList m_writers;
+ Stage* m_lastStage;
+ Writer* m_lastWriter;
+ bool m_isWriterPipeline;
+
PipelineManager& operator=(const PipelineManager&); // not implemented
PipelineManager(const PipelineManager&); // not implemented
};
diff -r bd76cb7782e6 -r 3f0d06373ce2 include/pdal/PipelineReader.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/pdal/PipelineReader.hpp Wed Jul 27 14:33:15 2011 -0700
@@ -0,0 +1,95 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.com)
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following
+* conditions are met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the
+* names of its contributors may be used to endorse or promote
+* products derived from this software without specific prior
+* written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+* OF SUCH DAMAGE.
+****************************************************************************/
+
+#ifndef INCLUDED_PIPELINEREADER_HPP
+#define INCLUDED_PIPELINEREADER_HPP
+
+#include <pdal/pdal.hpp>
+#include <pdal/StageFactory.hpp>
+
+#include <vector>
+#include <string>
+
+
+namespace pdal
+{
+
+class Options;
+class PipelineManager;
+
+class PDAL_DLL PipelineReader
+{
+private:
+ class StageParserContext;
+
+public:
+ PipelineReader(PipelineManager&);
+ ~PipelineReader();
+
+
+ // Use this to fill in a pipeline manager with an XML file that
+ // contains a <Writer> as the last pipeline stage.
+ void readWriterPipeline(const std::string&);
+
+ // Use this to fill in a pipeline manager with an XML file that
+ // don't contain a <Writer>. (Even though this is called "parse
+ // READER pipeline", it actually returns a Stage; it can be used
+ // where the last pipeline stage is a Reader or Filter.)
+ 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&);
+
+ 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);
+
+private:
+ PipelineManager& m_manager;
+
+ PipelineReader& operator=(const PipelineReader&); // not implemented
+ PipelineReader(const PipelineReader&); // not implemented
+};
+
+
+} // namespace pdal
+
+#endif
diff -r bd76cb7782e6 -r 3f0d06373ce2 include/pdal/PipelineWriter.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/pdal/PipelineWriter.hpp Wed Jul 27 14:33:15 2011 -0700
@@ -0,0 +1,64 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.com)
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following
+* conditions are met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the
+* names of its contributors may be used to endorse or promote
+* products derived from this software without specific prior
+* written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+* OF SUCH DAMAGE.
+****************************************************************************/
+
+#ifndef INCLUDED_PIPELINEWRITER_HPP
+#define INCLUDED_PIPELINEWRITER_HPP
+
+#include <pdal/pdal.hpp>
+#include <string>
+
+namespace pdal
+{
+
+class PipelineManager;
+
+class PDAL_DLL PipelineWriter
+{
+public:
+ PipelineWriter(const PipelineManager&);
+ ~PipelineWriter();
+
+ void writeWriterPipeline(const std::string& filename) const;
+
+private:
+ const PipelineManager& m_manager;
+
+ PipelineWriter& operator=(const PipelineWriter&); // not implemented
+ PipelineWriter(const PipelineWriter&); // not implemented
+};
+
+
+} // namespace pdal
+
+#endif
diff -r bd76cb7782e6 -r 3f0d06373ce2 src/CMakeLists.txt
--- a/src/CMakeLists.txt Wed Jul 27 12:58:49 2011 -0700
+++ b/src/CMakeLists.txt Wed Jul 27 14:33:15 2011 -0700
@@ -36,6 +36,8 @@
${PDAL_HEADERS_DIR}/MultiFilterIterator.hpp
${PDAL_HEADERS_DIR}/Options.hpp
${PDAL_HEADERS_DIR}/PipelineManager.hpp
+ ${PDAL_HEADERS_DIR}/PipelineReader.hpp
+ ${PDAL_HEADERS_DIR}/PipelineWriter.hpp
${PDAL_HEADERS_DIR}/PointBuffer.hpp
${PDAL_HEADERS_DIR}/PointBufferCache.hpp
${PDAL_HEADERS_DIR}/Range.hpp
@@ -72,6 +74,8 @@
MultiFilterIterator.cpp
Options.cpp
PipelineManager.cpp
+ PipelineReader.cpp
+ PipelineWriter.cpp
PointBuffer.cpp
PointBufferCache.cpp
Range.cpp
diff -r bd76cb7782e6 -r 3f0d06373ce2 src/PipelineManager.cpp
--- a/src/PipelineManager.cpp Wed Jul 27 12:58:49 2011 -0700
+++ b/src/PipelineManager.cpp Wed Jul 27 14:33:15 2011 -0700
@@ -51,6 +51,9 @@
{
PipelineManager::PipelineManager()
+ : m_lastStage(NULL)
+ , m_lastWriter(NULL)
+ , m_isWriterPipeline(false)
{
return;
@@ -95,6 +98,7 @@
{
Reader* stage = m_factory.createReader(type, options);
m_readers.push_back(stage);
+ m_lastStage = stage;
return stage;
}
@@ -103,6 +107,7 @@
{
Filter* stage = m_factory.createFilter(type, prevStage, options);
m_filters.push_back(stage);
+ m_lastStage = stage;
return stage;
}
@@ -111,418 +116,31 @@
{
MultiFilter* stage = m_factory.createMultiFilter(type, prevStages, options);
m_multifilters.push_back(stage);
+ m_lastStage = stage;
return stage;
}
Writer* PipelineManager::addWriter(const std::string& type, const Stage& prevStage, const Options& options)
{
- Writer* stage = m_factory.createWriter(type, prevStage, options);
- m_writers.push_back(stage);
- return stage;
-}
+ m_isWriterPipeline = true;
-
-class PipelineManager::StageParserContext
-{
More information about the Liblas-commits
mailing list