blob: a4db50a97c96632779779de74b75fc98d0cecc34 [file] [log] [blame]
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2011 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21#include "ccnx-pit-entry.h"
22#include "ccnx-name-components.h"
23#include "ccnx-fib.h"
24
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -070025#include "ns3/simulator.h"
26
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070027namespace ns3
28{
29
Alexander Afanasyeva46844b2011-11-21 19:13:26 -080030CcnxPitEntry::CcnxPitEntry (Ptr<CcnxNameComponents> prefix,
31 const Time &expireTime,
32 const CcnxFibEntry &fibEntry)
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070033 : m_prefix (prefix)
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070034 , m_fibEntry (fibEntry)
Alexander Afanasyeva46844b2011-11-21 19:13:26 -080035 , m_expireTime (expireTime)
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070036 , m_timerExpired (false)
37 , m_counterExpirations (0)
38{
39}
40
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080041CcnxPitEntryIncomingFaceContainer::type::iterator
42CcnxPitEntry::AddIncoming (Ptr<CcnxFace> face)
43{
44 std::pair<CcnxPitEntryIncomingFaceContainer::type::iterator,bool> ret =
45 m_incoming.insert (CcnxPitEntryIncomingFace (face));
Alexander Afanasyeva46844b2011-11-21 19:13:26 -080046
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080047 NS_ASSERT_MSG (ret.second, "Something is wrong");
Alexander Afanasyeva46844b2011-11-21 19:13:26 -080048
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080049 return ret.first;
50}
51
52CcnxPitEntryOutgoingFaceContainer::type::iterator
53CcnxPitEntry::AddOutgoing (Ptr<CcnxFace> face)
54{
55 std::pair<CcnxPitEntryOutgoingFaceContainer::type::iterator,bool> ret =
56 m_outgoing.insert (CcnxPitEntryOutgoingFace (face));
57
58 NS_ASSERT_MSG (ret.second, "Something is wrong");
59
60 return ret.first;
61}
62
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080063void
64CcnxPitEntry::RemoveAllReferencesToFace (Ptr<CcnxFace> face)
65{
66 CcnxPitEntryIncomingFaceContainer::type::iterator incoming =
67 m_incoming.find (face);
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070068
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080069 if (incoming != m_incoming.end ())
70 m_incoming.erase (incoming);
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070071
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080072 CcnxPitEntryOutgoingFaceContainer::type::iterator outgoing =
73 m_outgoing.find (face);
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070074
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080075 if (outgoing != m_outgoing.end ())
76 m_outgoing.erase (outgoing);
77}
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070078
79}