From 0fa3439949df5d4ad17c81f04159d5d699a17bd3 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Fri, 23 Dec 2016 15:35:28 -0500 Subject: [PATCH] add setOutput for graphics engine tasks --- libraries/render/src/render/Task.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/libraries/render/src/render/Task.h b/libraries/render/src/render/Task.h index 27538127ca..49273d79a5 100644 --- a/libraries/render/src/render/Task.h +++ b/libraries/render/src/render/Task.h @@ -45,8 +45,9 @@ public: } template Varying(const T& data) : _concept(std::make_shared>(data)) {} - template T& edit() { return std::static_pointer_cast>(_concept)->_data; } + template bool canCast() const { return !!std::dynamic_pointer_cast>(_concept); } template const T& get() const { return std::static_pointer_cast>(_concept)->_data; } + template T& edit() { return std::static_pointer_cast>(_concept)->_data; } // access potential sub varyings contained in this one. @@ -440,6 +441,9 @@ template void jobConfigure(T& data, const C& configuration) { template void jobConfigure(T&, const JobConfig&) { // nop, as the default JobConfig was used, so the data does not need a configure method } +template void jobConfigure(T&, const TaskConfig&) { + // nop, as the default TaskConfig was used, so the data does not need a configure method +} template void jobRun(T& data, const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const JobNoIO& input, JobNoIO& output) { data.run(sceneContext, renderContext); } @@ -591,22 +595,20 @@ class Task { public: using Config = TaskConfig; using QConfigPointer = Job::QConfigPointer; - using None = Job::None; - template class Model : public Job::Concept { + template class Model : public Job::Concept { public: using Data = T; - using Input = None; - using Output = O; + using Config = C; + using Input = Job::None; Data _data; - Varying _output; - const Varying getOutput() const override { return _output; } + const Varying getOutput() const override { return _data._output; } template Model(const Varying& input, A&&... args) : - Concept(nullptr), _data(Data(std::forward(args)...)), _output(Output()) { + Concept(nullptr), _data(Data(std::forward(args)...)) { // Recreate the Config to use the templated type _data.template createConfiguration(); _config = _data.getConfiguration(); @@ -626,7 +628,7 @@ public: } } }; - template using ModelO = Model; + template using ModelO = Model; using Jobs = std::vector; @@ -652,6 +654,10 @@ public: return addJob(name, input, std::forward(args)...); } + template void setOutput(O&& output) { + _output = Varying(output); + } + template void createConfiguration() { auto config = std::make_shared(); if (_config) { @@ -692,10 +698,11 @@ public: } protected: - template friend class Model; + template friend class Model; QConfigPointer _config; Jobs _jobs; + Varying _output; }; }