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-2022, 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 namespace nfd::cs {
32 
35 class Entry
36 {
37 public: // exposed through ContentStore enumeration
40  const Data&
41  getData() const
42  {
43  return *m_data;
44  }
45 
48  const Name&
49  getName() const
50  {
51  return m_data->getName();
52  }
53 
56  const Name&
57  getFullName() const
58  {
59  return m_data->getFullName();
60  }
61 
64  bool
65  isUnsolicited() const
66  {
67  return m_isUnsolicited;
68  }
69 
72  bool
73  isFresh() const;
74 
77  bool
78  canSatisfy(const Interest& interest) const;
79 
80 public: // used by ContentStore implementation
81  Entry(shared_ptr<const Data> data, bool isUnsolicited);
82 
85  void
87 
90  void
92  {
93  m_isUnsolicited = false;
94  }
95 
96 private:
97  shared_ptr<const Data> m_data;
98  bool m_isUnsolicited;
99  time::steady_clock::time_point m_freshUntil;
100 };
101 
102 bool
103 operator<(const Entry& entry, const Name& queryName);
104 
105 bool
106 operator<(const Name& queryName, const Entry& entry);
107 
108 bool
109 operator<(const Entry& lhs, const Entry& rhs);
110 
115 using Table = std::set<Entry, std::less<>>;
116 
117 inline bool
118 operator<(Table::const_iterator lhs, Table::const_iterator rhs)
119 {
120  return *lhs < *rhs;
121 }
122 
123 } // namespace nfd::cs
124 
125 #endif // NFD_DAEMON_TABLE_CS_ENTRY_HPP
A ContentStore entry.
Definition: cs-entry.hpp:36
bool isFresh() const
Check if the stored Data is fresh now.
Definition: cs-entry.cpp:38
const Name & getFullName() const
Return full name (including implicit digest) of the stored Data.
Definition: cs-entry.hpp:57
Entry(shared_ptr< const Data > data, bool isUnsolicited)
Definition: cs-entry.cpp:30
void clearUnsolicited()
Clear 'unsolicited' flag.
Definition: cs-entry.hpp:91
const Name & getName() const
Return stored Data name.
Definition: cs-entry.hpp:49
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 Data & getData() const
Return the stored Data.
Definition: cs-entry.hpp:41
bool isUnsolicited() const
Return whether the stored Data is unsolicited.
Definition: cs-entry.hpp:65
std::set< Entry, std::less<> > Table
An ordered container of ContentStore entries.
Definition: cs-entry.hpp:115
bool operator<(const Entry &entry, const Name &queryName)
Definition: cs-entry.cpp:96