nfdc: strategy-choice, Adding StrategyChoiceManagementOptions

refs: #1312

Change-Id: I20c7d76b7a5740202e194c1016399df3684d63d8
diff --git a/src/management/nfd-controller.cpp b/src/management/nfd-controller.cpp
index 7a99693..19e98f8 100644
--- a/src/management/nfd-controller.cpp
+++ b/src/management/nfd-controller.cpp
@@ -10,6 +10,7 @@
 #include "nfd-controller.hpp"
 #include "nfd-fib-management-options.hpp"
 #include "nfd-face-management-options.hpp"
+#include "nfd-strategy-choice-options.hpp"
 #include "nfd-control-response.hpp"
 
 namespace ndn {
@@ -123,29 +124,73 @@
                               onSuccess, onFail),
                          bind(onFail, "Command Interest timed out"));
 }
-
+  
 void
 Controller::processFaceCommandResponse(Data& data,
                                        const FaceCommandSucceedCallback& onSuccess,
                                        const FailCallback& onFail)
 {
   /// \todo Add validation of incoming Data
-
+  
   try
-    {
-      ControlResponse response(data.getContent().blockFromValue());
-      if (response.getCode() != 200)
-        return onFail(response.getText());
-
-      FaceManagementOptions options(response.getBody());
-      return onSuccess(options);
-    }
+  {
+    ControlResponse response(data.getContent().blockFromValue());
+    if (response.getCode() != 200)
+      return onFail(response.getText());
+    
+    FaceManagementOptions options(response.getBody());
+    return onSuccess(options);
+  }
   catch(ndn::Tlv::Error& e)
-    {
-      if (static_cast<bool>(onFail))
-        return onFail(e.what());
-    }
+  {
+    if (static_cast<bool>(onFail))
+      return onFail(e.what());
+  }
 }
 
+void
+Controller::startStrategyChoiceCommand(const std::string& command,
+                                       const StrategyChoiceOptions& options,
+                                       const StrategyChoiceCommandSucceedCallback& onSuccess,
+                                       const FailCallback& onFail)
+{
+  Name strategyChoiceCommandInterestName("/localhost/nfd/strategy-choice");
+  strategyChoiceCommandInterestName
+    .append(command)
+    .append(options.wireEncode());
+  
+  Interest strategyChoiceCommandInterest(strategyChoiceCommandInterestName);
+  m_commandInterestGenerator.generate(strategyChoiceCommandInterest);
+  
+  m_face.expressInterest(strategyChoiceCommandInterest,
+                         bind(&Controller::processStrategyChoiceCommandResponse, this, _2,
+                              onSuccess, onFail),
+                         bind(onFail, "Command Interest timed out"));
+}
+void
+Controller::processStrategyChoiceCommandResponse(
+    Data& data,
+    const StrategyChoiceCommandSucceedCallback& onSuccess,
+    const FailCallback& onFail)
+{
+  /// \todo Add validation of incoming Data
+  
+  try
+  {
+    ControlResponse response(data.getContent().blockFromValue());
+    if (response.getCode() != 200)
+      return onFail(response.getText());
+    
+    StrategyChoiceOptions options(response.getBody());
+    return onSuccess(options);
+  }
+  catch (ndn::Tlv::Error& error)
+  {
+    if (static_cast<bool>(onFail))
+      return onFail(error.what());
+  }
+}
+
+  
 } // namespace nfd
 } // namespace ndn