Loading...
Searching...
No Matches
cs-entry.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_TABLE_CS_ENTRY_HPP
27#define NFD_DAEMON_TABLE_CS_ENTRY_HPP
28
29#include "core/common.hpp"
30
31#include <set>
32
33namespace nfd::cs {
34
37class Entry
38{
39public: // exposed through ContentStore enumeration
42 const Data&
43 getData() const
44 {
45 return *m_data;
46 }
47
50 const Name&
51 getName() const
52 {
53 return m_data->getName();
54 }
55
58 const Name&
60 {
61 return m_data->getFullName();
62 }
63
66 bool
68 {
69 return m_isUnsolicited;
70 }
71
74 bool
75 isFresh() const;
76
79 bool
80 canSatisfy(const Interest& interest) const;
81
82public: // used by ContentStore implementation
83 Entry(shared_ptr<const Data> data, bool isUnsolicited);
84
87 void
89
92 void
94 {
95 m_isUnsolicited = false;
96 }
97
98private:
99 shared_ptr<const Data> m_data;
100 bool m_isUnsolicited;
101 time::steady_clock::time_point m_freshUntil;
102};
103
104bool
105operator<(const Entry& entry, const Name& queryName);
106
107bool
108operator<(const Name& queryName, const Entry& entry);
109
110bool
111operator<(const Entry& lhs, const Entry& rhs);
112
117using Table = std::set<Entry, std::less<>>;
118
119inline bool
120operator<(Table::const_iterator lhs, Table::const_iterator rhs)
121{
122 return *lhs < *rhs;
123}
124
125} // namespace nfd::cs
126
127#endif // NFD_DAEMON_TABLE_CS_ENTRY_HPP
A ContentStore entry.
Definition cs-entry.hpp:38
bool isFresh() const
Check if the stored Data is fresh now.
Definition cs-entry.cpp:38
const Data & getData() const
Return the stored Data.
Definition cs-entry.hpp:43
void clearUnsolicited()
Clear 'unsolicited' flag.
Definition cs-entry.hpp:93
const Name & getName() const
Return stored Data name.
Definition cs-entry.hpp:51
bool canSatisfy(const Interest &interest) const
Determine whether Interest can be satisified by the stored Data.
Definition cs-entry.cpp:50
void updateFreshUntil()
Recalculate when the entry would become non-fresh, relative to current time.
Definition cs-entry.cpp:44
const Name & getFullName() const
Return full name (including implicit digest) of the stored Data.
Definition cs-entry.hpp:59
bool isUnsolicited() const
Return whether the stored Data is unsolicited.
Definition cs-entry.hpp:67
std::set< Entry, std::less<> > Table
An ordered container of ContentStore entries.
Definition cs-entry.hpp:117
bool operator<(const Entry &entry, const Name &queryName)
Definition cs-entry.cpp:96