Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -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 | */ |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 20 | |
| 21 | #include "ccnx-face-container.h" |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame^] | 22 | // #include "ns3/node-list.h" |
| 23 | // #include "ns3/names.h" |
| 24 | #include <algorithm> |
| 25 | |
| 26 | #include "ns3/ccnx-face.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 27 | |
| 28 | namespace ns3 { |
| 29 | |
| 30 | CcnxFaceContainer::CcnxFaceContainer () |
| 31 | { |
| 32 | } |
| 33 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame^] | 34 | CcnxFaceContainer::CcnxFaceContainer (const CcnxFaceContainer &other) |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 35 | { |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame^] | 36 | AddAll (other); |
| 37 | } |
| 38 | |
| 39 | CcnxFaceContainer& |
| 40 | CcnxFaceContainer::operator= (const CcnxFaceContainer &other) |
| 41 | { |
| 42 | m_faces.clear (); |
| 43 | AddAll (other); |
| 44 | |
| 45 | return *this; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | void |
| 50 | CcnxFaceContainer::AddAll (const CcnxFaceContainer &other) |
| 51 | { |
| 52 | m_faces.insert (m_faces.end (), |
| 53 | other.m_faces.begin (), other.m_faces.end ()); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | CcnxFaceContainer::Iterator |
| 57 | CcnxFaceContainer::Begin (void) const |
| 58 | { |
| 59 | return m_faces.begin (); |
| 60 | } |
| 61 | |
| 62 | CcnxFaceContainer::Iterator |
| 63 | CcnxFaceContainer::End (void) const |
| 64 | { |
| 65 | return m_faces.end (); |
| 66 | } |
| 67 | |
| 68 | uint32_t |
| 69 | CcnxFaceContainer::GetN (void) const |
| 70 | { |
| 71 | return m_faces.size (); |
| 72 | } |
| 73 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 74 | void |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame^] | 75 | CcnxFaceContainer::SetMetricToAll (uint16_t metric) |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 76 | { |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame^] | 77 | for (FaceContainer::iterator it=m_faces.begin (); |
| 78 | it != m_faces.end (); |
| 79 | it++) |
| 80 | { |
| 81 | (*it)->SetMetric (metric); |
| 82 | } |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | void |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame^] | 86 | CcnxFaceContainer::Add (const Ptr<CcnxFace> &face) |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 87 | { |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame^] | 88 | m_faces.push_back (face); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame^] | 91 | Ptr<CcnxFace> |
| 92 | CcnxFaceContainer::Get (CcnxFaceContainer::Iterator i) const |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 93 | { |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame^] | 94 | return *i; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | |
| 98 | } // namespace ns3 |