implemented plan and task

This commit is contained in:
Chris Punches
2017-04-19 01:50:34 -04:00
parent 39a8145744
commit aebdae2cce
8 changed files with 94 additions and 78 deletions

View File

@@ -35,6 +35,7 @@ Json::Value JLoader::get_root()
return this->json_root;
}
Unit::Unit( Json::Value loader_root )
{
this->name = loader_root.get("name", "?").asString();
@@ -45,6 +46,7 @@ Unit::Unit( Json::Value loader_root )
this->required = loader_root.get("required", "?").asString();
this->rectify = loader_root.get("rectify", "?").asString();
}
std::string Unit::get_name() { return this->name; }
std::string Unit::get_target() { return this->target; }
std::string Unit::get_output() { return this->output; }
@@ -62,15 +64,30 @@ UnitHolder::UnitHolder( std::string filename ): JLoader( filename )
for ( int index = 0; index < raw_units.size(); index++ )
{
this->Units.push_back(Unit( raw_units[index] ));
this->units.push_back(Unit( raw_units[index] ));
}
};
Task::Task( Json::Value loader_root )
{
this->name = loader_root.get("name", "?").asString();
this->dependencies = loader_root.get("depends on", "");
}
std::string Task::get_name() { return this->name; }
Json::Value Task::get_dependencies() { return this->dependencies;}
Plan::Plan( std::string filename ): JLoader( filename )
{
// TODO: Implement
Json::Value raw_tasks = this->get_root()["plan"];
for ( int index = 0; index < raw_tasks.size(); index++ )
{
this->tasks.push_back( Task( raw_tasks[index] ) );
}
};
Conf::Conf( std::string filename ): JLoader( filename )
{
this->plan_path = this->get_root()["plan_path"].asString();

View File

@@ -46,18 +46,29 @@ class Unit
class UnitHolder: public JLoader
{
private:
std::vector<Unit> Units;
public:
using JLoader::JLoader;
std::vector<Unit> units;
UnitHolder( std::string filename );
};
class Task
{
private:
std::string name;
Json::Value dependencies;
public:
Task( Json::Value loader_root );
std::string get_name();
Json::Value get_dependencies();
};
class Plan: public JLoader
{
public:
using JLoader::JLoader;
std::vector<Task> tasks;
Plan( std::string filename );
};