Commit 8f903c523ec14a9a86f477267002c23477db4175

Authored by Scott Klum
1 parent 515eb7f4

Added Schrodinger

Showing 1 changed file with 37 additions and 0 deletions
openbr/plugins/meta.cpp
... ... @@ -783,6 +783,43 @@ public:
783 783 };
784 784 BR_REGISTER(Transform, DistributeTemplateTransform)
785 785  
  786 +/*!
  787 + * \ingroup transforms
  788 + * \brief Generates two templates, one of which is passed through a transform and the other
  789 + * is not. No cats were harmed in the making of this transform.
  790 + * \author Scott Klum \cite sklum
  791 + */
  792 +class SchrodingerTransform : public MetaTransform
  793 +{
  794 + Q_OBJECT
  795 + Q_PROPERTY(br::Transform* transform READ get_transform WRITE set_transform RESET reset_transform)
  796 + BR_PROPERTY(br::Transform*, transform, NULL)
  797 +
  798 +public:
  799 + void train(const TemplateList &data)
  800 + {
  801 + transform->train(data);
  802 + }
  803 +
  804 + void project(const TemplateList &src, TemplateList &dst) const
  805 + {
  806 + foreach(const Template &t, src) {
  807 + dst.append(t);
  808 + Template u;
  809 + transform->project(t,u);
  810 + dst.append(u);
  811 + }
  812 + }
  813 +
  814 + void project(const Template &src, Template &dst) const {
  815 + TemplateList temp;
  816 + project(TemplateList() << src, temp);
  817 + if (!temp.isEmpty()) dst = temp.first();
  818 + }
  819 +
  820 +};
  821 +BR_REGISTER(Transform, SchrodingerTransform)
  822 +
786 823 } // namespace br
787 824  
788 825 #include "meta.moc"
... ...