From 5c085bd08d5139c566908f470cf06b7e5517e7ac Mon Sep 17 00:00:00 2001
From: Sam Gateau <sam@highfidelity.io>
Date: Tue, 13 Aug 2019 18:58:35 -0700
Subject: [PATCH] CLean the code of the task::COnfig changes

---
 libraries/task/src/task/Config.h              | 126 ++++--------------
 libraries/task/src/task/Task.h                |  12 +-
 .../utilities/lib/jet/qml/TaskList.qml        |   2 +-
 3 files changed, 28 insertions(+), 112 deletions(-)

diff --git a/libraries/task/src/task/Config.h b/libraries/task/src/task/Config.h
index ba17c7418c..193674d152 100644
--- a/libraries/task/src/task/Config.h
+++ b/libraries/task/src/task/Config.h
@@ -161,10 +161,24 @@ public:
     template <class T> typename T::Config* getConfig(std::string jobPath = "") const {
         return dynamic_cast<typename T::Config*>(getJobConfig(jobPath));
     }
-    
+
+    // Describe the node graph data connections of the associated Job/Task
+   /**jsdoc
+    * @function JobConfig.isTask
+    * @returns {boolean}
+    */
     Q_INVOKABLE bool isTask() const { return _isTask; }
+
+    /**jsdoc
+     * @function JobConfig.isSwitch
+     * @returns {boolean}
+     */
     Q_INVOKABLE bool isSwitch() const { return _isSwitch; }
 
+    /**jsdoc
+     * @function JobConfig.getSubConfigs
+     * @returns {object[]}
+     */
     Q_INVOKABLE QObjectList getSubConfigs() const {
         auto list = findChildren<JobConfig*>(QRegExp(".*"), Qt::FindDirectChildrenOnly);
         QObjectList returned;
@@ -173,38 +187,23 @@ public:
         }
         return returned;
     }
+
+    /**jsdoc
+     * @function JobConfig.getNumSubs
+     * @returns {number}
+     */
     Q_INVOKABLE int getNumSubs() const { return getSubConfigs().size(); }
+
+    /**jsdoc
+     * @function JobConfig.getSubConfig
+     * @param {number} index
+     * @returns {object}
+     */
     Q_INVOKABLE QObject* getSubConfig(int i) const {
         auto subs = getSubConfigs();
         return ((i < 0 || i >= subs.size()) ? nullptr : subs[i]);
     }
     
-    // Describe the node graph data connections of the associated Job/Task
-    /**jsdoc
-     * @function Workload.isTask
-     * @returns {boolean}
-     */
-    //Q_INVOKABLE virtual bool isTask() const { return false; }
-
-    /**jsdoc
-     * @function Workload.getSubConfigs
-     * @returns {object[]}
-     */
-  //  Q_INVOKABLE virtual QObjectList getSubConfigs() const { return QObjectList(); }
-
-    /**jsdoc
-     * @function Workload.getNumSubs
-     * @returns {number}
-     */
-   // Q_INVOKABLE virtual int getNumSubs() const { return 0; }
-
-    /**jsdoc
-     * @function Workload.getSubConfig
-     * @param {number} index
-     * @returns {object}
-     */
-    //Q_INVOKABLE virtual QObject* getSubConfig(int i) const { return nullptr; }
-
     void connectChildConfig(std::shared_ptr<JobConfig> childConfig, const std::string& name);
     void transferChildrenConfigs(std::shared_ptr<JobConfig> source);
 
@@ -249,79 +248,6 @@ signals:
 
 using QConfigPointer = std::shared_ptr<JobConfig>;
 
