diff transform/ModelTransformer.h @ 877:b109b88bfa85 tonioni

Callback handler for additional models at end of processing
author Chris Cannam
date Wed, 29 Jan 2014 15:58:15 +0000
parents 47aa3aeb687b
children 6ea7761a418b
line wrap: on
line diff
--- a/transform/ModelTransformer.h	Wed Jan 29 09:31:22 2014 +0000
+++ b/transform/ModelTransformer.h	Wed Jan 29 15:58:15 2014 +0000
@@ -83,14 +83,42 @@
      * be initialised; an error message may be available via
      * getMessage() in this situation.
      */
-    Models getOutputModels();        
+    Models getOutputModels() { return m_outputs; }
 
     /**
      * Return the set of output models, also detaching them from the
      * transformer so that they will not be deleted when the
      * transformer is.  The caller takes ownership of the models.
      */
-    Models detachOutputModels() { m_detached = true; return getOutputModels(); }
+    Models detachOutputModels() { 
+        m_detached = true; 
+        return getOutputModels(); 
+    }
+
+    /**
+     * Return any additional models that were created during
+     * processing. This might happen if, for example, a transform was
+     * configured to split a multi-bin output into separate single-bin
+     * models as it processed. These should not be queried until after
+     * the transform has completed.
+     */
+    virtual Models getAdditionalOutputModels() { return Models(); }
+
+    /**
+     * Return true if the current transform is one that may produce
+     * additional models (to be retrieved through
+     * getAdditionalOutputModels above).
+     */
+    virtual bool willHaveAdditionalOutputModels() { return false; }
+
+    /**
+     * Return the set of additional models, also detaching them from
+     * the transformer.  The caller takes ownership of the models.
+     */
+    virtual Models detachAdditionalOutputModels() { 
+        m_detachedAdd = true;
+        return getAdditionalOutputModels();
+    }
 
     /**
      * Return a warning or error message.  If getOutputModel returned
@@ -104,18 +132,11 @@
     ModelTransformer(Input input, const Transform &transform);
     ModelTransformer(Input input, const Transforms &transforms);
 
-    /**
-     * Return any additional models that were created during
-     * processing. This might happen if, for example, a transform was
-     * configured to split a multi-bin output into separate single-bin
-     * models as it processed.
-     */
-    virtual Models getAdditionalOutputModels() { return Models(); }
-
     Transforms m_transforms;
     Input m_input; // I don't own the model in this
     Models m_outputs; // I own this, unless...
     bool m_detached; // ... this is true.
+    bool m_detachedAdd;
     bool m_abandoned;
     QString m_message;
 };