data structure seems to be fully implemented

master
Chris Punches 2017-04-19 22:49:39 -04:00
parent e60b959f3b
commit dd49cfe739
7 changed files with 51 additions and 42 deletions

View File

@ -33,8 +33,8 @@
<file leaf-file-name="loaders.h" pinned="false" current-in-tab="false"> <file leaf-file-name="loaders.h" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/loaders.h"> <entry file="file://$PROJECT_DIR$/src/loaders.h">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90"> <state relative-caret-position="306">
<caret line="5" column="24" lean-forward="true" selection-start-line="5" selection-start-column="24" selection-end-line="5" selection-end-column="24" /> <caret line="17" column="12" lean-forward="true" selection-start-line="17" selection-start-column="12" selection-end-line="17" selection-end-column="12" />
<folding> <folding>
<element signature="e#0#2#0" expanded="true" /> <element signature="e#0#2#0" expanded="true" />
</folding> </folding>
@ -69,12 +69,12 @@
<file leaf-file-name="loaders.cpp" pinned="false" current-in-tab="false"> <file leaf-file-name="loaders.cpp" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/loaders.cpp"> <entry file="file://$PROJECT_DIR$/src/loaders.cpp">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1071"> <state relative-caret-position="1111">
<caret line="82" column="20" lean-forward="true" selection-start-line="82" selection-start-column="20" selection-end-line="82" selection-end-column="20" /> <caret line="85" column="0" lean-forward="true" selection-start-line="85" selection-start-column="0" selection-end-line="85" selection-end-column="0" />
<folding> <folding>
<element signature="e#1909#2043#0" expanded="true" /> <element signature="e#1910#2044#0" expanded="true" />
<element signature="e#2287#2348#0" expanded="true" /> <element signature="e#2297#2358#0" expanded="true" />
<element signature="e#3033#3184#0" expanded="true" /> <element signature="e#2991#3142#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -126,8 +126,8 @@
<file leaf-file-name="examplar.cpp" pinned="false" current-in-tab="true"> <file leaf-file-name="examplar.cpp" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/examplar.cpp"> <entry file="file://$PROJECT_DIR$/examplar.cpp">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="234"> <state relative-caret-position="360">
<caret line="13" column="0" lean-forward="false" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" /> <caret line="20" column="80" lean-forward="false" selection-start-line="20" selection-start-column="80" selection-end-line="20" selection-end-column="80" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -477,12 +477,12 @@
<updated>1491540343823</updated> <updated>1491540343823</updated>
<workItem from="1491540345736" duration="17928000" /> <workItem from="1491540345736" duration="17928000" />
<workItem from="1491759279673" duration="614000" /> <workItem from="1491759279673" duration="614000" />
<workItem from="1492298506932" duration="40181000" /> <workItem from="1492298506932" duration="43757000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="58723000" /> <option name="totallyTimeSpent" value="62299000" />
</component> </component>
<component name="TodoView"> <component name="TodoView">
<todo-panel id="selected-file"> <todo-panel id="selected-file">
@ -502,7 +502,7 @@
<window_info id="CMake" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="CMake" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1407334" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1407334" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32903865" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32903865" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1103081" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1103081" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="LuaJ" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="LuaJ" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
@ -657,21 +657,33 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/cmake-build-debug/conf/test.plan">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54">
<caret line="3" column="23" lean-forward="false" selection-start-line="3" selection-start-column="23" selection-end-line="3" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/loaders.h"> <entry file="file://$PROJECT_DIR$/src/loaders.h">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90"> <state relative-caret-position="306">
<caret line="5" column="24" lean-forward="true" selection-start-line="5" selection-start-column="24" selection-end-line="5" selection-end-column="24" /> <caret line="17" column="12" lean-forward="true" selection-start-line="17" selection-start-column="12" selection-end-line="17" selection-end-column="12" />
<folding> <folding>
<element signature="e#0#2#0" expanded="true" /> <element signature="e#0#2#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/cmake-build-debug/conf/test.plan"> <entry file="file://$PROJECT_DIR$/src/loaders.cpp">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54"> <state relative-caret-position="1111">
<caret line="3" column="23" lean-forward="false" selection-start-line="3" selection-start-column="23" selection-end-line="3" selection-end-column="23" /> <caret line="85" column="0" lean-forward="true" selection-start-line="85" selection-start-column="0" selection-end-line="85" selection-end-column="0" />
<folding /> <folding>
<element signature="e#1910#2044#0" expanded="true" />
<element signature="e#2297#2358#0" expanded="true" />
<element signature="e#2991#3142#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
@ -683,22 +695,10 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/loaders.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1071">
<caret line="82" column="20" lean-forward="true" selection-start-line="82" selection-start-column="20" selection-end-line="82" selection-end-column="20" />
<folding>
<element signature="e#1909#2043#0" expanded="true" />
<element signature="e#2287#2348#0" expanded="true" />
<element signature="e#3033#3184#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/examplar.cpp"> <entry file="file://$PROJECT_DIR$/examplar.cpp">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="234"> <state relative-caret-position="360">
<caret line="13" column="0" lean-forward="false" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" /> <caret line="20" column="80" lean-forward="false" selection-start-line="20" selection-start-column="80" selection-end-line="20" selection-end-column="80" />
<folding /> <folding />
</state> </state>
</provider> </provider>

Binary file not shown.

View File

@ -11,7 +11,14 @@ int main()
for ( int i = 0; i < plan.tasks.size(); ++i ) for ( int i = 0; i < plan.tasks.size(); ++i )
{ {
std::cout << unitHolder.select_unit( plan.tasks[i].get_name() ).get_target() << std::endl; std::string current_task_name = plan.tasks[i].get_name();
std::cout << "Found task name:\t" << current_task_name << std::endl << std::endl;
Unit current_unit = unitHolder.select_unit( current_task_name );
std::cout << "Associated Unit name:\t" << current_unit.get_name() << std::endl;
std::cout << "Associated Unit target:\t" << current_unit.get_target() << std::endl;
std::cout << "Associated Unit healer:\t" << current_unit.get_rectifier() << std::endl << std::endl;
} }

View File

@ -47,6 +47,7 @@ Unit::Unit( Json::Value loader_root )
this->rectify = loader_root.get("rectify", "?").asString(); this->rectify = loader_root.get("rectify", "?").asString();
} }
std::string Unit::get_name() { return this->name; } std::string Unit::get_name() { return this->name; }
std::string Unit::get_target() { return this->target; } std::string Unit::get_target() { return this->target; }
std::string Unit::get_output() { return this->output; } std::string Unit::get_output() { return this->output; }
@ -68,21 +69,22 @@ UnitHolder::UnitHolder( std::string filename ): JLoader( filename )
} }
}; };
Unit UnitHolder::select_unit(std::string name) Unit UnitHolder::select_unit(std::string provided_name)
{ {
/* /*
* TODO: Implement fetch unit by name method. * TODO: Implement fetch unit by name method.
*/ */
for ( int i = 0; i < this->units.size(); ++i )
Unit * returnable;
for ( int i = 0; i < this->units.size(); i++ )
{ {
if ( this->units[i].get_name() == name ) std::string unit_name = this->units[i].get_name();
{ if ( unit_name == provided_name ) {
return this->units[i]; returnable = & this->units[i];
} else {
std::cerr << "Logic error in UnitHolder::select_unit. This is a bug. Please report it." << std::endl;
exit(1);
} }
} }
return * returnable;
} }

View File

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