NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
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
nfd::cs::Entry::getFullName
const Name & getFullName() const
return full name (including implicit digest) of the stored Data
Definition: cs-entry.hpp:58
nfd::cs::Entry
a ContentStore entry
Definition: cs-entry.hpp:37
nfd::cs::Entry::isFresh
bool isFresh() const
check if the stored Data is fresh now
Definition: cs-entry.cpp:39
nfd::cs::Entry::canSatisfy
bool canSatisfy(const Interest &interest) const
determine whether Interest can be satisified by the stored Data
Definition: cs-entry.cpp:51
nfd::cs::Table
std::set< Entry, std::less<> > Table
an ordered container of ContentStore entries
Definition: cs-entry.hpp:116
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
common.hpp
nfd::cs::Entry::getData
const Data & getData() const
return the stored Data
Definition: cs-entry.hpp:42
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::cs::Entry::getName
const Name & getName() const
return stored Data name
Definition: cs-entry.hpp:50
ndn::Interest
Represents an Interest packet.
Definition: interest.hpp:44
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
nfd::cs::Entry::updateFreshUntil
void updateFreshUntil()
recalculate when the entry would become non-fresh, relative to current time
Definition: cs-entry.cpp:45
ndn::time::steady_clock::TimePoint
time_point TimePoint
Definition: time.hpp:225
nfd::cs::Entry::isUnsolicited
bool isUnsolicited() const
return whether the stored Data is unsolicited
Definition: cs-entry.hpp:66
nfd::cs::Entry::Entry
Entry(shared_ptr< const Data > data, bool isUnsolicited)
Definition: cs-entry.cpp:31
nfd::cs::operator<
bool operator<(const Entry &entry, const Name &queryName)
Definition: cs-entry.cpp:97
nfd::cs::Entry::clearUnsolicited
void clearUnsolicited()
clear 'unsolicited' flag
Definition: cs-entry.hpp:92