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/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index c8bc267..b31f841 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -119,7 +119,7 @@
, m_faceTable(faceTable)
, m_faceStatusPublisher(m_faceTable, *m_face, FACES_LIST_DATASET_PREFIX, keyChain)
, m_channelStatusPublisher(m_factories, *m_face, CHANNELS_LIST_DATASET_PREFIX, keyChain)
- , m_notificationStream(m_face, FACE_EVENTS_PREFIX, keyChain)
+ , m_notificationStream(*m_face, FACE_EVENTS_PREFIX, keyChain)
, m_signedVerbDispatch(SIGNED_COMMAND_VERBS,
SIGNED_COMMAND_VERBS +
(sizeof(SIGNED_COMMAND_VERBS) / sizeof(SignedVerbAndProcessor)))
diff --git a/daemon/mgmt/face-manager.hpp b/daemon/mgmt/face-manager.hpp
index ec5decf..6a3994e 100644
--- a/daemon/mgmt/face-manager.hpp
+++ b/daemon/mgmt/face-manager.hpp
@@ -27,11 +27,11 @@
#define NFD_DAEMON_MGMT_FACE_MANAGER_HPP
#include "common.hpp"
+#include "core/notification-stream.hpp"
#include "face/local-face.hpp"
#include "mgmt/manager-base.hpp"
#include "mgmt/face-status-publisher.hpp"
#include "mgmt/channel-status-publisher.hpp"
-#include "mgmt/notification-stream.hpp"
#include <ndn-cxx/management/nfd-control-parameters.hpp>
#include <ndn-cxx/management/nfd-control-response.hpp>
@@ -174,7 +174,7 @@
FaceTable& m_faceTable;
FaceStatusPublisher m_faceStatusPublisher;
ChannelStatusPublisher m_channelStatusPublisher;
- NotificationStream m_notificationStream;
+ NotificationStream<AppFace> m_notificationStream;
typedef function<void(FaceManager*,
const Interest&,
diff --git a/daemon/mgmt/notification-stream.hpp b/daemon/mgmt/notification-stream.hpp
deleted file mode 100644
index 06c3b5a..0000000
--- a/daemon/mgmt/notification-stream.hpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- 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,
- * 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.
- *
- * NFD is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * 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_DAEMON_MGMT_NOTIFICATION_STREAM_HPP
-#define NFD_DAEMON_MGMT_NOTIFICATION_STREAM_HPP
-
-#include "mgmt/app-face.hpp"
-
-namespace nfd {
-
-class NotificationStream
-{
-public:
- NotificationStream(shared_ptr<AppFace> face, const Name& prefix, ndn::KeyChain& keyChain);
-
- ~NotificationStream();
-
- template <typename T> void
- postNotification(const T& notification);
-
-private:
- shared_ptr<AppFace> m_face;
- const Name m_prefix;
- uint64_t m_sequenceNo;
- ndn::KeyChain& m_keyChain;
-};
-
-inline
-NotificationStream::NotificationStream(shared_ptr<AppFace> face,
- const Name& prefix,
- ndn::KeyChain& keyChain)
- : m_face(face)
- , m_prefix(prefix)
- , m_sequenceNo(0)
- , m_keyChain(keyChain)
-{
-}
-
-template <typename T>
-inline void
-NotificationStream::postNotification(const T& notification)
-{
- Name dataName(m_prefix);
- dataName.appendSegment(m_sequenceNo);
- shared_ptr<Data> data(make_shared<Data>(dataName));
- data->setContent(notification.wireEncode());
- data->setFreshnessPeriod(time::seconds(1));
-
- m_keyChain.sign(*data);
- m_face->put(*data);
-
- ++m_sequenceNo;
-}
-
-inline
-NotificationStream::~NotificationStream()
-{
-}
-
-} // namespace nfd
-
-
-#endif // NFD_DAEMON_MGMT_NOTIFICATION_STREAM_HPP