Skip to content

Commit

Permalink
Plugin framework refactoring
Browse files Browse the repository at this point in the history
This commit adds a new PluginManager that controls loading of all plugins,
regardless of type (kernel vs. stage, static vs. shared). Subsequently, the
StageFactory and KernelFactory classes are greatly simplified as there was
significant redundant code. Macros are provided to simplify creation of each
type of plugin, but are not explicitly required. Each plugin registers it's
name, description, link, type, and will soon include a version.

Dropped program_options in pdal.cpp and added ability to selectively load
plugin types (or none at all).
  • Loading branch information
chambbj committed Feb 12, 2015
1 parent b7eadef commit ab011cf
Show file tree
Hide file tree
Showing 179 changed files with 2,314 additions and 2,005 deletions.
299 changes: 219 additions & 80 deletions apps/pdal.cpp

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions cmake/compiler_options.cmake
@@ -1,11 +1,17 @@
include_directories(${PDAL_INCLUDE_DIR})
include_directories(${PDAL_UTIL_DIR})
include_directories(${PDAL_SRC_DIR})
include_directories(${PDAL_IO_DIR})
include_directories(${PDAL_KERNEL_DIR})
include_directories(${PDAL_FILTER_DIR})
if (WIN32)
include (${CMAKE_CURRENT_LIST_DIR}/win32_compiler_options.cmake)
else()
include (${CMAKE_CURRENT_LIST_DIR}/unix_compiler_options.cmake)
if (APPLE)
set (PDAL_PLATFORM_OSX 1)
else()
set (PDAL_PLATFORM_LINUX 1)
endif()
endif()

14 changes: 0 additions & 14 deletions doc/tutorial/writing.rst
Expand Up @@ -39,20 +39,6 @@ main one, `<pdal/pdal.hpp>`, brings in most of the utility and basic classes
used throughout the PDAL system. Additionally, the following includes are
available subject to having the required include directories pathed:

* `#include <pdal/Drivers.hpp>`
* `#include <pdal/Filters.hpp>`
* `#include <pdal/Kernels.hpp>`


.. note::

Drivers, Filters, and Kernels bring in *all* of the respective sub includes
for those sections of the source tree. You are not required to include
everything if you don't need it, however, and it is still possible to
selectively include the classes you need as shown in the example below.



.. code-block:: cpp
#include <pdal/pdal.hpp>
Expand Down
2 changes: 1 addition & 1 deletion examples/writing/tutorial.cpp
Expand Up @@ -61,7 +61,7 @@ int main(int argc, char* argv[])
reader.addBuffer(buffer);

