blob: 2e0ec3375d6ca325506b17768e9c78ed1f8383c4 [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
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070021#include "ndn-face-container.h"
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070022
Alexander Afanasyev7112f482011-08-17 14:05:57 -070023#include <algorithm>
24
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070025#include "ns3/ndn-face.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070026
27namespace ns3 {
28
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070029NdnFaceContainer::NdnFaceContainer ()
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070030{
31}
32
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070033NdnFaceContainer::NdnFaceContainer (const NdnFaceContainer &other)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070034{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070035 AddAll (other);
36}
37
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070038NdnFaceContainer&
39NdnFaceContainer::operator= (const NdnFaceContainer &other)
Alexander Afanasyev7112f482011-08-17 14:05:57 -070040{
41 m_faces.clear ();
42 AddAll (other);
43
44 return *this;
45}
46
47
48void
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070049NdnFaceContainer::AddAll (Ptr<NdnFaceContainer> other)
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070050{
51 AddAll (*other);
52}
53
54void
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070055NdnFaceContainer::AddAll (const NdnFaceContainer &other)
Alexander Afanasyev7112f482011-08-17 14:05:57 -070056{
57 m_faces.insert (m_faces.end (),
58 other.m_faces.begin (), other.m_faces.end ());
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070059}
60
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070061NdnFaceContainer::Iterator
62NdnFaceContainer::Begin (void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070063{
64 return m_faces.begin ();
65}
66
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070067NdnFaceContainer::Iterator
68NdnFaceContainer::End (void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070069{
70 return m_faces.end ();
71}
72
73uint32_t
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070074NdnFaceContainer::GetN (void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070075{
76 return m_faces.size ();
77}
78
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070079// void
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070080// NdnFaceContainer::SetMetricToAll (uint16_t metric)
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070081// {
82// for (FaceContainer::iterator it=m_faces.begin ();
83// it != m_faces.end ();
84// it++)
85// {
86// (*it)->SetMetric (metric);
87// }
88// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070089
90void
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070091NdnFaceContainer::Add (const Ptr<NdnFace> &face)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070092{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070093 m_faces.push_back (face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070094}
95
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070096Ptr<NdnFace>
97NdnFaceContainer::Get (NdnFaceContainer::Iterator i) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070098{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070099 return *i;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700100}
101
102
103} // namespace ns3