From b512f7e1ba98985176f998eeeca95c981f47054e Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 21 Feb 2018 15:25:38 -0800 Subject: [PATCH] remove 'HelloWorld' stubbery --- libraries/workload/src/workload/Engine.cpp | 26 ++------------------- libraries/workload/src/workload/Engine.h | 27 +--------------------- 2 files changed, 3 insertions(+), 50 deletions(-) diff --git a/libraries/workload/src/workload/Engine.cpp b/libraries/workload/src/workload/Engine.cpp index ab4634cb97..70566fe704 100644 --- a/libraries/workload/src/workload/Engine.cpp +++ b/libraries/workload/src/workload/Engine.cpp @@ -20,36 +20,14 @@ namespace workload { - // the "real Job" - class HelloWorld { - QString _message; - bool _isEnabled { true }; - public: - using JobModel = Job::Model; - 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; + using EngineModel = Task::Model; - // 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; void build(EngineModel& model, const Varying& in, Varying& out) { - model.addJob("helloWorld"); - auto classifications = model.addJob("classificationTracker"); } }; diff --git a/libraries/workload/src/workload/Engine.h b/libraries/workload/src/workload/Engine.h index fdcb49b863..aa45b03a20 100644 --- a/libraries/workload/src/workload/Engine.h +++ b/libraries/workload/src/workload/Engine.h @@ -24,9 +24,6 @@ namespace workload { - // How to make an Engine under the task::Task 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; - // (2) Apply a macro which will create local aliases (via "using") for example: - // using Task = task::Task; + using WorkloadContextPointer = std::shared_ptr; 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 and will run all the Job'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: