From 27969c3c2715bd64b01ba72452ffd0c2671ef415 Mon Sep 17 00:00:00 2001 From: Chris Punches Date: Sun, 25 Jun 2017 18:50:14 -0400 Subject: [PATCH] impl all units loading in plan -- working --- examplar.cpp | 23 +---------------------- src/loaders/Plan.cpp | 17 +++++++++++++++++ src/loaders/Plan.h | 2 +- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/examplar.cpp b/examplar.cpp index d765017..a6c88b2 100644 --- a/examplar.cpp +++ b/examplar.cpp @@ -19,28 +19,7 @@ int main( ) Plan plan; plan.load_plan_file( plan_file, verbose ); -/* for ( int i = 0; i < plan.num_tasks(); ++i ) - { - Task current_task = plan.get_task( i ); - - Unit current_unit = unit_definitions->get_unit( current_task.get_name() ); - - std::cout << "Found task name in \"" << configuration.get_plan_path() << "\":\t" << current_task.get_name() << std::endl << std::endl; - - std::cout << "Associated Unit name:\t\t" << current_unit.get_name() << std::endl; - std::cout << "Associated Unit target:\t\t" << current_unit.get_target() << std::endl; - std::cout << "Associated Unit healer:\t\t" << current_unit.get_rectifier() << std::endl; - std::cout << "Associated Unit heals:\t\t" << current_unit.get_rectify() << std::endl; - - Json::Value deps = current_task.get_dependencies(); - - for ( int j = 0; j < deps.size(); ++j ) - { - std::cout << "Associated Dependency:\t\t" << deps[j] << std::endl; - } - std::cout << std::endl; - } -*/ + plan.load_definitions( available_definitions, verbose ); return 0; } \ No newline at end of file diff --git a/src/loaders/Plan.cpp b/src/loaders/Plan.cpp index 8032a2d..a412d42 100644 --- a/src/loaders/Plan.cpp +++ b/src/loaders/Plan.cpp @@ -86,4 +86,21 @@ void Plan::get_task(Task & result, std::string provided_name, bool verbose) std::cerr << "Task name \"" << provided_name << "\" was referenced but not defined!" << std::endl; throw Plan_InvalidTaskName(); } +} + +/// Plan::load_definitions - Load the units corresponding to each task in plan from the given Suite. +void Plan::load_definitions( Suite unit_definitions, bool verbose ) +{ + // placeholder Unit + Unit tmp_U; + + // for every task in the plan: + for (int i = 0; i < this->tasks.size(); i++ ) + { + // load the tmp_U corresponding to that task name + unit_definitions.get_unit( tmp_U, this->tasks[i].get_name() ); + + // then have that task attach a copy of tmp_U + this->tasks[i].load_definition( tmp_U, verbose ); + } } \ No newline at end of file diff --git a/src/loaders/Plan.h b/src/loaders/Plan.h index b5ccc02..aaad95d 100644 --- a/src/loaders/Plan.h +++ b/src/loaders/Plan.h @@ -25,7 +25,7 @@ class Plan: public JSON_Loader void get_task( Task & result, int index, bool verbose ); // load unit definitions from a provided suite and import them into individual tasks - void load_definitions( Suite unit_definitions ); + void load_definitions( Suite unit_definitions, bool verbose ); // fetch a corresponding Unit to a Task void get_definition_from_task(Unit & result, Task input, bool verbose );