From 1fe0defc7b012d302409b3ebcb371e9193a4b128 Mon Sep 17 00:00:00 2001 From: Chris Punches Date: Sun, 25 Jun 2017 17:36:32 -0400 Subject: [PATCH] worked out dependency type issue --- conf/plans/test.plan | 4 ++-- src/loaders/Plan.cpp | 2 +- src/loaders/Task.cpp | 19 +++++++++++++++++-- src/loaders/Task.h | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/conf/plans/test.plan b/conf/plans/test.plan index 446edb9..666f0c1 100644 --- a/conf/plans/test.plan +++ b/conf/plans/test.plan @@ -1,6 +1,6 @@ { "plan": [ - { "name": "independent test", "depends on": null }, - { "name": "dependent test", "depends on": [ "independent test", null, null ] } + { "name": "independent test", "dependencies": [ null ] }, + { "name": "dependent test", "dependencies": [ "independent test", null, null ] } ] } diff --git a/src/loaders/Plan.cpp b/src/loaders/Plan.cpp index 8ffa620..8032a2d 100644 --- a/src/loaders/Plan.cpp +++ b/src/loaders/Plan.cpp @@ -40,7 +40,7 @@ void Plan::load_plan_file(std::string filename, bool verbose) Task tmp_T; for ( int index = 0; index < this->json_root.size(); index++ ) { - tmp_T.load_root( this->json_root[ index ] ); + tmp_T.load_root( this->json_root[ index ], verbose ); this->tasks.push_back( tmp_T ); if ( verbose ) { std::cout << "Added task \"" << tmp_T.get_name() << "\" to Plan." << std::endl; diff --git a/src/loaders/Task.cpp b/src/loaders/Task.cpp index f24aa90..09d64a9 100644 --- a/src/loaders/Task.cpp +++ b/src/loaders/Task.cpp @@ -13,7 +13,7 @@ Task::Task() {} /// /// \param loader_root /// \return -void Task::load_root(Json::Value loader_root) +void Task::load_root(Json::Value loader_root, bool verbose ) { if ( loader_root.isMember("name") ) { @@ -22,7 +22,22 @@ void Task::load_root(Json::Value loader_root) throw Task_InvalidDataStructure(); } - this->dependencies = loader_root.get("depends on", ""); + // fetch as Json::Value array obj + Json::Value des_dep_root = loader_root.get("dependencies", 0); + + // iterate through each member of that obj + for ( int i = 0; i < des_dep_root.size(); i++ ) + { + // add each string to dependencies + if ( des_dep_root[i].asString() != "" ) + { + this->dependencies.push_back( des_dep_root[i].asString() ); + if ( verbose ) { + std::cout << "Added dependency \"" << des_dep_root[i].asString() << "\" to Task \"" << this->get_name() << "\"." << std::endl; + } + } + } + //this->has_succeeded = false; } diff --git a/src/loaders/Task.h b/src/loaders/Task.h index 3d7f421..d80016a 100644 --- a/src/loaders/Task.h +++ b/src/loaders/Task.h @@ -26,7 +26,7 @@ class Task Task(); // load a json::value into task members (second stage deserialization) - void load_root( Json::Value loader_root ); + void load_root( Json::Value loader_root, bool verbose ); // register a dependency void add_dependency( std::string dependency_name );