pdal::StageFactory f;
pdal::WriterPtr writer(f.createWriter("writers.las"));
pdal::std::unique_ptr<Stage> writer(f.createStage("writers.las"));
writer->setInput(&reader);
writer->setOptions(options);
writer->prepare(ctx);
Expand Down
8 changes: 8 additions & 0 deletions filters/chipper/ChipperFilter.cpp
Expand Up @@ -69,6 +69,14 @@ be stored.
namespace pdal
{

static PluginInfo const s_info {
"filters.chipper",
"Organize points into spatially contiguous, squarish, and non-overlapping chips.",
"http://pdal.io/stages/filters.chipper.html" };

CREATE_STATIC_PLUGIN(ChipperFilter, Filter, s_info)

std::string ChipperFilter::getName() const { return s_info.name; }

void ChipperFilter::processOptions(const Options& options)
{
Expand Down
19 changes: 11 additions & 8 deletions filters/chipper/ChipperFilter.hpp
Expand Up @@ -41,11 +41,15 @@

#pragma once

#include <vector>

#include <pdal/Filter.hpp>
#include <pdal/plugin.h>
#include <pdal/PointBuffer.hpp>

#include <vector>

extern "C" int32_t ChipperFilter_ExitFunc();
extern "C" PF_ExitFunc ChipperFilter_InitPlugin();

namespace pdal
{

Expand Down Expand Up @@ -132,17 +136,16 @@ class PDAL_DLL ChipRefList

class PDAL_DLL ChipperFilter : public pdal::Filter
{
#define CHIPPERDOCS "Organize points into spatially contiguous, squarish, and \n" \
"non-overlapping chips."
public:
SET_STAGE_NAME("filters.chipper", CHIPPERDOCS)
SET_STAGE_LINK("http://pdal.io/stages/filters.chipper.html")

ChipperFilter() : Filter(),
m_xvec(DIR_X), m_yvec(DIR_Y), m_spare(DIR_NONE)
{}

static Options getDefaultOptions();
static void * create();
static int32_t destroy(void *);
std::string getName() const;

Options getDefaultOptions();

private:
virtual void processOptions(const Options& options);
Expand Down
16 changes: 12 additions & 4 deletions filters/colorization/ColorizationFilter.cpp
Expand Up @@ -32,20 +32,28 @@
* OF SUCH DAMAGE.
****************************************************************************/

#include <array>
#include "ColorizationFilter.hpp"

#include <pdal/PointBuffer.hpp>
#include <pdal/GDALUtils.hpp>
#include <pdal/GlobalEnvironment.hpp>
#include <pdal/PointBuffer.hpp>

#include <gdal.h>
#include <ogr_spatialref.h>
#include <pdal/GDALUtils.hpp>

#include "ColorizationFilter.hpp"
#include <array>

namespace pdal
{

static PluginInfo const s_info {
"filters.colorization",
"Fetch and assign RGB color information from a GDAL-readable datasource.",
"http://pdal.io/stages/filters.colorization.html" };

CREATE_STATIC_PLUGIN(ColorizationFilter, Filter, s_info)

std::string ColorizationFilter::getName() const { return s_info.name; }

struct GDALSourceDeleter
{
Expand Down
20 changes: 12 additions & 8 deletions filters/colorization/ColorizationFilter.hpp
Expand Up @@ -35,8 +35,8 @@
#pragma once

#include <pdal/Filter.hpp>
#include <pdal/plugin.h>

#include <map>
#include <boost/array.hpp>

#pragma GCC diagnostic push
Expand All @@ -46,6 +46,11 @@
#include <pdal/GDALUtils.hpp>
#pragma GCC diagnostic pop

#include <map>

extern "C" int32_t ColorizationFilter_ExitFunc();
extern "C" PF_ExitFunc ColorizationFilter_InitPlugin();

namespace pdal
{

Expand All @@ -72,16 +77,15 @@ struct BandInfo
double m_scale;
};

#define COLORIZATIONDOC "Fetch and assign RGB color information from a GDAL-readable " \
"datasource. "
public:
SET_STAGE_NAME("filters.colorization", COLORIZATIONDOC)
SET_STAGE_LINK("http://pdal.io/stages/filters.colorization.html")
ColorizationFilter()
{}

ColorizationFilter() : Filter()
{}
static void * create();
static int32_t destroy(void *);
std::string getName() const;

static Options getDefaultOptions();
Options getDefaultOptions();

private:
virtual void initialize();
Expand Down
10 changes: 10 additions & 0 deletions filters/crop/CropFilter.cpp
Expand Up @@ -36,12 +36,22 @@

#include <pdal/PointBuffer.hpp>
#include <pdal/StageFactory.hpp>

#include <sstream>
#include <cstdarg>

namespace pdal
{

static PluginInfo const s_info {
"filters.crop",
"Filter points inside or outside a bounding box or a polygon if PDAL was built with GEOS support.",
"http://pdal.io/stages/filters.crop.html" };

CREATE_STATIC_PLUGIN(CropFilter, Filter, s_info)

std::string CropFilter::getName() const { return s_info.name; }

#ifdef PDAL_HAVE_GEOS
namespace geos
{
Expand Down
15 changes: 9 additions & 6 deletions filters/crop/CropFilter.hpp
Expand Up @@ -35,28 +35,31 @@
#pragma once

#include <pdal/Filter.hpp>
#include <pdal/plugin.h>

#ifdef PDAL_HAVE_GEOS
#include <geos_c.h>
#endif

extern "C" int32_t CropFilter_ExitFunc();
extern "C" PF_ExitFunc CropFilter_InitPlugin();

namespace pdal
{
class PointBuffer;

#define CROPFILTERDOCS "Filter points inside or outside a bounding box or \n" \
"a polygon if PDAL was built with GEOS support."
// removes any points outside of the given range
// updates the header accordingly
class PDAL_DLL CropFilter : public Filter
{
public:
SET_STAGE_NAME("filters.crop", CROPFILTERDOCS)
SET_STAGE_LINK("http://pdal.io/stages/filters.crop.html")

CropFilter();

static Options getDefaultOptions();
static void * create();
static int32_t destroy(void *);
std::string getName() const;

Options getDefaultOptions();

const BOX3D& getBounds() const;

Expand Down
13 changes: 9 additions & 4 deletions filters/decimation/DecimationFilter.cpp
Expand Up @@ -32,16 +32,21 @@
* OF SUCH DAMAGE.
****************************************************************************/

#include <pdal/PointBuffer.hpp>

#include "DecimationFilter.hpp"

#include <pdal/PointBuffer.hpp>

namespace pdal
{

DecimationFilter::DecimationFilter() : pdal::Filter()
{}
static PluginInfo const s_info {
"filters.decimation",
"Rank decimation filter. Keep every Nth point",
"http://pdal.io/stages/filters.decimation.html" };

CREATE_STATIC_PLUGIN(DecimationFilter, Filter, s_info)

std::string DecimationFilter::getName() const { return s_info.name; }

void DecimationFilter::processOptions(const Options& options)
{
Expand Down
12 changes: 9 additions & 3 deletions filters/decimation/DecimationFilter.hpp
Expand Up @@ -35,6 +35,10 @@
#pragma once

#include <pdal/Filter.hpp>
#include <pdal/plugin.h>

extern "C" int32_t DecimationFilter_ExitFunc();
extern "C" PF_ExitFunc DecimationFilter_InitPlugin();

namespace pdal
{
Expand All @@ -43,10 +47,12 @@ namespace pdal
class PDAL_DLL DecimationFilter : public Filter
{
public:
SET_STAGE_NAME("filters.decimation", "Rank decimation filter. Keep every Nth point.")
SET_STAGE_LINK("http://pdal.io/stages/filters.decimation.html")
DecimationFilter()
{}

DecimationFilter();
static void * create();
static int32_t destroy(void *);
std::string getName() const;

private:
uint32_t m_step;
Expand Down
15 changes: 8 additions & 7 deletions filters/ferry/FerryFilter.cpp
Expand Up @@ -34,15 +34,19 @@

#include "FerryFilter.hpp"

#include <pdal/pdal_export.hpp>

namespace pdal
{

static PluginInfo const s_info {
"filters.ferry",
"Copy date from one dimension to another.",
"http://pdal.io/stages/filters.ferry.html" };

CREATE_STATIC_PLUGIN(FerryFilter, Filter, s_info)

void FerryFilter::initialize()
{
}

std::string FerryFilter::getName() const { return s_info.name; }

Options FerryFilter::getDefaultOptions()
{
Expand Down Expand Up @@ -119,8 +123,5 @@ void FerryFilter::filter(PointBuffer& buffer)
}
}

void FerryFilter::done(PointContext ctx)
{
}

} // namespace pdal
18 changes: 12 additions & 6 deletions filters/ferry/FerryFilter.hpp
Expand Up @@ -35,28 +35,34 @@
#pragma once

#include <pdal/Filter.hpp>
#include <pdal/plugin.h>

#include <map>
#include <string>

extern "C" int32_t FerryFilter_ExitFunc();
extern "C" PF_ExitFunc FerryFilter_InitPlugin();

namespace pdal
{

class PDAL_DLL FerryFilter : public Filter
{
public:
SET_STAGE_NAME("filters.ferry", "Copy data from one dimension to another.")
SET_STAGE_LINK("http://pdal.io/stages/filters.ferry.html")
FerryFilter()
{}

static void * create();
static int32_t destroy(void *);
std::string getName() const;

FerryFilter() : Filter() {};
static Options getDefaultOptions();
Options getDefaultOptions();

private:
virtual void initialize();
virtual void processOptions(const Options&);
virtual void addDimensions(PointContextRef ctx);
virtual void ready(PointContext ctx);
virtual void filter(PointBuffer& buffer);
virtual void done(PointContext ctx);

FerryFilter& operator=(const FerryFilter&); // not implemented
FerryFilter(const FerryFilter&); // not implemented
Expand Down
12 changes: 8 additions & 4 deletions filters/merge/CMakeLists.txt
Expand Up @@ -6,13 +6,17 @@
# Merge Filter
#
set(srcs
MergeFilter.cpp
)

set(incs
MergeFilter.hpp
)

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
DESTINATION "${PDAL_INCLUDE_INSTALL_DIR}"
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)
#install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
# DESTINATION "${PDAL_INCLUDE_INSTALL_DIR}"
# FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
#)

PDAL_ADD_DRIVER(filter merge "${srcs}" "${incs}" objects)
set(PDAL_TARGET_OBJECTS ${PDAL_TARGET_OBJECTS} ${objects} PARENT_SCOPE)

0 comments on commit ab011cf

Please sign in to comment.