Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [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/>. |
| 24 | * |
Alexander Afanasyev | 4b3fc86 | 2014-06-19 14:57:57 -0700 | [diff] [blame^] | 25 | * \author Ilya Moiseenko <http://ilyamoiseenko.com/> |
| 26 | * \author Junxiao Shi <http://www.cs.arizona.edu/people/shijunxiao/> |
| 27 | * \author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html> |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 28 | */ |
| 29 | |
| 30 | #include "cs-entry.hpp" |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 31 | #include "core/logger.hpp" |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 32 | |
| 33 | namespace nfd { |
| 34 | namespace cs { |
| 35 | |
| 36 | NFD_LOG_INIT("CsEntry"); |
| 37 | |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 38 | void |
| 39 | Entry::release() |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 40 | { |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 41 | BOOST_ASSERT(m_layerIterators.empty()); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 42 | |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 43 | m_dataPacket.reset(); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | void |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 47 | Entry::setData(const Data& data, bool isUnsolicited) |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 48 | { |
Ilya Moiseenko | 96b80bb | 2014-04-05 20:53:27 -0400 | [diff] [blame] | 49 | m_isUnsolicited = isUnsolicited; |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 50 | m_dataPacket = data.shared_from_this(); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 51 | |
| 52 | updateStaleTime(); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 55 | void |
| 56 | Entry::updateStaleTime() |
| 57 | { |
Alexander Afanasyev | eb3197f | 2014-03-17 19:28:18 -0700 | [diff] [blame] | 58 | m_staleAt = time::steady_clock::now() + m_dataPacket->getFreshnessPeriod(); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 59 | } |
| 60 | |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 61 | void |
| 62 | Entry::setIterator(int layer, const Entry::LayerIterators::mapped_type& layerIterator) |
| 63 | { |
| 64 | m_layerIterators[layer] = layerIterator; |
| 65 | } |
| 66 | |
| 67 | void |
| 68 | Entry::removeIterator(int layer) |
| 69 | { |
| 70 | m_layerIterators.erase(layer); |
| 71 | } |
| 72 | |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 73 | void |
| 74 | Entry::printIterators() const |
| 75 | { |
| 76 | for (LayerIterators::const_iterator it = m_layerIterators.begin(); |
| 77 | it != m_layerIterators.end(); |
| 78 | ++it) |
| 79 | { |
Alexander Afanasyev | bf9edee | 2014-03-31 23:05:27 -0700 | [diff] [blame] | 80 | NFD_LOG_TRACE("[" << it->first << "]" << " " << &(*it->second)); |
Ilya Moiseenko | 76cf77a | 2014-03-05 14:35:51 -0800 | [diff] [blame] | 81 | } |
| 82 | } |
| 83 | |
| 84 | } // namespace cs |
| 85 | } // namespace nfd |