worked out dependency type issue

master
Chris Punches 2017-06-25 17:36:32 -04:00
parent 03ff5150ac
commit 1fe0defc7b
4 changed files with 21 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"plan": [ "plan": [
{ "name": "independent test", "depends on": null }, { "name": "independent test", "dependencies": [ null ] },
{ "name": "dependent test", "depends on": [ "independent test", null, null ] } { "name": "dependent test", "dependencies": [ "independent test", null, null ] }
] ]
} }

View File

@ -40,7 +40,7 @@ void Plan::load_plan_file(std::string filename, bool verbose)
Task tmp_T; Task tmp_T;
for ( int index = 0; index < this->json_root.size(); index++ ) 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 ); this->tasks.push_back( tmp_T );
if ( verbose ) { if ( verbose ) {
std::cout << "Added task \"" << tmp_T.get_name() << "\" to Plan." << std::endl; std::cout << "Added task \"" << tmp_T.get_name() << "\" to Plan." << std::endl;

View File

@ -13,7 +13,7 @@ Task::Task() {}
/// ///
/// \param loader_root /// \param loader_root
/// \return /// \return
void Task::load_root(Json::Value loader_root) void Task::load_root(Json::Value loader_root, bool verbose )
{ {
if ( loader_root.isMember("name") ) if ( loader_root.isMember("name") )
{ {
@ -22,7 +22,22 @@ void Task::load_root(Json::Value loader_root)
throw Task_InvalidDataStructure(); 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; //this->has_succeeded = false;
} }

View File

@ -26,7 +26,7 @@ class Task
Task(); Task();
// load a json::value into task members (second stage deserialization) // 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 // register a dependency
void add_dependency( std::string dependency_name ); void add_dependency( std::string dependency_name );