NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
channel-status-publisher.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
27 
28 #include "core/logger.hpp"
30 #include "face/channel.hpp"
31 
32 #include <ndn-cxx/management/nfd-channel-status.hpp>
33 
34 namespace nfd {
35 
36 NFD_LOG_INIT("ChannelStatusPublisher");
37 
38 
40  AppFace& face,
41  const Name& prefix,
42  ndn::KeyChain& keyChain)
43  : SegmentPublisher(face, prefix, keyChain)
44  , m_factories(factories)
45 {
46 
47 }
48 
49 
51 {
52 
53 }
54 
55 size_t
56 ChannelStatusPublisher::generate(ndn::EncodingBuffer& outBuffer)
57 {
58  size_t totalLength = 0;
59  std::set<shared_ptr<ProtocolFactory> > seenFactories;
60 
61  for (FactoryMap::const_iterator i = m_factories.begin();
62  i != m_factories.end(); ++i)
63  {
64  const shared_ptr<ProtocolFactory>& factory = i->second;
65 
66  if (seenFactories.find(factory) != seenFactories.end())
67  {
68  continue;
69  }
70  seenFactories.insert(factory);
71 
72  std::list<shared_ptr<const Channel> > channels = factory->getChannels();
73 
74  for (std::list<shared_ptr<const Channel> >::const_iterator j = channels.begin();
75  j != channels.end(); ++j)
76  {
77  ndn::nfd::ChannelStatus entry;
78  entry.setLocalUri((*j)->getUri().toString());
79 
80  totalLength += entry.wireEncode(outBuffer);
81  }
82  }
83 
84  return totalLength;
85 }
86 
87 } // namespace nfd
provides a publisher of Status Dataset or other segmented octet stream
virtual size_t generate(ndn::EncodingBuffer &outBuffer)
In a derived class, write the octets into outBuffer.
ChannelStatusPublisher(const FactoryMap &factories, AppFace &face, const Name &prefix, ndn::KeyChain &keyChain)
std::map< std::string, shared_ptr< ProtocolFactory > > FactoryMap
#define NFD_LOG_INIT(name)
Definition: logger.hpp:33