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
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 
70  begin() const;
71 
73  end() const;
74 
75 public: // signals
78  signal::Signal<FaceTable, shared_ptr<Face>> onAdd;
79 
84  signal::Signal<FaceTable, shared_ptr<Face>> onRemove;
85 
86 private:
87  void
88  addImpl(shared_ptr<Face> face, FaceId faceId);
89 
90  // remove is private because it's a subscriber of face.onFail event.
91  // face->close() closes a face and triggers .remove(face)
92  void
93  remove(shared_ptr<Face> face);
94 
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
Definition: face-table.hpp:67
const_iterator end() const
Definition: face-table.cpp:133
void add(shared_ptr< Face > face)
Definition: face-table.cpp:59
main class of NFD
Definition: forwarder.hpp:54
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
identifies a face
Forwarder
Definition: forwarder.cpp:36
boost::select_second_const_range< FaceMap > ForwardRange
Definition: face-table.hpp:63
#define VIRTUAL_WITH_TESTS
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.
Definition: common.hpp:37
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:127
signal::Signal< FaceTable, shared_ptr< Face > > onAdd
fires after a Face is added
Definition: face-table.hpp:78