face: replace EventEmitter usage with Signal

refs #2300

Change-Id: I17d0d65d2c474b17dd9f23f271a6144b0b4fbc07
diff --git a/tests/daemon/mgmt/fib-manager.cpp b/tests/daemon/mgmt/fib-manager.cpp
index 525dfc8..c5a437a 100644
--- a/tests/daemon/mgmt/fib-manager.cpp
+++ b/tests/daemon/mgmt/fib-manager.cpp
@@ -241,9 +241,9 @@
 
   shared_ptr<Interest> command = makeInterest("/localhost/nfd/fib");
 
-  face->onReceiveData += [this, command] (const Data& response) {
+  face->onReceiveData.connect([this, command] (const Data& response) {
     this->validateControlResponse(response, command->getName(), 400, "Malformed command");
-  };
+  });
 
   face->sendInterest(*command);
   g_io.run_one();
@@ -259,9 +259,9 @@
 
   Interest command("/localhost/nfd/fib");
 
-  face->onReceiveData += [this, command] (const Data& response) {
+  face->onReceiveData.connect([this, command] (const Data& response) {
     this->validateControlResponse(response, command.getName(), 400, "Malformed command");
-  };
+  });
 
   getFibManager().onFibRequest(command);
 
@@ -286,9 +286,9 @@
   shared_ptr<Interest> command(make_shared<Interest>(commandName));
   generateCommand(*command);
 
-  face->onReceiveData += [this, command] (const Data& response) {
+  face->onReceiveData.connect([this, command] (const Data& response) {
     this->validateControlResponse(response, command->getName(), 501, "Unsupported command");
-  };
+  });
 
   getFibManager().onFibRequest(*command);
 
@@ -314,9 +314,9 @@
 
   Interest command(commandName);
 
-  face->onReceiveData += [this, command] (const Data& response) {
+  face->onReceiveData.connect([this, command] (const Data& response) {
     this->validateControlResponse(response, command.getName(), 401, "Signature required");
-  };
+  });
 
   getFibManager().onFibRequest(command);
 
@@ -344,9 +344,9 @@
   shared_ptr<Interest> command(make_shared<Interest>(commandName));
   generateCommand(*command);
 
-  face->onReceiveData += [this, command] (const Data& response) {
+  face->onReceiveData.connect([this, command] (const Data& response) {
     this->validateControlResponse(response, command->getName(), 403, "Unauthorized command");
-  };
+  });
 
   getFibManager().onFibRequest(*command);
 
@@ -367,9 +367,9 @@
   shared_ptr<Interest> command(make_shared<Interest>(commandName));
   generateCommand(*command);
 
-  face->onReceiveData += [this, command] (const Data& response) {
+  face->onReceiveData.connect([this, command] (const Data& response) {
     this->validateControlResponse(response, command->getName(), 400, "Malformed command");
-  };
+  });
 
   getFibManager().onFibRequest(*command);
 
@@ -396,9 +396,9 @@
   shared_ptr<Interest> command(make_shared<Interest>(commandName));
   generateCommand(*command);
 
-  face->onReceiveData += [this, command] (const Data& response) {
+  face->onReceiveData.connect([this, command] (const Data& response) {
     this->validateControlResponse(response, command->getName(), 410, "Face not found");
-  };
+  });
 
   getFibManager().onFibRequest(*command);
 
@@ -436,17 +436,18 @@
     command->setIncomingFaceId(1);
     generateCommand(*command);
 
-    face->onReceiveData += [this, command, encodedExpectedParameters] (const Data& response) {
-      this->validateControlResponse(response, command->getName(),
-                                    200, "Success", encodedExpectedParameters);
-    };
+    signal::Connection conn = face->onReceiveData.connect(
+        [this, command, encodedExpectedParameters] (const Data& response) {
+          this->validateControlResponse(response, command->getName(),
+                                        200, "Success", encodedExpectedParameters);
+        });
 
     getFibManager().onFibRequest(*command);
 
     BOOST_REQUIRE(didCallbackFire());
     BOOST_REQUIRE(addedNextHopWithFace(getFib(), "/hello", 0, 101, getFace(1)));
 
-    face->onReceiveData.clear();
+    conn.disconnect();
     getFib().erase("/hello");
     BOOST_REQUIRE_EQUAL(getFib().size(), 0);
   }
@@ -472,10 +473,10 @@
   shared_ptr<Interest> command(make_shared<Interest>(commandName));
   generateCommand(*command);
 
-  face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
+  face->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
     this->validateControlResponse(response, command->getName(),
                                   200, "Success", encodedParameters);
-  };
+  });
 
   getFibManager().onFibRequest(*command);
 
@@ -507,10 +508,10 @@
   resultParameters.setFaceId(1);
   resultParameters.setCost(0);
 
-  face->onReceiveData += [this, command, resultParameters] (const Data& response) {
+  face->onReceiveData.connect([this, command, resultParameters] (const Data& response) {
     this->validateControlResponse(response, command->getName(),
                                   200, "Success", resultParameters.wireEncode());
-  };
+  });
 
   getFibManager().onFibRequest(*command);
 
@@ -540,10 +541,11 @@
       shared_ptr<Interest> command(make_shared<Interest>(commandName));
       generateCommand(*command);
 
