blob: 776a5ecb4d405b3614a6ca0ba6209d73ea208ef5 [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#ifndef NDN_FACE_CONTAINER_H
22#define NDN_FACE_CONTAINER_H
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070023
24#include <stdint.h>
25#include <vector>
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070026
27#include "ns3/ptr.h"
28#include "ns3/simple-ref-count.h"
Alexander Afanasyev0c395372014-12-20 15:54:02 -080029#include "ns3/ndn-face.hpp"
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
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070036 * \brief A pool for Ndn faces
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080037 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070038 * Provides tools to perform basic manipulation on faces, such as
39 * setting metrics and states on faces
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070040 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070041 * \see NdnStackHelper
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:
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045 typedef std::vector<Ptr<Face>> Container;
46
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070047public:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070048 typedef Container::const_iterator Iterator; ///< \brief Iterator over FaceContainer
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070049
50 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -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 Afanasyev2b4c9472012-08-09 15:00:38 -070056 * \brief Copy constructor for FaceContainer. Calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070057 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -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 Afanasyev2b4c9472012-08-09 15:00:38 -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 Afanasyev2b4c9472012-08-09 15:00:38 -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 /**
73 * \brief Add all entries from other container
74 *
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070075 * \param other smart pointer to a container
76 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080077 void
78 AddAll(Ptr<FaceContainer> other);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070079
80 /**
81 * \brief Add all entries from other container
82 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070083 * \param other container
84 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080085 void
86 AddAll(const FaceContainer& other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070087
88 /**
89 * \brief Get an iterator which refers to the first pair in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070090 * container.
91 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070092 * \returns an iterator which refers to the first pair in the container.
93 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080094 Iterator
95 Begin() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070096
97 /**
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080098 * \brief Get an iterator which indicates past-the-last Node in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070099 * container.
100 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700101 * \returns an iterator which indicates an ending condition for a loop.
102 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800103 Iterator
104 End() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700105
106 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700107 * \brief Get the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700108 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700109 * \returns the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700110 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800111 uint32_t
112 GetN() const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700113
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700114 // /**
115 // * \brief Set a metric for all faces in the container
116 // *
117 // * \param metric value of metric to assign to all faces in the container
118 // */
119 // void SetMetricToAll (uint16_t metric);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700120
121 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700122 * Add an entry to the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700123 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700124 * \param face a smart pointer to a Face-derived object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700125 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700126 * @see Face
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700127 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800128 void
129 Add(const Ptr<Face>& face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700130
131 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700132 * Get a smart pointer to Face-derived object stored in the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700133 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700134 * \param i the iterator corresponding to the requested object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700135 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700136 * This method is redundant and simple dereferencing of the iterator should be used instead
137 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700138 * @see Face
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700139 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800140 Ptr<Face>
141 Get(Iterator i) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700142
143private:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700144 Container m_faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700145};
146
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700147} // namespace ndn
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700148} // namespace ns3
149
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700150#endif /* NDN_FACE_CONTAINER_H */