diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 107f8ea..438a636 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -30,21 +30,11 @@ - - - - - - - - - - - + - - + + @@ -52,11 +42,11 @@ - + - - + + @@ -66,33 +56,23 @@ - + - - + + - + - - - - - - - - - - - - + + @@ -109,12 +89,12 @@ @@ -457,12 +437,12 @@ 1491540343823 - + - @@ -484,7 +464,7 @@ - + @@ -563,24 +543,6 @@ - - - - - - - - - - - - - - - - - - @@ -718,31 +680,49 @@ + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + - - + + - + - - - - - - - - \ No newline at end of file diff --git a/cmake-build-debug/CMakeFiles/ftests.dir/main.cpp.o b/cmake-build-debug/CMakeFiles/ftests.dir/main.cpp.o index 237d3cc..773e0c9 100644 Binary files a/cmake-build-debug/CMakeFiles/ftests.dir/main.cpp.o and b/cmake-build-debug/CMakeFiles/ftests.dir/main.cpp.o differ diff --git a/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders.cpp.o b/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders.cpp.o index 2240ae9..7c7cb3e 100644 Binary files a/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders.cpp.o and b/cmake-build-debug/CMakeFiles/ftests.dir/src/loaders.cpp.o differ diff --git a/cmake-build-debug/conf/test.plan b/cmake-build-debug/conf/test.plan index 99cbb4d..8b35e85 100644 --- a/cmake-build-debug/conf/test.plan +++ b/cmake-build-debug/conf/test.plan @@ -1,6 +1,6 @@ { "plan": [ { "name": "gcc is present", "depends on": [ null ] }, - { "name": "gcYou are not c can compile", "depends on": [ "gcc is present" ] } + { "name": "gcc can compile", "depends on": [ "gcc is present" ] } ] } \ No newline at end of file diff --git a/cmake-build-debug/ftests b/cmake-build-debug/ftests index cbec02b..c7f929c 100755 Binary files a/cmake-build-debug/ftests and b/cmake-build-debug/ftests differ diff --git a/main.cpp b/main.cpp index 12b09bf..60d4233 100644 --- a/main.cpp +++ b/main.cpp @@ -4,8 +4,16 @@ int main() { - Conf jsonLoader = Conf("config.json"); - UnitHolder units = UnitHolder( jsonLoader.get_units_path() ); + Conf configuration = Conf("config.json"); + UnitHolder unitHolder = UnitHolder( configuration.get_units_path() ); + Plan plan = Plan( configuration.get_plan_path() ); + + for ( int i = 0; i < plan.tasks.size(); ++i ) + { + std::cout << plan.tasks[i].get_name() << std::endl; + } + + return 0; } \ No newline at end of file diff --git a/src/loaders.cpp b/src/loaders.cpp index 932018f..c8c97c9 100644 --- a/src/loaders.cpp +++ b/src/loaders.cpp @@ -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(); diff --git a/src/loaders.h b/src/loaders.h index ef5ed3c..e329b57 100644 --- a/src/loaders.h +++ b/src/loaders.h @@ -46,18 +46,29 @@ class Unit class UnitHolder: public JLoader { - private: - std::vector Units; - public: using JLoader::JLoader; + std::vector 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 tasks; Plan( std::string filename ); };