mirror of
https://github.com/lubosz/overte.git
synced 2025-04-13 13:13:19 +02:00
remove 'HelloWorld' stubbery
This commit is contained in:
parent
7a684058b5
commit
b512f7e1ba
2 changed files with 3 additions and 50 deletions
|
@ -20,36 +20,14 @@
|
|||
|
||||
namespace workload {
|
||||
|
||||
// the "real Job"
|
||||
class HelloWorld {
|
||||
QString _message;
|
||||
bool _isEnabled { true };
|
||||
public:
|
||||
using JobModel = Job::Model<HelloWorld, HelloWorldConfig>;
|
||||
HelloWorld() {}
|
||||
void configure(const HelloWorldConfig& configuration) {
|
||||
_isEnabled = configuration.isEnabled();
|
||||
_message = configuration.getMessage();
|
||||
}
|
||||
void run(const WorkloadContextPointer& context) {
|
||||
if (_isEnabled) {
|
||||
std::cout << _message.toStdString() << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
WorkloadContext::WorkloadContext(const SpacePointer& space) : task::JobContext(trace_workload()), _space(space) {}
|
||||
|
||||
using EngineModel = Task::Model<class HelloWorldBuilder>;
|
||||
using EngineModel = Task::Model<class EngineBuilder>;
|
||||
|
||||
// the 'Builder' is the 'Data' on which the EngineModel templatizes.
|
||||
// It must implement build() which is called by EngineModel::create().
|
||||
class HelloWorldBuilder {
|
||||
class EngineBuilder {
|
||||
public:
|
||||
using JobModel = Task::Model<EngineModel>;
|
||||
void build(EngineModel& model, const Varying& in, Varying& out) {
|
||||
model.addJob<HelloWorld>("helloWorld");
|
||||
|
||||
auto classifications = model.addJob<ClassificationTracker>("classificationTracker");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
|
||||
namespace workload {
|
||||
|
||||
// How to make an Engine under the task::Task<C> paradigm...
|
||||
|
||||
// (1) Derive class C from task::JobContext
|
||||
class WorkloadContext : public task::JobContext {
|
||||
public:
|
||||
WorkloadContext(const SpacePointer& space);
|
||||
|
@ -34,40 +31,18 @@ namespace workload {
|
|||
|
||||
SpacePointer _space;
|
||||
};
|
||||
using WorkloadContextPointer = std::shared_ptr<WorkloadContext>;
|
||||
|
||||
// (2) Apply a macro which will create local aliases (via "using") for example:
|
||||
// using Task = task::Task<C>;
|
||||
using WorkloadContextPointer = std::shared_ptr<WorkloadContext>;
|
||||
Task_DeclareTypeAliases(WorkloadContext)
|
||||
|
||||
// (3) You'll need a 'real Job' but it will need a Config for exposing settings to JS,
|
||||
// and you should do that here:
|
||||
class HelloWorldConfig : public Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString message READ getMessage WRITE setMessage)
|
||||
QString _message {"Hello World."};
|
||||
public:
|
||||
HelloWorldConfig() : Job::Config(true) {}
|
||||
QString getMessage() const { return _message; }
|
||||
void setMessage(const QString& msg) { _message = msg; }
|
||||
};
|
||||
|
||||
// (4) In cpp file the 'real Job' will need a 'builder'. The 'builder' is the 'Data' argument
|
||||
// for the Model template.
|
||||
// Data must implement Data::build().
|
||||
// Data::build() is called when the Model is added (in Engine ctor) as the first child job of the Engine
|
||||
|
||||
// (5) Engine derives from task::Task<C> and will run all the Job<C>'s
|
||||
class Engine : public Task {
|
||||
public:
|
||||
Engine(const WorkloadContextPointer& context);
|
||||
~Engine() = default;
|
||||
|
||||
// (6) The Engine's Context is passed to its Jobs when they are run()
|
||||
void run() { assert(_context); run(_context); }
|
||||
|
||||
protected:
|
||||
// (6) Again, the Engine's Context is passed to its Jobs when they are run()
|
||||
void run(const WorkloadContextPointer& context) override { assert(_context); Task::run(_context); }
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue