From 8ff480b0de728d03f2a61f73fd9b05a3f19c8622 Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Wed, 3 Apr 2013 21:24:08 -0400 Subject: [PATCH] Rename pseudoCopy to smartCopy, add additional comments --- openbr/openbr_plugin.h | 8 +++++++- openbr/plugins/meta.cpp | 6 +++--- openbr/plugins/openbr_internal.h | 18 ++++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index c029efa..482a69b 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -1085,7 +1085,13 @@ public: return dst; } - virtual Transform * pseudoCopy() { return this;} + /*! + * \brief Perform the minimum amount of work necessary to make a + * transform that can be used safely from a different thread than this + * transform. For transforms that aren't time-varying, nothing needs to be + * done, returning this is sufficient. + */ + virtual Transform * smartCopy() { return this;} protected: Transform(bool independent = true, bool trainable = true); /*!< \brief Construct a transform. */ diff --git a/openbr/plugins/meta.cpp b/openbr/plugins/meta.cpp index daebfa0..7a462f6 100644 --- a/openbr/plugins/meta.cpp +++ b/openbr/plugins/meta.cpp @@ -600,7 +600,7 @@ public: virtual Transform *make() const { - return basis->pseudoCopy(); + return basis->smartCopy(); } }; @@ -647,13 +647,13 @@ class DistributeTemplateTransform : public MetaTransform public: - Transform * pseudoCopy() + Transform * smartCopy() { if (!transform->timeVarying()) return this; DistributeTemplateTransform * output = new DistributeTemplateTransform; - output->transform = transform->pseudoCopy(); + output->transform = transform->smartCopy(); return output; } diff --git a/openbr/plugins/openbr_internal.h b/openbr/plugins/openbr_internal.h index 38c2b41..7c992b6 100644 --- a/openbr/plugins/openbr_internal.h +++ b/openbr/plugins/openbr_internal.h @@ -72,7 +72,11 @@ public: } } - virtual Transform * pseudoCopy() + /*! + *\brief For transforms that don't do any training, this default implementation + * which creates a new copy of the Transform from its description string is sufficient. + */ + virtual Transform * smartCopy() { return this->clone(); } @@ -128,7 +132,13 @@ public: } } - Transform * pseudoCopy() + /*! + * \brief Composite transforms need to create a copy of themselves if they + * have any time-varying children. If this object is flagged as time-varying, + * it creates a new copy of its own class, and gives that copy the child transforms + * returned by calling smartCopy on this transforms children + */ + Transform * smartCopy() { if (!timeVarying()) return this; @@ -144,10 +154,10 @@ public: foreach(Transform* t, transforms ) { - Transform * maybe_copy = t->pseudoCopy(); + Transform * maybe_copy = t->smartCopy(); if (maybe_copy->parent() == NULL) maybe_copy->setParent(output); - output->transforms.append(t->pseudoCopy()); + output->transforms.append(t->smartCopy()); } output->file = this->file; -- libgit2 0.21.4