face+management: Removing ndnd::Controller and re-designing controllers

As of this commit, there is only one controller: nfd::Controller.
Legacy ndnd-tlv is no longer supported, but it is still possible to use
NFD FIB Management directly (RIB Management commands are used by
default).  To request direct FIB management, one needs to call
Face::setDirectFibManagement(true) or configure protocol variable in the
config file.

Instead of using virtual methods of the controllers, a special
setInterestFilterImpl method will select proper prefix registration
method.  In addition to that, setInterestFilterImpl will also remember
how exactly the prefix should be de-registered, including security
parameters.

Change-Id: If9d4c7e87f6d80b6cb766a4116e04e846a51272d
Refs: #1576, #1577
diff --git a/src/face.hpp b/src/face.hpp
index 1758e27..e524b8b 100644
--- a/src/face.hpp
+++ b/src/face.hpp
@@ -23,14 +23,17 @@
 #include "transport/unix-transport.hpp"
 #include "transport/tcp-transport.hpp"
 
-#include "management/controller.hpp"
-
 #include "util/scheduler.hpp"
 #include "detail/registered-prefix.hpp"
 #include "detail/pending-interest.hpp"
 
 namespace ndn {
 
+namespace nfd {
+class Controller;
+}
+class IdentityCertificate;
+
 /**
  * An OnData function object is used to pass a callback to expressInterest.
  */
@@ -147,11 +150,8 @@
   Face(const shared_ptr<Transport>& transport,
        boost::asio::io_service& ioService);
 
-  /**
-   * @brief Set controller used for prefix registration
-   */
-  void
-  setController(const shared_ptr<Controller>& controller);
+
+  ~Face();
 
   /**
    * @brief Express Interest
@@ -269,18 +269,19 @@
    * even it if has the same prefix name.  If there is no entry with the
    * registeredPrefixId, do nothing.
    *
+   * unsetInterestFilter will use the same credentials as original
+   * setInterestFilter/registerPrefix command
+   *
    * @param registeredPrefixId The ID returned from registerPrefix.
    */
   void
   unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId);
 
+  /**
+   * @brief (FOR DEBUG PURPOSES ONLY) Request direct NFD FIB management
+   */
   void
-  unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId,
-                      const IdentityCertificate& certificate);
-
-  void
-  unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId,
-                      const Name& identity);
+  setDirectFibManagement(bool isDirectFibManagementRequested = false);
 
    /**
    * @brief Publish data packet
@@ -362,9 +363,6 @@
   bool
   isSupportedNrdProtocol(const std::string& protocol);
 
-  bool
-  isSupportedNdndProtocol(const std::string& protocol);
-
   class ProcessEventsTimeout
   {
   };
@@ -387,14 +385,6 @@
   asyncUnsetInterestFilter(const RegisteredPrefixId* registeredPrefixId);
 
   void
-  asyncUnsetInterestFilterWithCertificate(const RegisteredPrefixId* registeredPrefixId,
-                                          const IdentityCertificate& certificate);
-
-  void
-  asyncUnsetInterestFilterWithIdentity(const RegisteredPrefixId* registeredPrefixId,
-                                       const Name& identity);
-
-  void
   finalizeUnregisterPrefix(RegisteredPrefixTable::iterator item);
 
   void
@@ -415,6 +405,13 @@
   void
   checkPitExpire();
 
+  template<class SignatureGenerator>
+  const RegisteredPrefixId*
+  setInterestFilterImpl(const InterestFilter& interestFilter,
+                        const OnInterest& onInterest,
+                        const OnSetInterestFilterFailed& onSetInterestFilterFailed,
+                        const SignatureGenerator& signatureGenerator);
+
 private:
   shared_ptr<boost::asio::io_service> m_ioService;
   shared_ptr<boost::asio::io_service::work> m_ioServiceWork; // if thread needs to be preserved
@@ -428,7 +425,8 @@
   InterestFilterTable m_interestFilterTable;
   RegisteredPrefixTable m_registeredPrefixTable;
 
-  shared_ptr<Controller> m_fwController;
+  nfd::Controller* m_nfdController;
+  bool m_isDirectNfdFibManagementRequested;
 
   ConfigFile m_config;
 };
@@ -445,10 +443,10 @@
   return protocol == "nrd-0.1";
 }
 
-inline bool
-Face::isSupportedNdndProtocol(const std::string& protocol)
+inline void
+Face::setDirectFibManagement(bool isDirectFibManagementRequested/* = false*/)
 {
-  return protocol == "ndnd-tlv-0.7";
+  m_isDirectNfdFibManagementRequested = isDirectFibManagementRequested;
 }
 
 } // namespace ndn