-
-
-#ifdef SPECIALIZE_CONFIG
-/**jsdoc
- * @namespace Workload
- *
- * @hifi-interface
- * @hifi-client-entity
- * @hifi-avatar
- *
- * @property {number} cpuRunTime - <em>Read-only.</em>
- * @property {boolean} enabled
- */
-class TaskConfig : public JobConfig {
-    Q_OBJECT
-
-public:
-    using Persistent = PersistentConfig<TaskConfig>;
-
-    TaskConfig() = default;
-    TaskConfig(bool enabled) : JobConfig(enabled) {}
-
-    /**jsdoc
-     * @function Workload.getConfig
-     * @param {string} name
-     * @returns {object}
-     */
-    // Get a sub job config through task.getConfig(path)
-    // where path can be:
-    // - <job_name> search for the first job named job_name traversing the the sub graph of task and jobs (from this task as root)
-    // - <parent_name>.[<sub_parent_names>.]<job_name>
-    //    Allowing to first look for the parent_name job (from this task as root) and then search from there for the
-    //    optional sub_parent_names and finally from there looking for the job_name (assuming every job in the path were found)
-    //
-    // getter for qml integration, prefer the templated getter
-    Q_INVOKABLE QObject* getConfig(const QString& name) { return getConfig<TConfigProxy>(name.toStdString()); }
-
-    // getter for cpp (strictly typed), prefer this getter
-    TaskConfig* getRootConfig(const std::string& jobPath, std::string& jobName) const;
-    JobConfig* getJobConfig(const std::string& jobPath) const;
-
-    template <class T> typename T::Config* getConfig(std::string jobPath = "") const {
-        return dynamic_cast<typename T::Config*>(getJobConfig(jobPath));
-    }
-
-    Q_INVOKABLE bool isTask() const override { return true; }
-    Q_INVOKABLE QObjectList getSubConfigs() const override {
-        auto list = findChildren<JobConfig*>(QRegExp(".*"), Qt::FindDirectChildrenOnly);
-        QObjectList returned;
-        for (int i = 0; i < list.size(); i++) {
-            returned.push_back(list[i]);
-        }
-        return returned;
-    }
-    Q_INVOKABLE int getNumSubs() const override { return getSubConfigs().size(); }
-    Q_INVOKABLE QObject* getSubConfig(int i) const override {
-        auto subs = getSubConfigs();
-        return ((i < 0 || i >= subs.size()) ? nullptr : subs[i]);
-    }
-};
-
-class SwitchConfig : public JobConfig {
-    Q_OBJECT
-    Q_PROPERTY(int branch READ getBranch WRITE setBranch NOTIFY dirtyEnabled)
-
-public:
-    uint8_t getBranch() const { return _branch; }
-    void setBranch(uint8_t index);
-
-protected:
-    uint8_t _branch { 0 };
-};
-#endif
 }
 
 #endif // hifi_task_Config_h
diff --git a/libraries/task/src/task/Task.h b/libraries/task/src/task/Task.h
index 0871cb5982..4d346480b6 100644
--- a/libraries/task/src/task/Task.h
+++ b/libraries/task/src/task/Task.h
@@ -80,8 +80,7 @@ public:
 
     virtual QConfigPointer& getConfiguration() { return _config; }
     virtual void applyConfiguration() = 0;
-    void setCPURunTime(const std::chrono::nanoseconds& runtime) { 
-        /*std::static_pointer_cast<Config>*/(_config)->setCPURunTime(runtime); }
+    void setCPURunTime(const std::chrono::nanoseconds& runtime) { (_config)->setCPURunTime(runtime); }
 
     QConfigPointer _config;
 protected:
@@ -95,9 +94,6 @@ template <class T, class C> void jobConfigure(T& data, const C& configuration) {
 template<class T> void jobConfigure(T&, const JobConfig&) {
     // nop, as the default JobConfig was used, so the data does not need a configure method
 }
-/*template<class T> void jobConfigure(T&, const TaskConfig&) {
-    // nop, as the default TaskConfig was used, so the data does not need a configure method
-}*/
 
 template <class T, class JC> void jobRun(T& data, const JC& jobContext, const JobNoIO& input, JobNoIO& output) {
     data.run(jobContext);
@@ -296,9 +292,6 @@ public:
                 TimeProfiler probe("build::" + model->getName());
                 model->_data.build(*(model), model->_input, model->_output, std::forward<A>(args)...);
             }
-            // Recreate the Config to use the templated type
-          //  model->createConfiguration();
-          //  model->applyConfiguration();
 
             return model;
         }
@@ -439,9 +432,6 @@ public:
                 TimeProfiler probe("build::" + model->getName());
                 model->_data.build(*(model), model->_input, model->_output, std::forward<A>(args)...);
             }
-            // Recreate the Config to use the templated type
-          //  model->createConfiguration();
-          //  model->applyConfiguration();
 
             return model;
         }
diff --git a/scripts/developer/utilities/lib/jet/qml/TaskList.qml b/scripts/developer/utilities/lib/jet/qml/TaskList.qml
index 0cfd9c049a..e4b0267d3f 100644
--- a/scripts/developer/utilities/lib/jet/qml/TaskList.qml
+++ b/scripts/developer/utilities/lib/jet/qml/TaskList.qml
@@ -31,7 +31,7 @@ Rectangle {
     }
 
     Component.onCompleted: {
-        var message = "sam"
+        var message = ""
         var functor = Jet.job_print_functor(function (line) { message += line + "\n"; }, false, true);
         Jet.task_traverseTree(rootConfig, functor);
         textArea.append(message);