in-memory-storage-entry.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2024 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_CXX_IMS_IN_MEMORY_STORAGE_ENTRY_HPP
23 #define NDN_CXX_IMS_IN_MEMORY_STORAGE_ENTRY_HPP
24 
25 #include "ndn-cxx/data.hpp"
26 #include "ndn-cxx/interest.hpp"
28 
29 namespace ndn {
30 
34 class InMemoryStorageEntry : noncopyable
35 {
36 public:
39  const Name&
40  getName() const
41  {
42  return m_dataPacket->getName();
43  }
44 
48  const Name&
49  getFullName() const
50  {
51  return m_dataPacket->getFullName();
52  }
53 
56  const Data&
57  getData() const
58  {
59  return *m_dataPacket;
60  }
61 
66  void
67  setData(const Data& data)
68  {
69  m_dataPacket = data.shared_from_this();
70  m_isFresh = true;
71  }
72 
75  void
77 
81  bool
82  isFresh() const
83  {
84  return m_isFresh;
85  }
86 
90  void
91  release();
92 
93 private:
94  shared_ptr<const Data> m_dataPacket;
95  scheduler::ScopedEventId m_markStaleEventId;
96  bool m_isFresh = true;
97 };
98 
99 } // namespace ndn
100 
101 #endif // NDN_CXX_IMS_IN_MEMORY_STORAGE_ENTRY_HPP
Represents a Data packet.
Definition: data.hpp:39
Represents an in-memory storage entry.
void release()
Releases reference counts on shared objects.
void scheduleMarkStale(Scheduler &sched, time::nanoseconds after)
Schedule an event to mark this entry as non-fresh.
const Data & getData() const
Returns the Data packet stored in the in-memory storage entry.
void setData(const Data &data)
Changes the content of in-memory storage entry.
const Name & getName() const
Returns the name of the Data packet stored in the in-memory storage entry.
const Name & getFullName() const
Returns the full name (including implicit digest) of the Data packet stored in the in-memory storage ...
bool isFresh() const
Check if the data can satisfy an Interest with MustBeFresh.
Represents an absolute name.
Definition: name.hpp:45
Generic time-based event scheduler.
Definition: scheduler.hpp:138
::boost::chrono::nanoseconds nanoseconds
Definition: time.hpp:54
Definition: data.cpp:25