blob: e1fd4b25cf7df64f9a048db52cadbc799345eeaf [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 Afanasyev4aac5572012-08-09 10:49:55 -070029#include "ns3/ndn-face.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070030
31namespace ns3 {
32
33/**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070034 * \ingroup ndn-helpers
35 * \brief A pool for Ndn faces
Alexander Afanasyev7112f482011-08-17 14:05:57 -070036 *
37 * Provides tools to perform basic manipulation on faces, such as
38 * setting metrics and states on faces
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070039 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070040 * \see NdnStackHelper
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070041 */
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070042class NdnFaceContainer : public SimpleRefCount<NdnFaceContainer>
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070043{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070044private:
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070045 typedef std::vector<Ptr<NdnFace> > FaceContainer;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070046public:
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070047 typedef FaceContainer::const_iterator Iterator; ///< \brief Iterator over NdnFaceContainer
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070048
49 /**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070050 * \brief Create an empty NdnFaceContainer.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070051 */
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070052 NdnFaceContainer ();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070053
54 /**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070055 * \brief Copy constructor for NdnFaceContainer. Calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070056 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070057 * \see NdnFaceContainer::AddAll
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070058 */
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070059 NdnFaceContainer (const NdnFaceContainer &other);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070060
61 /**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070062 * \brief Copy operator for NdnFaceContainer. Empties vector and calls AddAll method
Alexander Afanasyev7112f482011-08-17 14:05:57 -070063 *
64 * All previously obtained iterators (Begin() and End()) will be invalidated
65 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070066 * \see NdnFaceContainer::AddAll
Alexander Afanasyev7112f482011-08-17 14:05:57 -070067 */
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070068 NdnFaceContainer& operator= (const NdnFaceContainer &other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070069
70 /**
71 * \brief Add all entries from other container
72 *
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070073 * \param other smart pointer to a container
74 */
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070075 void AddAll (Ptr<NdnFaceContainer> other);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070076
77 /**
78 * \brief Add all entries from other container
79 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070080 * \param other container
81 */
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070082 void AddAll (const NdnFaceContainer &other);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070083
84 /**
85 * \brief Get an iterator which refers to the first pair in the
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070086 * container.
87 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070088 * \returns an iterator which refers to the first pair in the container.
89 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -070090 Iterator Begin () const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070091
92 /**
93 * \brief Get an iterator which indicates past-the-last Node in the
94 * container.
95 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070096 * \returns an iterator which indicates an ending condition for a loop.
97 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -070098 Iterator End () const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070099
100 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700101 * \brief Get the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700102 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700103 * \returns the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700104 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700105 uint32_t GetN () const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700106
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -0700107 // /**
108 // * \brief Set a metric for all faces in the container
109 // *
110 // * \param metric value of metric to assign to all faces in the container
111 // */
112 // void SetMetricToAll (uint16_t metric);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700113
114 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700115 * Add an entry to the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700116 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700117 * \param face a smart pointer to a NdnFace-derived object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700118 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700119 * @see NdnFace
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700120 */
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700121 void Add (const Ptr<NdnFace> &face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700122
123 /**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700124 * Get a smart pointer to NdnFace-derived object stored in the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700125 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700126 * \param i the iterator corresponding to the requested object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700127 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700128 * This method is redundant and simple dereferencing of the iterator should be used instead
129 *
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700130 * @see NdnFace
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700131 */
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700132 Ptr<NdnFace> Get (Iterator i) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700133
134private:
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700135 FaceContainer m_faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700136};
137
138} // namespace ns3
139
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700140#endif /* NDN_FACE_CONTAINER_H */