face: consistently use the template method pattern in ProtocolFactory

Change-Id: Ied0bf02cfcdffc7e9b2c28c5452441c01f98ccbc
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index 5b56839..d77b639 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -34,20 +34,15 @@
 NFD_REGISTER_PROTOCOL_FACTORY(TcpFactory);
 
 const std::string&
-TcpFactory::getId()
+TcpFactory::getId() noexcept
 {
   static std::string id("tcp");
   return id;
 }
 
-TcpFactory::TcpFactory(const CtorParams& params)
-  : ProtocolFactory(params)
-{
-}
-
 void
-TcpFactory::processConfig(OptionalConfigSection configSection,
-                          FaceSystem::ConfigContext& context)
+TcpFactory::doProcessConfig(OptionalConfigSection configSection,
+                            FaceSystem::ConfigContext& context)
 {
   // tcp
   // {
@@ -61,7 +56,7 @@
 
   if (!configSection) {
     if (!context.isDryRun && !m_channels.empty()) {
-      NFD_LOG_WARN("Cannot disable tcp4 and tcp6 channels after initialization");
+      NFD_LOG_WARN("Cannot disable TCP channels after initialization");
     }
     return;
   }
@@ -117,44 +112,44 @@
       "TCP channels or enable at least one channel type."));
   }
 
-  if (!context.isDryRun) {
-    providedSchemes.insert("tcp");
-
-    if (enableV4) {
-      tcp::Endpoint endpoint(ip::tcp::v4(), port);
-      shared_ptr<TcpChannel> v4Channel = this->createChannel(endpoint);
-      if (wantListen && !v4Channel->isListening()) {
-        v4Channel->listen(this->addFace, nullptr);
-      }
-      providedSchemes.insert("tcp4");
-    }
-    else if (providedSchemes.count("tcp4") > 0) {
-      NFD_LOG_WARN("Cannot close tcp4 channel after its creation");
-    }
-
-    if (enableV6) {
-      tcp::Endpoint endpoint(ip::tcp::v6(), port);
-      shared_ptr<TcpChannel> v6Channel = this->createChannel(endpoint);
-      if (wantListen && !v6Channel->isListening()) {
-        v6Channel->listen(this->addFace, nullptr);
-      }
-      providedSchemes.insert("tcp6");
-    }
-    else if (providedSchemes.count("tcp6") > 0) {
-      NFD_LOG_WARN("Cannot close tcp6 channel after its creation");
-    }
-
-    m_local = std::move(local);
+  if (context.isDryRun) {
+    return;
   }
+
+  providedSchemes.insert("tcp");
+
+  if (enableV4) {
+    tcp::Endpoint endpoint(ip::tcp::v4(), port);
+    auto v4Channel = this->createChannel(endpoint);
+    if (wantListen && !v4Channel->isListening()) {
+      v4Channel->listen(this->addFace, nullptr);
+    }
+    providedSchemes.insert("tcp4");
+  }
+  else if (providedSchemes.count("tcp4") > 0) {
+    NFD_LOG_WARN("Cannot close tcp4 channel after its creation");
+  }
+
+  if (enableV6) {
+    tcp::Endpoint endpoint(ip::tcp::v6(), port);
+    auto v6Channel = this->createChannel(endpoint);
+    if (wantListen && !v6Channel->isListening()) {
+      v6Channel->listen(this->addFace, nullptr);
+    }
+    providedSchemes.insert("tcp6");
+  }
+  else if (providedSchemes.count("tcp6") > 0) {
+    NFD_LOG_WARN("Cannot close tcp6 channel after its creation");
+  }
+
+  m_local = std::move(local);
 }
 
 void
-TcpFactory::createFace(const CreateFaceRequest& req,
-                       const FaceCreatedCallback& onCreated,
-                       const FaceCreationFailedCallback& onFailure)
+TcpFactory::doCreateFace(const CreateFaceRequest& req,
+                         const FaceCreatedCallback& onCreated,
+                         const FaceCreationFailedCallback& onFailure)
 {
-  BOOST_ASSERT(req.remoteUri.isCanonical());
-
   if (req.localUri) {
     NFD_LOG_TRACE("Cannot create unicast TCP face with LocalUri");
     onFailure(406, "Unicast TCP faces cannot be created with a LocalUri");
@@ -212,7 +207,7 @@
 }
 
 std::vector<shared_ptr<const Channel>>
-TcpFactory::getChannels() const
+TcpFactory::doGetChannels() const
 {
   return getChannelsFromMap(m_channels);
 }