blob: 545ff4d9e29f5e5065f296ecceb0a57711d9bcab [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyev7112f482011-08-17 14:05:57 -07004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyev7112f482011-08-17 14:05:57 -07007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyev7112f482011-08-17 14:05:57 -070011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyev7112f482011-08-17 14:05:57 -070015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070019
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070020#ifndef NDN_FACE_CONTAINER_H
21#define NDN_FACE_CONTAINER_H
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070022
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070023#include "ns3/ndnSIM/model/ndn-common.hpp"
24
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070025#include <stdint.h>
26#include <vector>
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070027
28#include "ns3/ptr.h"
29#include "ns3/simple-ref-count.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070030
31namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070032namespace ndn {
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070033
34/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070035 * @ingroup ndn-helpers
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080036 * @brief A pool for Ndn faces
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080037 *
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080038 * Provides tools to perform basic manipulation on faces, such as setting metrics and
39 * states on faces
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070040 *
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080041 * @see ndn::StackHelper
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070042 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043class FaceContainer : public SimpleRefCount<FaceContainer> {
Alexander Afanasyev7112f482011-08-17 14:05:57 -070044private:
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070045 typedef std::vector<shared_ptr<Face>> Container;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080046
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070047public:
Alexander Afanasyev241df872015-08-13 17:26:15 -070048 typedef Container::const_iterator Iterator; ///< @brief Iterator over FaceContainer
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070049
50 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070051 * @brief Create an empty FaceContainer.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070052 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080053 FaceContainer();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070054
55 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070056 * @brief Copy constructor for FaceContainer. Calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070057 *
Alexander Afanasyev241df872015-08-13 17:26:15 -070058 * @see FaceContainer::AddAll
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070059 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080060 FaceContainer(const FaceContainer& other);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070061
62 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070063 * @brief Copy operator for FaceContainer. Empties vector and calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070064 *
65 * All previously obtained iterators (Begin() and End()) will be invalidated
66 *
Alexander Afanasyev241df872015-08-13 17:26:15 -070067 * @see FaceContainer::AddAll
Alexander Afanasyev7112f482011-08-17 14:05:57 -070068 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080069 FaceContainer&
70 operator=(const FaceContainer& other);
71
Alexander Afanasyev7112f482011-08-17 14:05:57 -070072 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070073 * Add an entry to the container
Alexander Afanasyev7112f482011-08-17 14:05:57 -070074 *
Alexander Afanasyev241df872015-08-13 17:26:15 -070075 * @param face a smart pointer to a Face-derived object
76 */
77 void
78 Add(shared_ptr<Face> face);
79
80 /**
81 * @brief Add all entries from other container
82 *
83 * @param other smart pointer to a container
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070084 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080085 void
86 AddAll(Ptr<FaceContainer> other);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070087
88 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070089 * @brief Add all entries from other container
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070090 *
Alexander Afanasyev241df872015-08-13 17:26:15 -070091 * @param other container
Alexander Afanasyev7112f482011-08-17 14:05:57 -070092 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080093 void
94 AddAll(const FaceContainer& other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070095
Alexander Afanasyev241df872015-08-13 17:26:15 -070096public: // accessors
Alexander Afanasyev7112f482011-08-17 14:05:57 -070097 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -070098 * @brief Get an iterator which refers to the first pair in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070099 * container.
100 *
Alexander Afanasyev241df872015-08-13 17:26:15 -0700101 * @returns an iterator which refers to the first pair in the container.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700102 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800103 Iterator
104 Begin() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700105
106 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -0700107 * @brief Get an iterator which indicates past-the-last Node in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700108 * container.
109 *
Alexander Afanasyev241df872015-08-13 17:26:15 -0700110 * @returns an iterator which indicates an ending condition for a loop.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700111 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800112 Iterator
113 End() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700114
115 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -0700116 * @brief Get the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700117 *
Alexander Afanasyev241df872015-08-13 17:26:15 -0700118 * @returns the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700119 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800120 uint32_t
121 GetN() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700122
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700123 /**
Alexander Afanasyev241df872015-08-13 17:26:15 -0700124 * Get a Face stored in the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700125 *
Alexander Afanasyev241df872015-08-13 17:26:15 -0700126 * @param pos index of the Face in the container
127 * @throw std::out_of_range if !(pos < GetN()).
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700128 */
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -0700129 shared_ptr<Face>
Alexander Afanasyev241df872015-08-13 17:26:15 -0700130 Get(size_t pos) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700131
132private:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700133 Container m_faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700134};
135
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700136} // namespace ndn
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700137} // namespace ns3
138
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700139#endif /* NDN_FACE_CONTAINER_H */