NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
face-table.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_FW_FACE_TABLE_HPP
27 #define NFD_DAEMON_FW_FACE_TABLE_HPP
28 
29 #include "face/face.hpp"
30 #include <boost/range/adaptor/map.hpp>
31 
32 namespace nfd {
33 
34 class Forwarder;
35 
38 class FaceTable : noncopyable
39 {
40 public:
41  explicit
42  FaceTable(Forwarder& forwarder);
43 
45  ~FaceTable();
46 
48  add(shared_ptr<Face> face);
49 
52  addReserved(shared_ptr<Face> face, FaceId faceId);
53 
54  VIRTUAL_WITH_TESTS shared_ptr<Face>
55  get(FaceId id) const;
56 
57  size_t
58  size() const;
59 
60 public: // enumeration
61  typedef std::map<FaceId, shared_ptr<Face>> FaceMap;
62 
63  typedef boost::select_second_const_range<FaceMap> ForwardRange;
64 
67  typedef boost::range_iterator<ForwardRange>::type const_iterator;
68 
69  const_iterator
70  begin() const;
71 
72  const_iterator
73  end() const;
74 
75 public: // signals
79 
85 
86 private:
87  void
88  addImpl(shared_ptr<Face> face, FaceId faceId);
89 
90  // remove is private because it's a handler of face.onFail signal.
91  // face->close() closes the face and triggers .remove()
92  void
93  remove(shared_ptr<Face> face, const std::string& reason);
94 
95  ForwardRange
96  getForwardRange() const;
97 
98 private:
99  Forwarder& m_forwarder;
100  FaceId m_lastFaceId;
101  FaceMap m_faces;
102 };
103 
104 } // namespace nfd
105 
106 #endif // NFD_DAEMON_FW_FACE_TABLE_HPP
boost::range_iterator< ForwardRange >::type const_iterator
ForwardIterator for shared_ptr<Face>
Definition: face-table.hpp:67
const_iterator end() const
Definition: face-table.cpp:125
void add(shared_ptr< Face > face)
Definition: face-table.cpp:59
main class of NFD
Definition: forwarder.hpp:54
provides a lightweight signal / event system
size_t size() const
Definition: face-table.cpp:53
signal::Signal< FaceTable, shared_ptr< Face > > onRemove
fires before a Face is removed
Definition: face-table.hpp:84
std::map< FaceId, shared_ptr< Face > > FaceMap
Definition: face-table.hpp:61
container of all Faces
Definition: face-table.hpp:38
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
#define VIRTUAL_WITH_TESTS
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: common.hpp:37
identifies a face
Forwarder
Definition: forwarder.cpp:38
boost::select_second_const_range< FaceMap > ForwardRange
Definition: face-table.hpp:63
FaceTable(Forwarder &forwarder)
Definition: face-table.cpp:34
void addReserved(shared_ptr< Face > face, FaceId faceId)
add a special Face with a reserved FaceId
Definition: face-table.cpp:72
const_iterator begin() const
Definition: face-table.cpp:119
signal::Signal< FaceTable, shared_ptr< Face > > onAdd
fires after a Face is added
Definition: face-table.hpp:78