core: use markers in StatusDataset and NotificationStream

This commit also refactors FaceMonitor as generic NotificationSubscriber,
and refactors AutoregServer to use FaceMonitor.

refs #1837 #1838

Change-Id: I8b40dfae118853d1224c8290cf92e7cc0daa116f
diff --git a/core/event-emitter.hpp b/core/event-emitter.hpp
index 35925f9..e63e111 100644
--- a/core/event-emitter.hpp
+++ b/core/event-emitter.hpp
@@ -1,11 +1,12 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014  Regents of the University of California,
- *                     Arizona Board of Regents,
- *                     Colorado State University,
- *                     University Pierre & Marie Curie, Sorbonne University,
- *                     Washington University in St. Louis,
- *                     Beijing Institute of Technology
+ * Copyright (c) 2014,  Regents of the University of California,
+ *                      Arizona Board of Regents,
+ *                      Colorado State University,
+ *                      University Pierre & Marie Curie, Sorbonne University,
+ *                      Washington University in St. Louis,
+ *                      Beijing Institute of Technology,
+ *                      The University of Memphis
  *
  * This file is part of NFD (Named Data Networking Forwarding Daemon).
  * See AUTHORS.md for complete list of NFD authors and contributors.
@@ -20,7 +21,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
 
 #ifndef NFD_CORE_EVENT_EMITTER_HPP
 #define NFD_CORE_EVENT_EMITTER_HPP
@@ -29,25 +30,27 @@
 
 namespace nfd {
 
-struct empty {};
+struct empty
+{
+};
 
 /** \class EventEmitter
  *  \brief provides a lightweight event system
  *
  *  To declare an event:
- *    EventEmitter<TArgs> m_eventName;
+ *    EventEmitter<TArgs> onEventName;
  *  To subscribe to an event:
- *    eventSource->m_eventName += eventHandler;
+ *    eventSource->onEventName += eventHandler;
  *    Multiple functions can subscribe to the same event.
  *  To trigger an event:
- *    m_eventName(args);
+ *    onEventName(args);
  *  To clear event subscriptions:
- *    m_eventName.clear();
+ *    onEventName.clear();
  */
 
 // four arguments
 template<typename T1 = empty, typename T2 = empty,
-    typename T3 = empty, typename T4 = empty>
+         typename T3 = empty, typename T4 = empty>
 class EventEmitter : noncopyable
 {
 public:
@@ -199,6 +202,8 @@
   std::vector<Handler>::iterator it;
   for (it = m_handlers.begin(); it != m_handlers.end(); ++it) {
     (*it)();
+    if (m_handlers.empty()) // .clear has been called
+      return;
   }
 }
 
@@ -232,6 +237,8 @@
   typename std::vector<Handler>::iterator it;
   for (it = m_handlers.begin(); it != m_handlers.end(); ++it) {
     (*it)(a1);
+    if (m_handlers.empty()) // .clear has been called
+      return;
   }
 }
 
@@ -266,6 +273,8 @@
   typename std::vector<Handler>::iterator it;
   for (it = m_handlers.begin(); it != m_handlers.end(); ++it) {
     (*it)(a1, a2);
+    if (m_handlers.empty()) // .clear has been called
+      return;
   }
 }
 
@@ -300,6 +309,8 @@
   typename std::vector<Handler>::iterator it;
   for (it = m_handlers.begin(); it != m_handlers.end(); ++it) {
     (*it)(a1, a2, a3);
+    if (m_handlers.empty()) // .clear has been called
+      return;
   }
 }
 
@@ -334,6 +345,8 @@
   typename std::vector<Handler>::iterator it;
   for (it = m_handlers.begin(); it != m_handlers.end(); ++it) {
     (*it)(a1, a2, a3, a4);
+    if (m_handlers.empty()) // .clear has been called
+      return;
   }
 }