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/indirected.hpp>
31 #include <boost/range/adaptor/map.hpp>
32 
33 namespace nfd {
34 
37 class FaceTable : noncopyable
38 {
39 public:
40  FaceTable();
41 
47  void
48  add(shared_ptr<Face> face);
49 
52  void
53  addReserved(shared_ptr<Face> face, FaceId faceId);
54 
59  Face*
60  get(FaceId id) const;
61 
64  size_t
65  size() const;
66 
67 public: // enumeration
68  using FaceMap = std::map<FaceId, shared_ptr<Face>>;
69  using ForwardRange = boost::indirected_range<const boost::select_second_const_range<FaceMap>>;
70 
73  using const_iterator = boost::range_iterator<ForwardRange>::type;
74 
76  begin() const;
77 
79  end() const;
80 
81 public: // signals
84  signal::Signal<FaceTable, Face&> afterAdd;
85 
90  signal::Signal<FaceTable, Face&> beforeRemove;
91 
92 private:
93  void
94  addImpl(shared_ptr<Face> face, FaceId faceId);
95 
96  void
97  remove(FaceId faceId);
98 
100  getForwardRange() const;
101 
102 private:
103  FaceId m_lastFaceId;
104  FaceMap m_faces;
105 };
106 
107 } // namespace nfd
108 
109 #endif // NFD_DAEMON_FW_FACE_TABLE_HPP
container of all faces
Definition: face-table.hpp:37
size_t size() const
Definition: face-table.cpp:51
void addReserved(shared_ptr< Face > face, FaceId faceId)
add a special face with a reserved FaceId
Definition: face-table.cpp:70
boost::range_iterator< ForwardRange >::type const_iterator
ForwardIterator for Face&.
Definition: face-table.hpp:73
const_iterator begin() const
Definition: face-table.cpp:120
boost::indirected_range< const boost::select_second_const_range< FaceMap >> ForwardRange
Definition: face-table.hpp:69
void add(shared_ptr< Face > face)
add a face
Definition: face-table.cpp:57
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
std::map< FaceId, shared_ptr< Face >> FaceMap
Definition: face-table.hpp:68
signal::Signal< FaceTable, Face & > beforeRemove
fires before a face is removed
Definition: face-table.hpp:90
signal::Signal< FaceTable, Face & > afterAdd
fires after a face is added
Definition: face-table.hpp:84
uint64_t FaceId
identifies a face
Definition: face.hpp:39
const_iterator end() const
Definition: face-table.cpp:126