face-table.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2019, Regents of the University of California,
4  * Arizona Board of Regents,
5  * Colorado State University,
6  * University Pierre & Marie Curie, Sorbonne University,
7  * Washington University in St. Louis,
8  * Beijing Institute of Technology,
9  * The University of Memphis.
10  *
11  * This file is part of NFD (Named Data Networking Forwarding Daemon).
12  * See AUTHORS.md for complete list of NFD authors and contributors.
13  *
14  * NFD is free software: you can redistribute it and/or modify it under the terms
15  * of the GNU General Public License as published by the Free Software Foundation,
16  * either version 3 of the License, or (at your option) any later version.
17  *
18  * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20  * PURPOSE. See the GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along with
23  * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef NFD_DAEMON_FW_FACE_TABLE_HPP
27 #define NFD_DAEMON_FW_FACE_TABLE_HPP
28 
29 #include "face/face.hpp"
30 
31 #include <boost/range/adaptor/indirected.hpp>
32 #include <boost/range/adaptor/map.hpp>
33 
34 namespace nfd {
35 
38 class FaceTable : noncopyable
39 {
40 public:
41  FaceTable();
42 
48  void
49  add(shared_ptr<Face> face);
50 
53  void
54  addReserved(shared_ptr<Face> face, FaceId faceId);
55 
60  Face*
61  get(FaceId id) const;
62 
65  size_t
66  size() const;
67 
68 public: // enumeration
69  using FaceMap = std::map<FaceId, shared_ptr<Face>>;
70  using ForwardRange = boost::indirected_range<const boost::select_second_const_range<FaceMap>>;
71 
74  using const_iterator = boost::range_iterator<ForwardRange>::type;
75 
77  begin() const;
78 
80  end() const;
81 
82 public: // signals
85  signal::Signal<FaceTable, Face> afterAdd;
86 
91  signal::Signal<FaceTable, Face> beforeRemove;
92 
93 private:
94  void
95  addImpl(shared_ptr<Face> face, FaceId faceId);
96 
97  void
98  remove(FaceId faceId);
99 
101  getForwardRange() const;
102 
103 private:
104  FaceId m_lastFaceId;
105  FaceMap m_faces;
106 };
107 
108 } // namespace nfd
109 
110 #endif // NFD_DAEMON_FW_FACE_TABLE_HPP
boost::indirected_range< const boost::select_second_const_range< FaceMap > > ForwardRange
Definition: face-table.hpp:70
const_iterator end() const
Definition: face-table.cpp:127
container of all faces
Definition: face-table.hpp:38
void addReserved(shared_ptr< Face > face, FaceId faceId)
add a special face with a reserved FaceId
Definition: face-table.cpp:71
std::map< FaceId, shared_ptr< Face > > FaceMap
Definition: face-table.hpp:69
signal::Signal< FaceTable, Face > afterAdd
Fires immediately after a face is added.
Definition: face-table.hpp:85
size_t size() const
Definition: face-table.cpp:52
boost::range_iterator< ForwardRange >::type const_iterator
ForwardIterator for Face&.
Definition: face-table.hpp:74
signal::Signal< FaceTable, Face > beforeRemove
Fires immediately before a face is removed.
Definition: face-table.hpp:91
void add(shared_ptr< Face > face)
add a face
Definition: face-table.cpp:58
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
generalization of a network interface
Definition: face.hpp:54
const_iterator begin() const
Definition: face-table.cpp:121
uint64_t FaceId
Identifies a face.
Definition: face-common.hpp:44