blob: 956614dbecc14ac53ab8d77e82059fea2d272a52 [file] [log] [blame]
Alexander Afanasyev7112f482011-08-17 14:05:57 -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 */
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070020
21#include "ccnx-face-container.h"
Alexander Afanasyev7112f482011-08-17 14:05:57 -070022// #include "ns3/node-list.h"
23// #include "ns3/names.h"
24#include <algorithm>
25
26#include "ns3/ccnx-face.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070027
28namespace ns3 {
29
30CcnxFaceContainer::CcnxFaceContainer ()
31{
32}
33
Alexander Afanasyev7112f482011-08-17 14:05:57 -070034CcnxFaceContainer::CcnxFaceContainer (const CcnxFaceContainer &other)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070035{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070036 AddAll (other);
37}
38
39CcnxFaceContainer&
40CcnxFaceContainer::operator= (const CcnxFaceContainer &other)
41{
42 m_faces.clear ();
43 AddAll (other);
44
45 return *this;
46}
47
48
49void
50CcnxFaceContainer::AddAll (const CcnxFaceContainer &other)
51{
52 m_faces.insert (m_faces.end (),
53 other.m_faces.begin (), other.m_faces.end ());
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070054}
55
56CcnxFaceContainer::Iterator
57CcnxFaceContainer::Begin (void) const
58{
59 return m_faces.begin ();
60}
61
62CcnxFaceContainer::Iterator
63CcnxFaceContainer::End (void) const
64{
65 return m_faces.end ();
66}
67
68uint32_t
69CcnxFaceContainer::GetN (void) const
70{
71 return m_faces.size ();
72}
73
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070074void
Alexander Afanasyev7112f482011-08-17 14:05:57 -070075CcnxFaceContainer::SetMetricToAll (uint16_t metric)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070076{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070077 for (FaceContainer::iterator it=m_faces.begin ();
78 it != m_faces.end ();
79 it++)
80 {
81 (*it)->SetMetric (metric);
82 }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070083}
84
85void
Alexander Afanasyev7112f482011-08-17 14:05:57 -070086CcnxFaceContainer::Add (const Ptr<CcnxFace> &face)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070087{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070088 m_faces.push_back (face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070089}
90
Alexander Afanasyev7112f482011-08-17 14:05:57 -070091Ptr<CcnxFace>
92CcnxFaceContainer::Get (CcnxFaceContainer::Iterator i) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070093{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070094 return *i;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070095}
96
97
98} // namespace ns3