mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 01:24:03 +02:00
add setOutput for graphics engine tasks
This commit is contained in:
parent
8d63067fa5
commit
0fa3439949
1 changed files with 17 additions and 10 deletions
|
@ -45,8 +45,9 @@ public:
|
|||
}
|
||||
template <class T> Varying(const T& data) : _concept(std::make_shared<Model<T>>(data)) {}
|
||||
|
||||
template <class T> T& edit() { return std::static_pointer_cast<Model<T>>(_concept)->_data; }
|
||||
template <class T> bool canCast() const { return !!std::dynamic_pointer_cast<Model<T>>(_concept); }
|
||||
template <class T> const T& get() const { return std::static_pointer_cast<const Model<T>>(_concept)->_data; }
|
||||
template <class T> T& edit() { return std::static_pointer_cast<Model<T>>(_concept)->_data; }
|
||||
|
||||
|
||||
// access potential sub varyings contained in this one.
|
||||
|
@ -440,6 +441,9 @@ 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> 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 T, class C = Config, class O = None> class Model : public Job::Concept {
|
||||
template <class T, class C = Config> 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 <class... A>
|
||||
Model(const Varying& input, A&&... args) :
|
||||
Concept(nullptr), _data(Data(std::forward<A>(args)...)), _output(Output()) {
|
||||
Concept(nullptr), _data(Data(std::forward<A>(args)...)) {
|
||||
// Recreate the Config to use the templated type
|
||||
_data.template createConfiguration<C>();
|
||||
_config = _data.getConfiguration();
|
||||
|
@ -626,7 +628,7 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
template <class T, class O, class C = Config> using ModelO = Model<T, C, O>;
|
||||
template <class T, class C = Config> using ModelO = Model<T, C>;
|
||||
|
||||
using Jobs = std::vector<Job>;
|
||||
|
||||
|
@ -652,6 +654,10 @@ public:
|
|||
return addJob<T>(name, input, std::forward<A>(args)...);
|
||||
}
|
||||
|
||||
template <class O> void setOutput(O&& output) {
|
||||
_output = Varying(output);
|
||||
}
|
||||
|
||||
template <class C> void createConfiguration() {
|
||||
auto config = std::make_shared<C>();
|
||||
if (_config) {
|
||||
|
@ -692,10 +698,11 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
template <class T, class C, class O> friend class Model;
|
||||
template <class T, class C> friend class Model;
|
||||
|
||||
QConfigPointer _config;
|
||||
Jobs _jobs;
|
||||
Varying _output;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue