blob: 3be59f813fb10036054a2bd3c07e0c52b8fce3d4 [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 Afanasyev0c395372014-12-20 15:54:02 -080021#include "ndn-face-container.hpp"
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070022
Alexander Afanasyev7112f482011-08-17 14:05:57 -070023#include <algorithm>
24
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070025namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070026namespace ndn {
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070027
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080028FaceContainer::FaceContainer()
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070029{
30}
31
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080032FaceContainer::FaceContainer(const FaceContainer& other)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070033{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080034 AddAll(other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070035}
36
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070037FaceContainer&
38FaceContainer::operator= (const FaceContainer &other)
Alexander Afanasyev7112f482011-08-17 14:05:57 -070039{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080040 m_faces.clear();
41 AddAll(other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070042
43 return *this;
44}
45
Alexander Afanasyev7112f482011-08-17 14:05:57 -070046void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080047FaceContainer::AddAll(Ptr<FaceContainer> other)
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070048{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049 AddAll(*other);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070050}
51
52void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080053FaceContainer::AddAll(const FaceContainer& other)
Alexander Afanasyev7112f482011-08-17 14:05:57 -070054{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055 m_faces.insert(m_faces.end(), other.m_faces.begin(), other.m_faces.end());
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070056}
57
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070058FaceContainer::Iterator
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080059FaceContainer::Begin(void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070060{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061 return m_faces.begin();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070062}
63
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070064FaceContainer::Iterator
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080065FaceContainer::End(void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070066{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080067 return m_faces.end();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070068}
69
70uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080071FaceContainer::GetN(void) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070072{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080073 return m_faces.size();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070074}
75
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080076// void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070077// FaceContainer::SetMetricToAll (uint16_t metric)
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070078// {
79// for (FaceContainer::iterator it=m_faces.begin ();
80// it != m_faces.end ();
81// it++)
82// {
83// (*it)->SetMetric (metric);
84// }
85// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070086
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080087void
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070088FaceContainer::Add(const shared_ptr<Face>& face)
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070089{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080090 m_faces.push_back(face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070091}
92
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070093shared_ptr<Face>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080094FaceContainer::Get(FaceContainer::Iterator i) const
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070095{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070096 return *i;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070097}
98
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070099} // namespace ndn
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700100} // namespace ns3