blob: 4426449757c78830197decb8bba770f2c482ea24 [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
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
28namespace ns3 {
29
30/**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070031 * \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 Afanasyev45b92d42011-08-14 23:11:38 -070036 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070037 * \see Ccnx
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070038 */
39class CcnxFaceContainer
40{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070041private:
42 typedef std::vector<Ptr<CcnxFace> > FaceContainer;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070043public:
Alexander Afanasyev7112f482011-08-17 14:05:57 -070044 typedef FaceContainer::const_iterator Iterator; ///< \brief Iterator over CcnxFaceContainer
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070045
46 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070047 * \brief Create an empty CcnxFaceContainer.
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070048 */
49 CcnxFaceContainer ();
50
51 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070052 * \brief Copy constructor for CcnxFaceContainer. Calls AddAll method
53 *
54 * \see CcnxFaceContainer::AddAll
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070055 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -070056 CcnxFaceContainer (const CcnxFaceContainer &other);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070057
58 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070059 * \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 Afanasyev45b92d42011-08-14 23:11:38 -070076 * container.
77 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070078 * \returns an iterator which refers to the first pair in the container.
79 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -070080 Iterator Begin () const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070081
82 /**
83 * \brief Get an iterator which indicates past-the-last Node in the
84 * container.
85 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070086 * \returns an iterator which indicates an ending condition for a loop.
87 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -070088 Iterator End () const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070089
90 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070091 * \brief Get the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070092 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070093 * \returns the number of faces stored in this container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070094 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -070095 uint32_t GetN () const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070096
97 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070098 * \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 Afanasyev45b92d42011-08-14 23:11:38 -0700101 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700102 void SetMetricToAll (uint16_t metric);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700103
104 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700105 * Add an entry to the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700106 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700107 * \param face a smart pointer to a CcnxFace-derived object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700108 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700109 * @see CcnxFace
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700110 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700111 void Add (const Ptr<CcnxFace> &face);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700112
113 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700114 * Get a smart pointer to CcnxFace-derived object stored in the container
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700115 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700116 * \param i the iterator corresponding to the requested object
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700117 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700118 * This method is redundant and simple dereferencing of the iterator should be used instead
119 *
120 * @see CcnxFace
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700121 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700122 Ptr<CcnxFace> Get (Iterator i) const;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700123
124private:
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700125 FaceContainer m_faces;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700126};
127
128} // namespace ns3
129
130#endif /* CCNX_FACE_CONTAINER_H */