Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | 78cf0c9 | 2011-09-01 19:57:14 -0700 | [diff] [blame] | 25 | #include "ns3/simulator.h" |
| 26 | |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 27 | namespace ns3 |
| 28 | { |
| 29 | |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 30 | CcnxPitEntry::CcnxPitEntry (Ptr<CcnxNameComponents> prefix, |
| 31 | const Time &expireTime, |
| 32 | const CcnxFibEntry &fibEntry) |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 33 | : m_prefix (prefix) |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 34 | , m_fibEntry (fibEntry) |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 35 | , m_expireTime (expireTime) |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 36 | , m_timerExpired (false) |
| 37 | , m_counterExpirations (0) |
| 38 | { |
| 39 | } |
| 40 | |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 41 | CcnxPitEntryIncomingFaceContainer::type::iterator |
| 42 | CcnxPitEntry::AddIncoming (Ptr<CcnxFace> face) |
| 43 | { |
| 44 | std::pair<CcnxPitEntryIncomingFaceContainer::type::iterator,bool> ret = |
| 45 | m_incoming.insert (CcnxPitEntryIncomingFace (face)); |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 46 | |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 47 | NS_ASSERT_MSG (ret.second, "Something is wrong"); |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 48 | |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 49 | return ret.first; |
| 50 | } |
| 51 | |
Alexander Afanasyev | 9d313d4 | 2011-11-25 13:36:15 -0800 | [diff] [blame^] | 52 | void |
| 53 | CcnxPitEntry::RemoveIncoming (Ptr<CcnxFace> face) |
| 54 | { |
| 55 | m_incoming.erase (face); |
| 56 | } |
| 57 | |
| 58 | |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 59 | CcnxPitEntryOutgoingFaceContainer::type::iterator |
| 60 | CcnxPitEntry::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 Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 70 | void |
| 71 | CcnxPitEntry::RemoveAllReferencesToFace (Ptr<CcnxFace> face) |
| 72 | { |
| 73 | CcnxPitEntryIncomingFaceContainer::type::iterator incoming = |
| 74 | m_incoming.find (face); |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 75 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 76 | if (incoming != m_incoming.end ()) |
| 77 | m_incoming.erase (incoming); |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 78 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 79 | CcnxPitEntryOutgoingFaceContainer::type::iterator outgoing = |
| 80 | m_outgoing.find (face); |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 81 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 82 | if (outgoing != m_outgoing.end ()) |
| 83 | m_outgoing.erase (outgoing); |
| 84 | } |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 85 | |
| 86 | } |