logic error

This commit is contained in:
Chris Punches
2017-04-19 02:27:54 -04:00
parent 6762c10734
commit e60b959f3b
7 changed files with 135 additions and 188 deletions

View File

@@ -68,6 +68,23 @@ UnitHolder::UnitHolder( std::string filename ): JLoader( filename )
}
};
Unit UnitHolder::select_unit(std::string name)
{
/*
* TODO: Implement fetch unit by name method.
*/
for ( int i = 0; i < this->units.size(); ++i )
{
if ( this->units[i].get_name() == name )
{
return this->units[i];
} else {
std::cerr << "Logic error in UnitHolder::select_unit. This is a bug. Please report it." << std::endl;
exit(1);
}
}
}
Task::Task( Json::Value loader_root )
{
@@ -79,6 +96,10 @@ Json::Value Task::get_dependencies() { return this->dependencies;}
Plan::Plan( std::string filename ): JLoader( filename )
{
/* Plan loads a file and deserializes the Unit JSON object to Task types as a vector member
* Plan { vector<Task> }
* TODO: Ensure FIFO order.
*/
Json::Value raw_tasks = this->get_root()["plan"];
for ( int index = 0; index < raw_tasks.size(); index++ )

View File

@@ -50,6 +50,7 @@ class UnitHolder: public JLoader
using JLoader::JLoader;
std::vector<Unit> units;
UnitHolder( std::string filename );
Unit select_unit( std::string name );
};
class Task