blob: 1262065dfa9e7f8890307237888d879b8080c82e [file] [log] [blame]
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -08001/* -*- 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/>.
24 *
Alexander Afanasyev4b3fc862014-06-19 14:57:57 -070025 * \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 Moiseenko76cf77a2014-03-05 14:35:51 -080028 */
29
30#include "cs-entry.hpp"
Steve DiBenedettobf6a93d2014-03-21 14:03:02 -060031#include "core/logger.hpp"
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080032
33namespace nfd {
34namespace cs {
35
36NFD_LOG_INIT("CsEntry");
37
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040038void
39Entry::release()
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080040{
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040041 BOOST_ASSERT(m_layerIterators.empty());
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080042
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040043 m_dataPacket.reset();
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080044}
45
46void
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040047Entry::setData(const Data& data, bool isUnsolicited)
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080048{
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040049 m_isUnsolicited = isUnsolicited;
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080050 m_dataPacket = data.shared_from_this();
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080051
52 updateStaleTime();
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080053}
54
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080055void
56Entry::updateStaleTime()
57{
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -070058 m_staleAt = time::steady_clock::now() + m_dataPacket->getFreshnessPeriod();
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080059}
60
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080061void
62Entry::setIterator(int layer, const Entry::LayerIterators::mapped_type& layerIterator)
63{
64 m_layerIterators[layer] = layerIterator;
65}
66
67void
68Entry::removeIterator(int layer)
69{
70 m_layerIterators.erase(layer);
71}
72
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080073void
74Entry::printIterators() const
75{
76 for (LayerIterators::const_iterator it = m_layerIterators.begin();
77 it != m_layerIterators.end();
78 ++it)
79 {
Alexander Afanasyevbf9edee2014-03-31 23:05:27 -070080 NFD_LOG_TRACE("[" << it->first << "]" << " " << &(*it->second));
Ilya Moiseenko76cf77a2014-03-05 14:35:51 -080081 }
82}
83
84} // namespace cs
85} // namespace nfd