Commit 416c3f42c343c7029ef74b8013fe6274b29ce25b
1 parent
45998ba0
Add FlattenTransform to flatten a list of Templates to a single Template
Showing
1 changed file
with
26 additions
and
0 deletions
openbr/plugins/misc.cpp
| @@ -538,6 +538,32 @@ class EventTransform : public UntrainableMetaTransform | @@ -538,6 +538,32 @@ class EventTransform : public UntrainableMetaTransform | ||
| 538 | }; | 538 | }; |
| 539 | BR_REGISTER(Transform, EventTransform) | 539 | BR_REGISTER(Transform, EventTransform) |
| 540 | 540 | ||
| 541 | +/*! | ||
| 542 | + * \ingroup transforms | ||
| 543 | + * \brief Flattens a list of Templates into a single Template | ||
| 544 | + * \author Austin Blanton \cite imaus10 | ||
| 545 | + */ | ||
| 546 | +class FlattenTransform : public UntrainableMetaTransform | ||
| 547 | +{ | ||
| 548 | + Q_OBJECT | ||
| 549 | + | ||
| 550 | + void project(const TemplateList &src, TemplateList &dst) const | ||
| 551 | + { | ||
| 552 | + Template flat; | ||
| 553 | + foreach (const Template &tmpl, src) | ||
| 554 | + flat.append(tmpl); | ||
| 555 | + dst.append(flat); | ||
| 556 | + } | ||
| 557 | + | ||
| 558 | + void project(const Template &src, Template &dst) const | ||
| 559 | + { | ||
| 560 | + (void) src; | ||
| 561 | + (void) dst; | ||
| 562 | + qFatal("You shouldn't do that!"); | ||
| 563 | + } | ||
| 564 | +}; | ||
| 565 | +BR_REGISTER(Transform, FlattenTransform) | ||
| 566 | + | ||
| 541 | } | 567 | } |
| 542 | 568 | ||
| 543 | #include "misc.moc" | 569 | #include "misc.moc" |