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-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_TABLE_CS_ENTRY_HPP
27 #define NFD_DAEMON_TABLE_CS_ENTRY_HPP
28 
29 #include "core/common.hpp"
30 
31 namespace nfd {
32 namespace cs {
33 
36 class Entry
37 {
38 public: // exposed through ContentStore enumeration
41  const Data&
42  getData() const
43  {
44  return *m_data;
45  }
46 
49  const Name&
50  getName() const
51  {
52  return m_data->getName();
53  }
54 
57  const Name&
58  getFullName() const
59  {
60  return m_data->getFullName();
61  }
62 
65  bool
66  isUnsolicited() const
67  {
68  return m_isUnsolicited;
69  }
70 
73  bool
74  isFresh() const;
75 
78  bool
79  canSatisfy(const Interest& interest) const;
80 
81 public: // used by ContentStore implementation
82  Entry(shared_ptr<const Data> data, bool isUnsolicited);
83 
86  void
88 
91  void
93  {
94  m_isUnsolicited = false;
95  }
96 
97 private:
98  shared_ptr<const Data> m_data;
99  bool m_isUnsolicited;
100  time::steady_clock::TimePoint m_freshUntil;
101 };
102 
103 bool
104 operator<(const Entry& entry, const Name& queryName);
105 
106 bool
107 operator<(const Name& queryName, const Entry& entry);
108 
109 bool
110 operator<(const Entry& lhs, const Entry& rhs);
111 
116 using Table = std::set<Entry, std::less<>>;
117 
118 inline bool
119 operator<(Table::const_iterator lhs, Table::const_iterator rhs)
120 {
121  return *lhs < *rhs;
122 }
123 
124 } // namespace cs
125 } // namespace nfd
126 
127 #endif // NFD_DAEMON_TABLE_CS_ENTRY_HPP
const Data & getData() const
return the stored Data
Definition: cs-entry.hpp:42
bool isFresh() const
check if the stored Data is fresh now
Definition: cs-entry.cpp:39
bool operator<(const Entry &entry, const Name &queryName)
Definition: cs-entry.cpp:97
a ContentStore entry
Definition: cs-entry.hpp:36
Entry(shared_ptr< const Data > data, bool isUnsolicited)
Definition: cs-entry.cpp:31
const Name & getFullName() const
return full name (including implicit digest) of the stored Data
Definition: cs-entry.hpp:58
void updateFreshUntil()
recalculate when the entry would become non-fresh, relative to current time
Definition: cs-entry.cpp:45
std::set< Entry, std::less<>> Table
an ordered container of ContentStore entries
Definition: cs-entry.hpp:116
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
void clearUnsolicited()
clear &#39;unsolicited&#39; flag
Definition: cs-entry.hpp:92
bool isUnsolicited() const
return whether the stored Data is unsolicited
Definition: cs-entry.hpp:66
const Name & getName() const
return stored Data name
Definition: cs-entry.hpp:50
bool canSatisfy(const Interest &interest) const
determine whether Interest can be satisified by the stored Data
Definition: cs-entry.cpp:51