blob: 61b4fcc0fc8d410310b184750efbcba4831f36b3 [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
Alexander Afanasyev9d313d42011-11-25 13:36:15 -080052void
53CcnxPitEntry::RemoveIncoming (Ptr<CcnxFace> face)
54{
55 m_incoming.erase (face);
56}
57
58
Alexander Afanasyeva5bbe0e2011-11-22 17:28:39 -080059CcnxPitEntryOutgoingFaceContainer::type::iterator
60CcnxPitEntry::AddOutgoing (Ptr<CcnxFace> face)
61{
62 std::pair<CcnxPitEntryOutgoingFaceContainer::type::iterator,bool> ret =
63 m_outgoing.insert (CcnxPitEntryOutgoingFace (face));
64
65 NS_ASSERT_MSG (ret.second, "Something is wrong");
66
67 return ret.first;
68}
69
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080070void
71CcnxPitEntry::RemoveAllReferencesToFace (Ptr<CcnxFace> face)
72{
73 CcnxPitEntryIncomingFaceContainer::type::iterator incoming =
74 m_incoming.find (face);
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070075
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080076 if (incoming != m_incoming.end ())
77 m_incoming.erase (incoming);
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070078
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080079 CcnxPitEntryOutgoingFaceContainer::type::iterator outgoing =
80 m_outgoing.find (face);
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070081
Alexander Afanasyev09c7deb2011-11-23 14:50:10 -080082 if (outgoing != m_outgoing.end ())
83 m_outgoing.erase (outgoing);
84}
Alexander Afanasyeva98cdd22011-08-29 17:32:37 -070085
86}