blob: 12a65b060cc9c93619a3869b8ba8801b6a58d544 [file] [log] [blame]
Junxiao Shi0fcb41e2014-01-24 10:29:43 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev4b3fc862014-06-19 14:57:57 -07003 * Copyright (c) 2014, 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
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080010 *
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070011 * 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/>.
Junxiao Shi0fcb41e2014-01-24 10:29:43 -070024 */
25
Alexander Afanasyev613e2a92014-04-15 13:36:58 -070026#ifndef NFD_DAEMON_TABLE_CS_ENTRY_HPP
27#define NFD_DAEMON_TABLE_CS_ENTRY_HPP
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080028
Junxiao Shia9388182014-12-13 23:16:09 -070029#include "cs.hpp"
30#include "core/scheduler.hpp"
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -080031
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080032namespace nfd {
Junxiao Shi0fcb41e2014-01-24 10:29:43 -070033namespace cs {
34
Junxiao Shia9388182014-12-13 23:16:09 -070035/** \brief an Entry in ContentStore
36 * \note This type is internal to ContentStore.
37 *
38 * An Entry is either a stored Entry which contains a Data packet and related attributes,
39 * or a query Entry which contains a Name that is LessComparable to other stored/query Entry
40 * and is used to lookup a container of entries.
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080041 */
Junxiao Shia9388182014-12-13 23:16:09 -070042class Entry
Junxiao Shi0fcb41e2014-01-24 10:29:43 -070043{
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080044public:
Junxiao Shia9388182014-12-13 23:16:09 -070045 /** \brief construct Entry for query
46 * \note Name is implicitly convertible to Entry, so that Name can be passed to
47 * lookup functions on a container of Entry
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040048 */
Junxiao Shia9388182014-12-13 23:16:09 -070049 Entry(const Name& name);
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080050
Junxiao Shia9388182014-12-13 23:16:09 -070051 /** \brief construct Entry for storage
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080052 */
Junxiao Shia9388182014-12-13 23:16:09 -070053 Entry(shared_ptr<const Data> data, bool isUnsolicited);
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080054
Junxiao Shia9388182014-12-13 23:16:09 -070055 shared_ptr<const Data>
56 getData() const;
57
Alexander Afanasyev4b3fc862014-06-19 14:57:57 -070058 const Name&
59 getFullName() const;
60
Junxiao Shia9388182014-12-13 23:16:09 -070061 /** \return true if entry can become stale, false if entry is never stale
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080062 */
63 bool
Junxiao Shia9388182014-12-13 23:16:09 -070064 canStale() const;
65
66 bool
67 isStale() const;
68
69 void
70 refresh();
71
72 bool
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080073 isUnsolicited() const;
74
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080075 void
Junxiao Shia9388182014-12-13 23:16:09 -070076 unsetUnsolicited();
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080077
Junxiao Shia9388182014-12-13 23:16:09 -070078 bool
79 canSatisfy(const Interest& interest) const;
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080080
Junxiao Shia9388182014-12-13 23:16:09 -070081 bool
82 operator<(const Entry& other) const;
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080083
84private:
Junxiao Shia9388182014-12-13 23:16:09 -070085 bool
86 isQuery() const;
87
88public:
89 Cs::QueueType queueType;
90 Cs::QueueIt queueIt;
91 scheduler::EventId moveStaleEvent;
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080092
93private:
Junxiao Shia9388182014-12-13 23:16:09 -070094 Name m_queryName;
95 shared_ptr<const Data> m_data;
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -070096 time::steady_clock::TimePoint m_staleAt;
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080097 bool m_isUnsolicited;
Junxiao Shi0fcb41e2014-01-24 10:29:43 -070098};
99
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -0800100} // namespace cs
Alexander Afanasyev18bbf812014-01-29 01:40:23 -0800101} // namespace nfd
Alexander Afanasyevb927a3a2014-01-24 10:41:47 -0800102
Alexander Afanasyev613e2a92014-04-15 13:36:58 -0700103#endif // NFD_DAEMON_TABLE_CS_ENTRY_HPP