From 416c3f42c343c7029ef74b8013fe6274b29ce25b Mon Sep 17 00:00:00 2001 From: Austin Van Blanton Date: Wed, 31 Jul 2013 14:25:36 -0400 Subject: [PATCH] Add FlattenTransform to flatten a list of Templates to a single Template --- openbr/plugins/misc.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+), 0 deletions(-) diff --git a/openbr/plugins/misc.cpp b/openbr/plugins/misc.cpp index 567fa0d..d79208b 100644 --- a/openbr/plugins/misc.cpp +++ b/openbr/plugins/misc.cpp @@ -538,6 +538,32 @@ class EventTransform : public UntrainableMetaTransform }; BR_REGISTER(Transform, EventTransform) +/*! + * \ingroup transforms + * \brief Flattens a list of Templates into a single Template + * \author Austin Blanton \cite imaus10 + */ +class FlattenTransform : public UntrainableMetaTransform +{ + Q_OBJECT + + void project(const TemplateList &src, TemplateList &dst) const + { + Template flat; + foreach (const Template &tmpl, src) + flat.append(tmpl); + dst.append(flat); + } + + void project(const Template &src, Template &dst) const + { + (void) src; + (void) dst; + qFatal("You shouldn't do that!"); + } +}; +BR_REGISTER(Transform, FlattenTransform) + } #include "misc.moc" -- libgit2 0.21.4