LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2014 Wireless Communications and Networking Group (WCNG), | 3 * Copyright (c) 2014 Wireless Communications and Networking Group (WCNG), |
4 * University of Rochester, Rochester, NY, USA. | 4 * University of Rochester, Rochester, NY, USA. |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
8 * published by the Free Software Foundation; | 8 * published by the Free Software Foundation; |
9 * | 9 * |
10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
(...skipping 11 matching lines...) Expand all Loading... |
22 #ifndef ENERGY_HARVESTER_CONTAINER_H | 22 #ifndef ENERGY_HARVESTER_CONTAINER_H |
23 #define ENERGY_HARVESTER_CONTAINER_H | 23 #define ENERGY_HARVESTER_CONTAINER_H |
24 | 24 |
25 #include "ns3/energy-harvester.h" | 25 #include "ns3/energy-harvester.h" |
26 #include "ns3/object.h" | 26 #include "ns3/object.h" |
27 #include <vector> | 27 #include <vector> |
28 #include <stdint.h> | 28 #include <stdint.h> |
29 | 29 |
30 namespace ns3 { | 30 namespace ns3 { |
31 ···· | 31 ···· |
32 class EnergyHarvester; | 32 class EnergyHarvester; |
33 ···· | 33 |
34 /** | 34 /** |
35 * \ingroup energy | 35 * \ingroup energy |
36 * \brief Holds a vector of ns3::EnergyHarvester pointers. | 36 * \brief Holds a vector of ns3::EnergyHarvester pointers. |
37 * | 37 * |
38 * EnergyHarvesterContainer returns a list of EnergyHarvester pointers | 38 * EnergyHarvesterContainer returns a list of EnergyHarvester pointers |
39 * installed on a node. Users can use this list to access EnergyHarvester | 39 * installed on a node. Users can use this list to access EnergyHarvester |
40 * objects to obtain the total energy harvested on a node easily. | 40 * objects to obtain the total energy harvested on a node easily. |
41 * | 41 * |
42 * \see NetDeviceContainer | 42 * \see NetDeviceContainer |
43 * | 43 * |
44 */ | 44 */ |
45 class EnergyHarvesterContainer : public Object | 45 class EnergyHarvesterContainer : public Object |
46 { | 46 { |
47 public: | 47 public: |
48 typedef std::vector< Ptr<EnergyHarvester> >::const_iterator Iterator; | 48 typedef std::vector< Ptr<EnergyHarvester> >::const_iterator Iterator; |
49 ········ | 49 |
50 public: | 50 public: |
51 static TypeId GetTypeId (void); | 51 static TypeId GetTypeId (void); |
52 /** | 52 /** |
53 * Creates an empty EnergyHarvesterContainer. | 53 * Creates an empty EnergyHarvesterContainer. |
54 */ | 54 */ |
55 EnergyHarvesterContainer (); | 55 EnergyHarvesterContainer (); |
56 ~EnergyHarvesterContainer (); | 56 ~EnergyHarvesterContainer (); |
57 ········ | 57 |
58 /** | 58 /** |
59 * \param harvester Pointer to an EnergyHarvester. | 59 * \param harvester Pointer to an EnergyHarvester. |
60 * | 60 * |
61 * Creates a EnergyHarvesterContainer with exactly one EnergyHarvester | 61 * Creates a EnergyHarvesterContainer with exactly one EnergyHarvester |
62 * previously instantiated. | 62 * previously instantiated. |
63 */ | 63 */ |
64 EnergyHarvesterContainer (Ptr<EnergyHarvester> harvester); | 64 EnergyHarvesterContainer (Ptr<EnergyHarvester> harvester); |
65 ········ | 65 |
66 /** | 66 /** |
67 * \param harvesterName Name of EnergyHarvester. | 67 * \param harvesterName Name of EnergyHarvester. |
68 * | 68 * |
69 * Creates an EnergyHarvesterContainer with exactly one EnergyHarvester | 69 * Creates an EnergyHarvesterContainer with exactly one EnergyHarvester |
70 * previously instantiated and assigned a name using the Object name ser
vice. | 70 * previously instantiated and assigned a name using the Object name service. |
71 * This EnergyHarvester is specified by its assigned name. | 71 * This EnergyHarvester is specified by its assigned name. |
72 */ | 72 */ |
73 EnergyHarvesterContainer (std::string harvesterName); | 73 EnergyHarvesterContainer (std::string harvesterName); |
74 ········ | 74 |
75 /** | 75 /** |
76 * \param a A EnergyHarvesterContainer. | 76 * \param a A EnergyHarvesterContainer. |
77 * \param b Another EnergyHarvesterContainer. | 77 * \param b Another EnergyHarvesterContainer. |
78 * | 78 * |
79 * Creates a EnergyHarvesterContainer by concatenating EnergyHarvesterCo
ntainer b | 79 * Creates a EnergyHarvesterContainer by concatenating EnergyHarvesterContaine
r b |
80 * to EnergyHarvesterContainer a. | 80 * to EnergyHarvesterContainer a. |
81 * | 81 * |
82 * \note Can be used to concatenate 2 Ptr<EnergyHarvester> directly. C++ | 82 * \note Can be used to concatenate 2 Ptr<EnergyHarvester> directly. C++ |
83 * will be calling EnergyHarvesterContainer constructor with Ptr<EnergyH
arvester> | 83 * will be calling EnergyHarvesterContainer constructor with Ptr<EnergyHarvest
er> |
84 * first. | 84 * first. |
85 */ | 85 */ |
86 EnergyHarvesterContainer (const EnergyHarvesterContainer &a, | 86 EnergyHarvesterContainer (const EnergyHarvesterContainer &a, |
87 const EnergyHarvesterContainer &b); | 87 const EnergyHarvesterContainer &b); |
88 ········ | 88 |
89 /** | 89 /** |
90 * \brief Get an iterator which refers to the first EnergyHarvester poin
ter | 90 * \brief Get an iterator which refers to the first EnergyHarvester pointer |
91 * in the container. | 91 * in the container. |
92 * | 92 * |
93 * \returns An iterator which refers to the first EnergyHarvester in con
tainer. | 93 * \returns An iterator which refers to the first EnergyHarvester in container
. |
94 * | 94 * |
95 * EnergyHarvesters can be retrieved from the container in two ways. Fir
st, | 95 * EnergyHarvesters can be retrieved from the container in two ways. First, |
96 * directly by an index into the container, and second, using an iterato
r. | 96 * directly by an index into the container, and second, using an iterator. |
97 * This method is used in the iterator method and is typically used in a | 97 * This method is used in the iterator method and is typically used in a |
98 * for-loop to run through the EnergyHarvesters. | 98 * for-loop to run through the EnergyHarvesters. |
99 * | 99 * |
100 * \code | 100 * \code |
101 * EnergyHarvesterContainer::Iterator i; | 101 * EnergyHarvesterContainer::Iterator i; |
102 * for (i = container.Begin (); i != container.End (); ++i) | 102 * for (i = container.Begin (); i != container.End (); ++i) |
103 * { | 103 * { |
104 * (*i)->method (); // some EnergyHarvester method | 104 * (*i)->method (); // some EnergyHarvester method |
105 * } | 105 * } |
106 * \endcode | 106 * \endcode |
107 */ | 107 */ |
108 Iterator Begin (void) const; | 108 Iterator Begin (void) const; |
109 ········ | 109 |
110 /** | 110 /** |
111 * \brief Get an iterator which refers to the last EnergyHarvester point
er | 111 * \brief Get an iterator which refers to the last EnergyHarvester pointer |
112 * in the container. | 112 * in the container. |
113 * | 113 * |
114 * \returns An iterator which refers to the last EnergyHarvester in cont
ainer. | 114 * \returns An iterator which refers to the last EnergyHarvester in container. |
115 * | 115 * |
116 * EnergyHarvesters can be retrieved from the container in two ways. Fir
st, | 116 * EnergyHarvesters can be retrieved from the container in two ways. First, |
117 * directly by an index into the container, and second, using an iterato
r. | 117 * directly by an index into the container, and second, using an iterator. |
118 * This method is used in the iterator method and is typically used in a | 118 * This method is used in the iterator method and is typically used in a |
119 * for-loop to run through the EnergyHarvesters. | 119 * for-loop to run through the EnergyHarvesters. |
120 * | 120 * |
121 * \code | 121 * \code |
122 * EnergyHarvesterContainer::Iterator i; | 122 * EnergyHarvesterContainer::Iterator i; |
123 * for (i = container.Begin (); i != container.End (); ++i) | 123 * for (i = container.Begin (); i != container.End (); ++i) |
124 * { | 124 * { |
125 * (*i)->method (); // some EnergyHarvester method | 125 * (*i)->method (); // some EnergyHarvester method |
126 * } | 126 * } |
127 * \endcode | 127 * \endcode |
128 */ | 128 */ |
129 Iterator End (void) const; | 129 Iterator End (void) const; |
130 ········ | 130 |
131 /** | 131 /** |
132 * \brief Get the number of Ptr<EnergyHarvester> stored in this containe
r. | 132 * \brief Get the number of Ptr<EnergyHarvester> stored in this container. |
133 * | 133 * |
134 * \returns The number of Ptr<EnergyHarvester> stored in this container. | 134 * \returns The number of Ptr<EnergyHarvester> stored in this container. |
135 */ | 135 */ |
136 uint32_t GetN (void) const; | 136 uint32_t GetN (void) const; |
137 ········ | 137 |
138 /** | 138 /** |
139 * \brief Get the i-th Ptr<EnergyHarvester> stored in this container. | 139 * \brief Get the i-th Ptr<EnergyHarvester> stored in this container. |
140 * | 140 * |
141 * \param i Index of the requested Ptr<EnergyHarvester>. | 141 * \param i Index of the requested Ptr<EnergyHarvester>. |
142 * \returns The requested Ptr<EnergyHarvester>. | 142 * \returns The requested Ptr<EnergyHarvester>. |
143 */ | 143 */ |
144 Ptr<EnergyHarvester> Get (uint32_t i) const; | 144 Ptr<EnergyHarvester> Get (uint32_t i) const; |
145 ········ | 145 |
146 /** | 146 /** |
147 * \param container Another EnergyHarvesterContainer. | 147 * \param container Another EnergyHarvesterContainer. |
148 * | 148 * |
149 * Appends the contents of another EnergyHarvesterContainer to the end o
f | 149 * Appends the contents of another EnergyHarvesterContainer to the end of |
150 * this EnergyHarvesterContainer. | 150 * this EnergyHarvesterContainer. |
151 */ | 151 */ |
152 void Add (EnergyHarvesterContainer container); | 152 void Add (EnergyHarvesterContainer container); |
153 ········ | 153 |
154 /** | 154 /** |
155 * \brief Append a single Ptr<EnergyHarvester> to the end of this contai
ner. | 155 * \brief Append a single Ptr<EnergyHarvester> to the end of this container. |
156 * | 156 * |
157 * \param harvester Pointer to an EnergyHarvester. | 157 * \param harvester Pointer to an EnergyHarvester. |
158 */ | 158 */ |
159 void Add (Ptr<EnergyHarvester> harvester); | 159 void Add (Ptr<EnergyHarvester> harvester); |
160 ········ | 160 |
161 /** | 161 /** |
162 * \brief Append a single Ptr<EnergyHarvester> referred to by its object | 162 * \brief Append a single Ptr<EnergyHarvester> referred to by its object |
163 * name to the end of this container. | 163 * name to the end of this container. |
164 * | 164 * |
165 * \param harvesterName Name of EnergyHarvester object. | 165 * \param harvesterName Name of EnergyHarvester object. |
166 */ | 166 */ |
167 void Add (std::string harvesterName); | 167 void Add (std::string harvesterName); |
168 ········ | 168 |
169 /** | 169 /** |
170 * \brief Removes all elements in the container. | 170 * \brief Removes all elements in the container. |
171 */ | 171 */ |
172 void Clear (void); | 172 void Clear (void); |
173 ········ | 173 |
174 private: | 174 private: |
175 virtual void DoDispose (void); | 175 virtual void DoDispose (void); |
176 ········ | 176 |
177 /** | 177 /** |
178 * \brief Calls Object::Initialize () for all EnergySource objects. | 178 * \brief Calls Object::Initialize () for all EnergySource objects. |
179 */ | 179 */ |
180 virtual void DoInitialize (void); | 180 virtual void DoInitialize (void); |
181 ········ | 181 |
182 private: | 182 private: |
183 std::vector< Ptr<EnergyHarvester> > m_harvesters; | 183 std::vector< Ptr<EnergyHarvester> > m_harvesters; |
184 ········ | 184 |
185 }; | 185 }; |
186 ···· | 186 ···· |
187 } // namespace ns3 | 187 } // namespace ns3 |
188 | 188 |
189 | 189 |
190 #endif /* defined(ENERGY_HARVESTER_CONTAINER_H) */ | 190 #endif /* defined(ENERGY_HARVESTER_CONTAINER_H) */ |
LEFT | RIGHT |