Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 20 | |
| 21 | #ifndef CCNX_FACE_CONTAINER_H |
| 22 | #define CCNX_FACE_CONTAINER_H |
| 23 | |
| 24 | #include <stdint.h> |
| 25 | #include <vector> |
| 26 | #include "ns3/ccnx.h" |
| 27 | |
| 28 | namespace ns3 { |
| 29 | |
| 30 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 31 | * \ingroup ccnx |
| 32 | * \brief A pool for CCNx faces |
| 33 | * |
| 34 | * Provides tools to perform basic manipulation on faces, such as |
| 35 | * setting metrics and states on faces |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 36 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 37 | * \see Ccnx |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 38 | */ |
| 39 | class CcnxFaceContainer |
| 40 | { |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 41 | private: |
| 42 | typedef std::vector<Ptr<CcnxFace> > FaceContainer; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 43 | public: |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 44 | typedef FaceContainer::const_iterator Iterator; ///< \brief Iterator over CcnxFaceContainer |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 47 | * \brief Create an empty CcnxFaceContainer. |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 48 | */ |
| 49 | CcnxFaceContainer (); |
| 50 | |
| 51 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 52 | * \brief Copy constructor for CcnxFaceContainer. Calls AddAll method |
| 53 | * |
| 54 | * \see CcnxFaceContainer::AddAll |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 55 | */ |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 56 | CcnxFaceContainer (const CcnxFaceContainer &other); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 57 | |
| 58 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 59 | * \brief Copy operator for CcnxFaceContainer. Empties vector and calls AddAll method |
| 60 | * |
| 61 | * All previously obtained iterators (Begin() and End()) will be invalidated |
| 62 | * |
| 63 | * \see CcnxFaceContainer::AddAll |
| 64 | */ |
| 65 | CcnxFaceContainer& operator= (const CcnxFaceContainer &other); |
| 66 | |
| 67 | /** |
| 68 | * \brief Add all entries from other container |
| 69 | * |
| 70 | * \param other container |
| 71 | */ |
| 72 | void AddAll (const CcnxFaceContainer &other); |
| 73 | |
| 74 | /** |
| 75 | * \brief Get an iterator which refers to the first pair in the |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 76 | * container. |
| 77 | * |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 78 | * \returns an iterator which refers to the first pair in the container. |
| 79 | */ |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 80 | Iterator Begin () const; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * \brief Get an iterator which indicates past-the-last Node in the |
| 84 | * container. |
| 85 | * |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 86 | * \returns an iterator which indicates an ending condition for a loop. |
| 87 | */ |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 88 | Iterator End () const; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 89 | |
| 90 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 91 | * \brief Get the number of faces stored in this container |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 92 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 93 | * \returns the number of faces stored in this container |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 94 | */ |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 95 | uint32_t GetN () const; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 96 | |
| 97 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 98 | * \brief Set a metric for all faces in the container |
| 99 | * |
| 100 | * \param metric value of metric to assign to all faces in the container |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 101 | */ |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 102 | void SetMetricToAll (uint16_t metric); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 103 | |
| 104 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 105 | * Add an entry to the container |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 106 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 107 | * \param face a smart pointer to a CcnxFace-derived object |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 108 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 109 | * @see CcnxFace |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 110 | */ |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 111 | void Add (const Ptr<CcnxFace> &face); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 112 | |
| 113 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 114 | * Get a smart pointer to CcnxFace-derived object stored in the container |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 115 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 116 | * \param i the iterator corresponding to the requested object |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 117 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 118 | * This method is redundant and simple dereferencing of the iterator should be used instead |
| 119 | * |
| 120 | * @see CcnxFace |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 121 | */ |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 122 | Ptr<CcnxFace> Get (Iterator i) const; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 123 | |
| 124 | private: |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 125 | FaceContainer m_faces; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | } // namespace ns3 |
| 129 | |
| 130 | #endif /* CCNX_FACE_CONTAINER_H */ |