task/plan work

This commit is contained in:
Chris Punches
2017-06-25 02:28:22 -04:00
parent 162a2d5cd4
commit 6fc300a98e
6 changed files with 53 additions and 43 deletions

View File

@@ -1,17 +1,27 @@
#include "Task.h"
Task::Task() {}
/// Task_InvalidDataStructure - Exception thrown when a Task is defined with invalid JSON.
class Task_InvalidDataStructure: public std::runtime_error { public:
Task_InvalidDataStructure(): std::runtime_error("Task: Attempted to access a member of a Task that is not set.") {}
};
Task::Task( Json::Value loader_root )
{
this->load_root( loader_root );
}
/// Task::Task() - Constructor for the Task class. The Task is the building block of a Plan indicating of which Unit to
/// execute, and its dependencies on other units to have already been completed successfully.
Task::Task() {}
int Task::load_root(Json::Value loader_root)
{
this->name = loader_root.get("name", "?").asString();
this->dependencies = loader_root.get("depends on", "");
this->has_succeeded = false;
if ( loader_root.isMember("name") )
{
this->name = loader_root.get("name", "?").asString();
} else {
throw Task_InvalidDataStructure();
}
// this->dependencies = loader_root.get("depends on", "");
//this->has_succeeded = false;
}
std::string Task::get_name()
@@ -19,23 +29,4 @@ std::string Task::get_name()
return this->name;
}
bool Task::isDone()
{
return this->has_succeeded;
}
void Task::finish()
{
this->has_succeeded = true;
}
// returns Json::Value for dependencies
Json::Value Task::get_dependencies()
{
return this->dependencies;
}
Json::Value Task::set_dependencies()
{
}