-      face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
-        this->validateControlResponse(response, command->getName(),
-                                      200, "Success", encodedParameters);
-      };
+      signal::Connection conn = face->onReceiveData.connect(
+          [this, command, encodedParameters] (const Data& response) {
+            this->validateControlResponse(response, command->getName(),
+                                          200, "Success", encodedParameters);
+          });
 
       getFibManager().onFibRequest(*command);
       BOOST_REQUIRE(didCallbackFire());
@@ -564,7 +566,7 @@
           BOOST_FAIL("Failed to find expected fib entry");
         }
 
-      face->onReceiveData.clear();
+      conn.disconnect();
     }
 }
 
@@ -589,18 +591,19 @@
     shared_ptr<Interest> command(make_shared<Interest>(commandName));
     generateCommand(*command);
 
-    face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
-      this->validateControlResponse(response, command->getName(),
-                                    200, "Success", encodedParameters);
-    };
+    signal::Connection conn = face->onReceiveData.connect(
+        [this, command, encodedParameters] (const Data& response) {
+          this->validateControlResponse(response, command->getName(),
+                                        200, "Success", encodedParameters);
+        });
 
     getFibManager().onFibRequest(*command);
 
     BOOST_REQUIRE(didCallbackFire());
-  }
 
-  resetCallbackFired();
-  face->onReceiveData.clear();
+    resetCallbackFired();
+    conn.disconnect();
+  }
 
   {
     parameters.setCost(102);
@@ -614,10 +617,10 @@
     shared_ptr<Interest> command(make_shared<Interest>(commandName));
     generateCommand(*command);
 
-    face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
+    face->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
       this->validateControlResponse(response, command->getName(),
                                     200, "Success", encodedParameters);
-    };
+    });
 
     getFibManager().onFibRequest(*command);
 
@@ -661,9 +664,9 @@
   shared_ptr<Interest> command(make_shared<Interest>(commandName));
   generateCommand(*command);
 
-  face->onReceiveData += [this, command] (const Data& response) {
+  face->onReceiveData.connect([this, command] (const Data& response) {
     this->validateControlResponse(response, command->getName(), 400, "Malformed command");
-  };
+  });
 
   getFibManager().onFibRequest(*command);
 
@@ -705,17 +708,18 @@
   shared_ptr<Interest> command(make_shared<Interest>(commandName));
   fixture->generateCommand(*command);
 
-  face->onReceiveData += [fixture, command, encodedParameters] (const Data& response) {
-    fixture->validateControlResponse(response, command->getName(),
-                                     200, "Success", encodedParameters);
-  };
+  signal::Connection conn = face->onReceiveData.connect(
+      [fixture, command, encodedParameters] (const Data& response) {
+        fixture->validateControlResponse(response, command->getName(),
+                                         200, "Success", encodedParameters);
+      });
 
   manager.onFibRequest(*command);
 
   BOOST_REQUIRE(fixture->didCallbackFire());
 
   fixture->resetCallbackFired();
-  face->onReceiveData.clear();
+  conn.disconnect();
 }
 
 BOOST_AUTO_TEST_CASE(RemoveNextHop)
@@ -767,10 +771,10 @@
   shared_ptr<Interest> command(make_shared<Interest>(commandName));
   generateCommand(*command);
 
-  face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
+  face->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
     this->validateControlResponse(response, command->getName(),
                                   200, "Success", encodedParameters);
-  };
+  });
 
   getFibManager().onFibRequest(*command);
 
@@ -796,10 +800,10 @@
   shared_ptr<Interest> command(make_shared<Interest>(commandName));
   generateCommand(*command);
 
-  face->onReceiveData += [this, command, encodedParameters] (const Data& response) {
+  face->onReceiveData.connect([this, command, encodedParameters] (const Data& response) {
     this->validateControlResponse(response, command->getName(),
                                   200, "Success", encodedParameters);
-  };
+  });
 
   getFibManager().onFibRequest(*command);
 
@@ -824,9 +828,9 @@
   shared_ptr<Interest> command(make_shared<Interest>(commandName));
   generateCommand(*command);
 
-  face->onReceiveData += [this, command] (const Data& response) {
+  face->onReceiveData.connect([this, command] (const Data& response) {
     this->validateControlResponse(response, command->getName(), 400, "Malformed command");
-  };
+  });
 
   getFibManager().onFibRequest(*command);
 
@@ -859,16 +863,17 @@
     resultParameters.setFaceId(1);
     resultParameters.setName("/hello");
 
-    face->onReceiveData += [this, command, resultParameters] (const Data& response) {
-      this->validateControlResponse(response, command->getName(),
-                                    200, "Success", resultParameters.wireEncode());
-    };
+    signal::Connection conn = face->onReceiveData.connect(
+        [this, command, resultParameters] (const Data& response) {
+          this->validateControlResponse(response, command->getName(),
+                                        200, "Success", resultParameters.wireEncode());
+        });
 
     getFibManager().onFibRequest(*command);
 
     BOOST_REQUIRE(didCallbackFire());
 
-    face->onReceiveData.clear();
+    conn.disconnect();
   }
 }
 
@@ -905,8 +910,8 @@
 
   ndn::EncodingBuffer buffer;
 
-  m_face->onReceiveData +=
-    bind(&FibEnumerationPublisherFixture::decodeFibEntryBlock, this, _1);
+  m_face->onReceiveData.connect(bind(&FibEnumerationPublisherFixture::decodeFibEntryBlock,
+                                     this, _1));
 
   shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/fib/list"));