Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 4b3fc86 | 2014-06-19 14:57:57 -0700 | [diff] [blame] | 3 | * 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 Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 10 | * |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 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/>. |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 24 | */ |
| 25 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 26 | #ifndef NFD_DAEMON_TABLE_CS_ENTRY_HPP |
| 27 | #define NFD_DAEMON_TABLE_CS_ENTRY_HPP |
Alexander Afanasyev | b927a3a | 2014-01-24 10:41:47 -0800 | [diff] [blame] | 28 | |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 29 | #include "cs.hpp" |
| 30 | #include "core/scheduler.hpp" |
Alexander Afanasyev | b927a3a | 2014-01-24 10:41:47 -0800 | [diff] [blame] | 31 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 32 | namespace nfd { |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 33 | namespace cs { |
| 34 | |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 35 | /** \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 Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 41 | */ |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 42 | class Entry |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 43 | { |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 44 | public: |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 45 | /** \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 Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 48 | */ |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 49 | Entry(const Name& name); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 50 | |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 51 | /** \brief construct Entry for storage |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 52 | */ |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 53 | Entry(shared_ptr<const Data> data, bool isUnsolicited); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 54 | |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 55 | shared_ptr<const Data> |
| 56 | getData() const; |
| 57 | |
Alexander Afanasyev | 4b3fc86 | 2014-06-19 14:57:57 -0700 | [diff] [blame] | 58 | const Name& |
| 59 | getFullName() const; |
| 60 | |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 61 | /** \return true if entry can become stale, false if entry is never stale |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 62 | */ |
| 63 | bool |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 64 | canStale() const; |
| 65 | |
| 66 | bool |
| 67 | isStale() const; |
| 68 | |
| 69 | void |
| 70 | refresh(); |
| 71 | |
| 72 | bool |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 73 | isUnsolicited() const; |
| 74 | |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 75 | void |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 76 | unsetUnsolicited(); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 77 | |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 78 | bool |
| 79 | canSatisfy(const Interest& interest) const; |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 80 | |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 81 | bool |
| 82 | operator<(const Entry& other) const; |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 83 | |
| 84 | private: |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 85 | bool |
| 86 | isQuery() const; |
| 87 | |
| 88 | public: |
| 89 | Cs::QueueType queueType; |
| 90 | Cs::QueueIt queueIt; |
| 91 | scheduler::EventId moveStaleEvent; |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 92 | |
| 93 | private: |
Junxiao Shi | a938818 | 2014-12-13 23:16:09 -0700 | [diff] [blame^] | 94 | Name m_queryName; |
| 95 | shared_ptr<const Data> m_data; |
Alexander Afanasyev | eb3197f | 2014-03-17 19:28:18 -0700 | [diff] [blame] | 96 | time::steady_clock::TimePoint m_staleAt; |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 97 | bool m_isUnsolicited; |
Junxiao Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
Alexander Afanasyev | b927a3a | 2014-01-24 10:41:47 -0800 | [diff] [blame] | 100 | } // namespace cs |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 101 | } // namespace nfd |
Alexander Afanasyev | b927a3a | 2014-01-24 10:41:47 -0800 | [diff] [blame] | 102 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 103 | #endif // NFD_DAEMON_TABLE_CS_ENTRY_HPP |