diff --git a/design_log/Step_5.md b/design_log/Step_5.md
index 064289f..058d1f3 100644
--- a/design_log/Step_5.md
+++ b/design_log/Step_5.md
@@ -393,6 +393,10 @@ Since I have not had prior exposure to several concepts needed for this task, I
* [Brainstorming (Appendix)](Step_5_Appendix.md#brainstorming)
* [Research (Appendix)](Step_5_Appendix.md#research)
+### Fix for bind issue
+
+* [Bind issue (Appendix)](Step_5_Appendix.md#bind-issue)
+
### Environment
The general environment remains the same as the previous steps.
diff --git a/design_log/Step_5_Appendix.md b/design_log/Step_5_Appendix.md
index 8237931..fd05264 100644
--- a/design_log/Step_5_Appendix.md
+++ b/design_log/Step_5_Appendix.md
@@ -283,15 +283,76 @@ Deciding to manually add the functions in main()
// It looks like C++ is not able to implement a programmatic enumberation of
// a class's public member functions, so I need to do it manually in main().
-
+
+
+
+
+Bind issue
+---
+
+### Hint
+
+Received this email:
+
+> Armaan,
+>
+> Hint on the dispatcher. Bind is required and not static questions.
+
+This was not wholely unexpected. Using static member functions of `Controller` class produced results expected during testing, but did not make use of `std::bind` which was included as a hint in one of the files' headers. It seems logical that some other test conditions which I have not encountered produce unexpected results.
+
+### Issue fix
+
+Problem code:
+
+```c++
+ // Add available command handlers in Controller class to CommandDispatcher manually
+ ///
+ /// \note needs static functions
+ ///
+ /// \todo maybe use std::bind instead to enable using non-static functions.
+ ///
+ command_dispatcher.addCommandHandler( "help", controller.help);
+ command_dispatcher.addCommandHandler( "exit", controller.exit);
+ command_dispatcher.addCommandHandler( "sum_ints", controller.sum_ints);
+ command_dispatcher.addCommandHandler( "query_payload", controller.query_payload);
+ command_dispatcher.addCommandHandler( "mean_ints", controller.mean_ints);
+```
+
+Fixed code:
+
+```c++
+ // bind controller functions to function objects to facilitate map addition
+ //
+ // std::placeholders::_1 refers to first (and only) argument for Controller member
+ // functions of type rapidjson::Value
+ using namespace placeholders;
+
+ auto help_b = std::bind( &Controller::help, controller, _1 );
+ auto exit_b = std::bind( &Controller::exit, controller, _1 );
+ auto sum_ints_b = std::bind( &Controller::sum_ints, controller, _1 );
+ auto query_payload_b = std::bind( &Controller::query_payload, controller, _1 );
+ auto mean_ints_b = std::bind( &Controller::mean_ints, controller, _1 );
+
+ // Add available command handlers in Controller class to CommandDispatcher manually
+ command_dispatcher.addCommandHandler( "help", help_b );
+ command_dispatcher.addCommandHandler( "exit", exit_b);
+ command_dispatcher.addCommandHandler( "sum_ints", sum_ints_b);
+ command_dispatcher.addCommandHandler( "query_payload", query_payload_b);
+ command_dispatcher.addCommandHandler( "mean_ints", mean_ints_b);
+```
+
+This allows all Controller member functions to be non-static.
+
+
+
Reference
---
-### std::function << know this
+### std::function
-### std::bind << need to look up
+### std::bind
* Binds parameters to functions
* Guaranteed to make a copy of argument passed in.
@@ -337,9 +398,9 @@ shell:user$ ./bind.out
source: https://www.youtube.com/watch?v=JtUZmkvroKg
-### std::placeholders << need to look up
+### std::placeholders
-### std::map << know this
+### std::map
key / value pair
@@ -369,7 +430,7 @@ source: https://www.youtube.com/watch?v=6iyzPed7FrM
Note: class template does NOT infer parameter types. Function template does.
-### std::make_pair << need to look up
+### std::make_pair
diff --git a/docs/Step_5/html/index.html b/docs/Step_5/html/index.html
index 7b6d97f..a98a2ee 100644
--- a/docs/Step_5/html/index.html
+++ b/docs/Step_5/html/index.html
@@ -65,28 +65,28 @@
cmake ../
. The build environment will be set up in that directory using the CMakeLists.txt file in the parent directory.TEST_ALL
on line 37 of main.cpp is set to the desired value:true
will cause all test commands to be sent to the dispatcher upon program startup.false
will skip all tests and immediately fall through to a user prompt.make
. Executable will build as dispatcher
../dispatcher
.The general environment remains the same as the previous steps.
Go to the source code of this file.
@@ -164,7 +166,7 @@Definition at line 544 of file main.cpp.
+Definition at line 546 of file main.cpp.
@@ -205,7 +207,7 @@Definition at line 52 of file main.cpp.
+Definition at line 54 of file main.cpp.
@@ -234,7 +236,7 @@Definition at line 68 of file main.cpp.
+Definition at line 70 of file main.cpp.
@@ -252,13 +254,11 @@Definition at line 750 of file main.cpp.
+Definition at line 753 of file main.cpp.
@@ -277,7 +277,7 @@Definition at line 41 of file main.cpp.
@@ -293,7 +293,7 @@Definition at line 107 of file main.cpp.
+Definition at line 109 of file main.cpp.
@@ -309,7 +309,7 @@Definition at line 116 of file main.cpp.
+Definition at line 118 of file main.cpp.
@@ -325,7 +325,7 @@Definition at line 79 of file main.cpp.
+Definition at line 81 of file main.cpp.
@@ -341,7 +341,7 @@Definition at line 33 of file main.cpp.
+Definition at line 35 of file main.cpp.
@@ -357,7 +357,7 @@Definition at line 89 of file main.cpp.
+Definition at line 91 of file main.cpp.
@@ -373,7 +373,7 @@Definition at line 98 of file main.cpp.
+Definition at line 100 of file main.cpp.
@@ -389,7 +389,7 @@Definition at line 171 of file main.cpp.
+Definition at line 173 of file main.cpp.
@@ -405,7 +405,7 @@Definition at line 180 of file main.cpp.
+Definition at line 182 of file main.cpp.
@@ -421,7 +421,7 @@Definition at line 189 of file main.cpp.
+Definition at line 191 of file main.cpp.
@@ -437,7 +437,7 @@Definition at line 198 of file main.cpp.
+Definition at line 200 of file main.cpp.
@@ -453,7 +453,7 @@Definition at line 125 of file main.cpp.
+Definition at line 127 of file main.cpp.
@@ -469,7 +469,7 @@Definition at line 152 of file main.cpp.
+Definition at line 154 of file main.cpp.
@@ -485,7 +485,7 @@Definition at line 161 of file main.cpp.
+Definition at line 163 of file main.cpp.
@@ -501,7 +501,7 @@Definition at line 143 of file main.cpp.
+Definition at line 145 of file main.cpp.
@@ -517,7 +517,7 @@Definition at line 134 of file main.cpp.
+Definition at line 136 of file main.cpp.
@@ -535,7 +535,7 @@Definition at line 39 of file main.cpp.
@@ -553,7 +553,7 @@Definition at line 40 of file main.cpp.
diff --git a/docs/Step_5/html/main_8cpp_source.html b/docs/Step_5/html/main_8cpp_source.html index 6b8e43d..059c224 100644 --- a/docs/Step_5/html/main_8cpp_source.html +++ b/docs/Step_5/html/main_8cpp_source.html @@ -63,44 +63,44 @@Go to the source code of this file.
@@ -160,7 +162,7 @@Definition at line 535 of file main_no_debug.cpp.
+Definition at line 537 of file main_no_debug.cpp.
@@ -190,7 +192,7 @@Definition at line 50 of file main_no_debug.cpp.
+Definition at line 52 of file main_no_debug.cpp.
@@ -208,13 +210,11 @@Definition at line 716 of file main_no_debug.cpp.
+Definition at line 718 of file main_no_debug.cpp.
@@ -231,7 +231,7 @@Definition at line 89 of file main_no_debug.cpp.
+Definition at line 91 of file main_no_debug.cpp.
@@ -247,7 +247,7 @@Definition at line 98 of file main_no_debug.cpp.
+Definition at line 100 of file main_no_debug.cpp.
@@ -263,7 +263,7 @@Definition at line 61 of file main_no_debug.cpp.
+Definition at line 63 of file main_no_debug.cpp.
@@ -279,7 +279,7 @@Definition at line 33 of file main_no_debug.cpp.
+Definition at line 35 of file main_no_debug.cpp.
@@ -295,7 +295,7 @@Definition at line 71 of file main_no_debug.cpp.
+Definition at line 73 of file main_no_debug.cpp.
@@ -311,7 +311,7 @@Definition at line 80 of file main_no_debug.cpp.
+Definition at line 82 of file main_no_debug.cpp.
@@ -327,7 +327,7 @@Definition at line 153 of file main_no_debug.cpp.
+Definition at line 155 of file main_no_debug.cpp.
@@ -343,7 +343,7 @@Definition at line 162 of file main_no_debug.cpp.
+Definition at line 164 of file main_no_debug.cpp.
@@ -359,7 +359,7 @@Definition at line 171 of file main_no_debug.cpp.
+Definition at line 173 of file main_no_debug.cpp.
@@ -375,7 +375,7 @@Definition at line 182 of file main_no_debug.cpp.
+Definition at line 184 of file main_no_debug.cpp.
@@ -391,7 +391,7 @@Definition at line 199 of file main_no_debug.cpp.
+Definition at line 201 of file main_no_debug.cpp.
@@ -407,7 +407,7 @@Definition at line 107 of file main_no_debug.cpp.
+Definition at line 109 of file main_no_debug.cpp.
@@ -423,7 +423,7 @@Definition at line 134 of file main_no_debug.cpp.
+Definition at line 136 of file main_no_debug.cpp.
@@ -439,7 +439,7 @@Definition at line 143 of file main_no_debug.cpp.
+Definition at line 145 of file main_no_debug.cpp.
@@ -455,7 +455,7 @@Definition at line 125 of file main_no_debug.cpp.
+Definition at line 127 of file main_no_debug.cpp.
@@ -471,7 +471,7 @@Definition at line 116 of file main_no_debug.cpp.
+Definition at line 118 of file main_no_debug.cpp.
@@ -489,7 +489,7 @@Definition at line 39 of file main_no_debug.cpp.
@@ -507,7 +507,7 @@Definition at line 40 of file main_no_debug.cpp.
diff --git a/docs/Step_5/html/main__no__debug_8cpp_source.html b/docs/Step_5/html/main__no__debug_8cpp_source.html index aab45ac..dfdb83d 100644 --- a/docs/Step_5/html/main__no__debug_8cpp_source.html +++ b/docs/Step_5/html/main__no__debug_8cpp_source.html @@ -63,42 +63,42 @@