task/plan work
parent
162a2d5cd4
commit
6fc300a98e
|
@ -12,12 +12,12 @@ int main( )
|
||||||
// load the configuration file which contains filepaths to definitions of a plan and definitions of units.
|
// load the configuration file which contains filepaths to definitions of a plan and definitions of units.
|
||||||
std::string definitions_file = configuration.get_units_path();
|
std::string definitions_file = configuration.get_units_path();
|
||||||
std::string plan_file = configuration.get_plan_path();
|
std::string plan_file = configuration.get_plan_path();
|
||||||
// std::cout << definitions_file << std::endl << plan_file << std::endl;
|
|
||||||
|
|
||||||
Suite available_definitions;
|
Suite available_definitions;
|
||||||
available_definitions.load_units_file( definitions_file, verbose );
|
available_definitions.load_units_file( definitions_file, verbose );
|
||||||
|
|
||||||
Plan plan;
|
Plan plan;
|
||||||
|
plan.load_plan_file( plan_file, verbose );
|
||||||
|
|
||||||
/* for ( int i = 0; i < plan.num_tasks(); ++i )
|
/* for ( int i = 0; i < plan.num_tasks(); ++i )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "Plan.h"
|
#include "Plan.h"
|
||||||
|
|
||||||
/// Plan_InvalidTaskIndex - Exception thrown when a Plan tries to access a contained Task's value by index not present
|
/// Plan_InvalidTaskIndex - Exception thrown when a Plan tries to access a contained Task's value by index not present
|
||||||
/// in the Unit.
|
/// in the Unit.
|
||||||
class Plan_InvalidTaskIndex: public std::runtime_error { public:
|
class Plan_InvalidTaskIndex: public std::runtime_error { public:
|
||||||
|
@ -12,7 +11,6 @@ class Plan_InvalidTaskName: public std::runtime_error { public:
|
||||||
Plan_InvalidTaskName(): std::runtime_error("Plan: Attempted to access a Task using an invalid name.") {}
|
Plan_InvalidTaskName(): std::runtime_error("Plan: Attempted to access a Task using an invalid name.") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Plan::Plan() - Constructor for Plan class. A Plan is a managed container for a Task vector. These tasks reference
|
/// Plan::Plan() - Constructor for Plan class. A Plan is a managed container for a Task vector. These tasks reference
|
||||||
/// Units that are defined in the Units files (Suite). If Units are definitions, Tasks are selections of those
|
/// Units that are defined in the Units files (Suite). If Units are definitions, Tasks are selections of those
|
||||||
/// definitions to execute, and if Units together form a Suite, Tasks together form a Plan.
|
/// definitions to execute, and if Units together form a Suite, Tasks together form a Plan.
|
||||||
|
|
|
@ -16,13 +16,20 @@ class Plan: public JSON_Loader
|
||||||
public:
|
public:
|
||||||
Plan();
|
Plan();
|
||||||
|
|
||||||
|
// append this->tasks from JSON file
|
||||||
void load_plan_file( std::string filename, bool verbose );
|
void load_plan_file( std::string filename, bool verbose );
|
||||||
|
|
||||||
|
// fetch a task from this->tasks
|
||||||
void get_task( Task & result, std::string provided_name, bool verbose );
|
void get_task( Task & result, std::string provided_name, bool verbose );
|
||||||
|
|
||||||
void get_task( Task & result, int index. bool verbose );
|
// fetch a task from this->tasks
|
||||||
|
void get_task( Task & result, int index, bool verbose );
|
||||||
|
|
||||||
void get_unit_from_task(Unit & result, Task input, bool verbose );
|
// load unit definitions from a provided suite and import them into individual tasks
|
||||||
|
// void load_definitions( Suite unit_definitions );
|
||||||
|
|
||||||
|
// fetch a corresponding Unit to a Task
|
||||||
|
// void get_definition_from_task(Unit & result, Task input, bool verbose );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FTESTS_PLAN_H
|
#endif //FTESTS_PLAN_H
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
class Suite: public JSON_Loader
|
class Suite: public JSON_Loader
|
||||||
{
|
{
|
||||||
private:
|
protected:
|
||||||
// storage for the definitions we are amassing from the unit definition files
|
// storage for the definitions we are amassing from the unit definition files
|
||||||
std::vector<Unit> units;
|
std::vector<Unit> units;
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,27 @@
|
||||||
#include "Task.h"
|
#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 )
|
/// 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.
|
||||||
this->load_root( loader_root );
|
Task::Task() {}
|
||||||
}
|
|
||||||
|
|
||||||
int Task::load_root(Json::Value loader_root)
|
int Task::load_root(Json::Value loader_root)
|
||||||
{
|
{
|
||||||
this->name = loader_root.get("name", "?").asString();
|
if ( loader_root.isMember("name") )
|
||||||
this->dependencies = loader_root.get("depends on", "");
|
{
|
||||||
this->has_succeeded = false;
|
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()
|
std::string Task::get_name()
|
||||||
|
@ -19,23 +29,4 @@ std::string Task::get_name()
|
||||||
return this->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()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -7,24 +7,38 @@
|
||||||
|
|
||||||
class Task
|
class Task
|
||||||
{
|
{
|
||||||
private:
|
protected:
|
||||||
|
// the name of this task
|
||||||
std::string name;
|
std::string name;
|
||||||
Json::Value dependencies;
|
|
||||||
bool has_succeeded;
|
// names of tasks that must have successfully executed before this task can execute its own unit.
|
||||||
|
std::vector<std::string> dependencies;
|
||||||
|
|
||||||
|
// private member to store the definition of this task once found in a Suite by Plan.
|
||||||
|
// populated by load_definition
|
||||||
|
Unit definition;
|
||||||
|
|
||||||
|
// the status of this task
|
||||||
|
bool complete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Task( Json::Value loader_root );
|
// constructor
|
||||||
Task();
|
Task();
|
||||||
|
|
||||||
|
// load a json::value into task members (second stage deserialization)
|
||||||
int load_root( Json::Value loader_root );
|
int load_root( Json::Value loader_root );
|
||||||
|
|
||||||
std::string get_name();
|
// register a dependency
|
||||||
Json::Value get_dependencies();
|
void add_dependency( std::string dependency_name );
|
||||||
Json::Value set_dependencies();
|
|
||||||
|
|
||||||
// appends associated_unit as child member
|
// appends definition unit as child member
|
||||||
bool isDone();
|
void load_definition( Unit definition );
|
||||||
void finish();
|
|
||||||
|
|
||||||
|
bool is_complete();
|
||||||
|
|
||||||
|
// fetch the name of a task
|
||||||
|
std::string get_name();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FTESTS_TASK_H
|
#endif //FTESTS_TASK_H
|
||||||
|
|
Loading…
Reference in New Issue