util: replace EventEmitter with Signal in NotificationSubscriber
refs #2350
Breaks: nfd:commit:04cf5a99d93d8f64571753260e71ade90332f860
Breaks: nlsr:commit:c2e51f6b6b85a602275dd59bfaaa0fa0403e0978
Change-Id: I54e9b8b8f8d172826616b33e8363cd27a1c53917
diff --git a/src/util/notification-subscriber.hpp b/src/util/notification-subscriber.hpp
index 32d9d6a..ca997b7 100644
--- a/src/util/notification-subscriber.hpp
+++ b/src/util/notification-subscriber.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2014 Regents of the University of California.
+ * Copyright (c) 2013-2015 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -48,8 +48,8 @@
#ifndef NDN_UTIL_NOTIFICATION_SUBSCRIBER_HPP
#define NDN_UTIL_NOTIFICATION_SUBSCRIBER_HPP
-#include "event-emitter.hpp"
#include "../face.hpp"
+#include "signal.hpp"
#include "concepts.hpp"
#include <boost/concept_check.hpp>
@@ -135,15 +135,15 @@
/** \brief fires when a Notification is received
* \note Removing all handlers will cause the subscriber to stop.
*/
- EventEmitter<Notification> onNotification;
+ signal::Signal<NotificationSubscriber, Notification> onNotification;
/** \brief fires when no Notification is received within .getInterestLifetime period
*/
- EventEmitter<> onTimeout;
+ signal::Signal<NotificationSubscriber> onTimeout;
/** \brief fires when a Data packet in the Notification Stream cannot be decoded as Notification
*/
- EventEmitter<Data> onDecodeError;
+ signal::Signal<NotificationSubscriber, Data> onDecodeError;
private:
void
diff --git a/tests/unit-tests/util/notification-subscriber.cpp b/tests/unit-tests/util/notification-subscriber.cpp
index 96f5bf4..643daf0 100644
--- a/tests/unit-tests/util/notification-subscriber.cpp
+++ b/tests/unit-tests/util/notification-subscriber.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2014 Regents of the University of California.
+ * Copyright (c) 2013-2015 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -97,12 +97,6 @@
}
void
- clearNotificationHandlers()
- {
- subscriber.onNotification.clear();
- }
-
- void
afterTimeout()
{
hasTimeout = true;
@@ -155,6 +149,7 @@
util::NotificationStream<SimpleNotification> notificationStream;
shared_ptr<DummyClientFace> subscriberFace;
util::NotificationSubscriber<SimpleNotification> subscriber;
+ util::signal::Connection notificationConn;
uint64_t lastDeliveredSeqNo;
@@ -171,9 +166,10 @@
subscriber.start();
BOOST_REQUIRE_EQUAL(subscriber.isRunning(), false);
- subscriber.onNotification += bind(&EndToEndFixture::afterNotification, this, _1);
- subscriber.onTimeout += bind(&EndToEndFixture::afterTimeout, this);
- subscriber.onDecodeError += bind(&EndToEndFixture::afterDecodeError, this, _1);
+ notificationConn = subscriber.onNotification.connect(
+ bind(&EndToEndFixture::afterNotification, this, _1));
+ subscriber.onTimeout.connect(bind(&EndToEndFixture::afterTimeout, this));
+ subscriber.onDecodeError.connect(bind(&EndToEndFixture::afterDecodeError, this, _1));
// not received when subscriber is not running
this->deliverNotification("n1");
@@ -231,7 +227,7 @@
BOOST_CHECK(this->hasInitialRequest());
// stop if handlers are cleared
- subscriber.onNotification += bind(&EndToEndFixture::clearNotificationHandlers, this);
+ notificationConn.disconnect();
subscriberFace->sentInterests.clear();
this->deliverNotification("n5");
advanceClocks(time::milliseconds(1));