NFD: Named Data Networking Forwarding Daemon 24.07-28-gdcc0e6e0
Loading...
Searching...
No Matches
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-2024, 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#include <map>
35
36namespace nfd {
37
41class FaceTable : noncopyable
42{
43public:
49 void
50 add(shared_ptr<Face> face);
51
54 void
55 addReserved(shared_ptr<Face> face, FaceId faceId);
56
61 Face*
62 get(FaceId id) const noexcept;
63
66 size_t
67 size() const noexcept;
68
69public: // enumeration
70 using FaceMap = std::map<FaceId, shared_ptr<Face>>;
71 using ForwardRange = boost::indirected_range<const boost::select_second_const_range<FaceMap>>;
72 using const_iterator = boost::range_iterator<ForwardRange>::type;
73
75 begin() const;
76
78 end() const;
79
80public: // signals
83 signal::Signal<FaceTable, Face> afterAdd;
84
89 signal::Signal<FaceTable, Face> beforeRemove;
90
91private:
92 void
93 addImpl(shared_ptr<Face> face, FaceId faceId);
94
95 void
96 remove(FaceId faceId);
97
99 getForwardRange() const;
100
101private:
102 FaceId m_lastFaceId = face::FACEID_RESERVED_MAX;
103 FaceMap m_faces;
104};
105
106} // namespace nfd
107
108#endif // NFD_DAEMON_FW_FACE_TABLE_HPP
Container of all faces.
const_iterator end() const
size_t size() const noexcept
Return the total number of faces.
signal::Signal< FaceTable, Face > beforeRemove
Fires immediately before a face is removed.
std::map< FaceId, shared_ptr< Face > > FaceMap
signal::Signal< FaceTable, Face > afterAdd
Fires immediately after a face is added.
boost::indirected_range< const boost::select_second_const_range< FaceMap > > ForwardRange
Face * get(FaceId id) const noexcept
Get face by FaceId.
const_iterator begin() const
void add(shared_ptr< Face > face)
Add a face.
void addReserved(shared_ptr< Face > face, FaceId faceId)
Add a special face with a reserved FaceId.
boost::range_iterator< ForwardRange >::type const_iterator
Generalization of a network interface.
Definition face.hpp:118
constexpr FaceId FACEID_RESERVED_MAX
Upper bound of reserved FaceIds.
Definition common.hpp:71