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; -*- */
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
42  const Data&
43  getData() const
44  {
45  BOOST_ASSERT(this->hasData());
46  return *m_data;
47  }
48 
52  const Name&
53  getName() const
54  {
55  BOOST_ASSERT(this->hasData());
56  return m_data->getName();
57  }
58 
62  const Name&
63  getFullName() const
64  {
65  BOOST_ASSERT(this->hasData());
66  return m_data->getFullName();
67  }
68 
72  bool
73  isUnsolicited() const
74  {
75  BOOST_ASSERT(this->hasData());
76  return m_isUnsolicited;
77  }
78 
84  getStaleTime() const
85  {
86  BOOST_ASSERT(this->hasData());
87  return m_staleTime;
88  }
89 
93  bool
94  isStale() const;
95 
100  bool
101  canSatisfy(const Interest& interest) const;
102 
103 public: // used by generic ContentStore implementation
106  bool
107  hasData() const
108  {
109  return m_data != nullptr;
110  }
111 
114  void
115  setData(shared_ptr<const Data> data, bool isUnsolicited);
116 
119  void
120  setData(const Data& data, bool isUnsolicited)
121  {
122  this->setData(data.shared_from_this(), isUnsolicited);
123  }
124 
127  void
128  updateStaleTime();
129 
133  void
134  reset();
135 
136 private:
137  shared_ptr<const Data> m_data;
138  bool m_isUnsolicited;
139  time::steady_clock::TimePoint m_staleTime;
140 };
141 
142 } // namespace cs
143 } // namespace nfd
144 
145 #endif // NFD_DAEMON_TABLE_CS_ENTRY_HPP
void reset()
clears the entry
Definition: cs-entry.cpp:70
time_point TimePoint
Definition: time.hpp:225
bool isUnsolicited() const
Definition: cs-entry.hpp:73
const time::steady_clock::TimePoint & getStaleTime() const
Definition: cs-entry.hpp:84
void setData(shared_ptr< const Data > data, bool isUnsolicited)
replaces the stored Data
Definition: cs-entry.cpp:32
Represents an Interest packet.
Definition: interest.hpp:44
bool isStale() const
checks if the stored Data is stale now
Definition: cs-entry.cpp:41
bool hasData() const
Definition: cs-entry.hpp:107
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
void setData(const Data &data, bool isUnsolicited)
replaces the stored Data
Definition: cs-entry.hpp:120
represents a base class for CS entry
Definition: cs-entry.hpp:36
Represents an absolute name.
Definition: name.hpp:43
const Data & getData() const
Definition: cs-entry.hpp:43
const Name & getName() const
Definition: cs-entry.hpp:53
const Name & getFullName() const
Definition: cs-entry.hpp:63
void updateStaleTime()
refreshes stale time relative to current time
Definition: cs-entry.cpp:48
Represents a Data packet.
Definition: data.hpp:35
bool canSatisfy(const Interest &interest) const
determines whether Interest can be satisified by the stored Data
Definition: cs-entry.cpp:55