View | Details | Raw Unified | Return to bug 2780
Collapse All | Expand All

(-)a/src/core/model/object-factory.cc (-1 / +1 lines)
 Lines 61-67   ObjectFactory::SetTypeId (const char *tid) Link Here 
61
  m_tid = TypeId::LookupByName (tid);
61
  m_tid = TypeId::LookupByName (tid);
62
}
62
}
63
void
63
void
64
ObjectFactory::Set (std::string name, const AttributeValue &value)
64
ObjectFactory::DoSet (std::string name, const AttributeValue &value)
65
{
65
{
66
  NS_LOG_FUNCTION (this << name << &value);
66
  NS_LOG_FUNCTION (this << name << &value);
67
  if (name == "")
67
  if (name == "")
(-)a/src/core/model/object-factory.h (-53 / +54 lines)
 Lines 23-28    Link Here 
23
#include "attribute-construction-list.h"
23
#include "attribute-construction-list.h"
24
#include "object.h"
24
#include "object.h"
25
#include "type-id.h"
25
#include "type-id.h"
26
#include <map>
27
#include <functional>
28
#include <utility>
26
29
27
/**
30
/**
28
 * \file
31
 * \file
 Lines 75-84   public: Link Here 
75
  /**
78
  /**
76
   * Set an attribute to be set during construction.
79
   * Set an attribute to be set during construction.
77
   *
80
   *
78
   * \param [in] name The name of the attribute to set.
81
   * \param [in] args A sequence of name-value pairs of the attributes to set.
79
   * \param [in] value The value of the attribute to set.
82
   *
83
   * The args sequence can be made of any number of pairs, each consisting of a
84
   * name (of std::string type) followed by a value (of const AttributeValue & type).
80
   */
85
   */
81
  void Set (std::string name, const AttributeValue &value);
86
  template <typename... Args>
87
  void Set (Args&&... args);
82
88
83
  /**
89
  /**
84
   * Get the TypeId which will be created by this ObjectFactory.
90
   * Get the TypeId which will be created by this ObjectFactory.
 Lines 107-112   public: Link Here 
107
113
108
private:
114
private:
109
  /**
115
  /**
116
   * Set an attribute to be set during construction.
117
   *
118
   * \param [in] name The name of the attribute to set.
119
   * \param [in] value The value of the attribute to set.
120
   */
121
  void DoSet (std::string name, const AttributeValue &value);
122
  /**
123
   * Set all the attributes whose name-value pairs are stored in a tuple.
124
   *
125
   * \param [in] seq A sequence of values from 0 to (size_of_tuple/2)-1.
126
   * \param [in] tuple Tuple containing name-value pairs of the attributes to set.
127
   */
128
  template <std::size_t... Is, typename Tuple>
129
  void SetImpl (std::index_sequence<Is...> seq, Tuple tuple);
130
  /**
110
   * Print the factory configuration on an output stream.
131
   * Print the factory configuration on an output stream.
111
   *
132
   *
112
   * The configuration will be printed as a string with the form
133
   * The configuration will be printed as a string with the form
 Lines 147-185   std::istream & operator >> (std::istream &is, ObjectFactory &factory); Link Here 
147
 * Allocate an Object on the heap and initialize with a set of attributes.
168
 * Allocate an Object on the heap and initialize with a set of attributes.
148
 *
169
 *
149
 * \tparam T \explicit The requested Object type.
170
 * \tparam T \explicit The requested Object type.
150
 * \param [in] n1 Name of attribute
171
 * \param [in] args A sequence of name-value pairs of the attributes to set.
151
 * \param [in] v1 Value of attribute
152
 * \param [in] n2 Name of attribute
153
 * \param [in] v2 Value of attribute
154
 * \param [in] n3 Name of attribute
155
 * \param [in] v3 Value of attribute
156
 * \param [in] n4 Name of attribute
157
 * \param [in] v4 Value of attribute
158
 * \param [in] n5 Name of attribute
159
 * \param [in] v5 Value of attribute
160
 * \param [in] n6 Name of attribute
161
 * \param [in] v6 Value of attribute
162
 * \param [in] n7 Name of attribute
163
 * \param [in] v7 Value of attribute
164
 * \param [in] n8 Name of attribute
165
 * \param [in] v8 Value of attribute
166
 * \param [in] n9 Name of attribute
167
 * \param [in] v9 Value of attribute
168
 * \returns A pointer to a newly allocated object.
172
 * \returns A pointer to a newly allocated object.
173
 *
174
 * The args sequence can be made of any number of pairs, each consisting of a
175
 * name (of std::string type) followed by a value (of const AttributeValue & type).
169
 */
176
 */
170
template <typename T>
177
template <typename T, typename... Args>
171
Ptr<T> 
178
Ptr<T> 
172
CreateObjectWithAttributes
179
CreateObjectWithAttributes (Args... args);
173
  (std::string n1 = "", const AttributeValue & v1 = EmptyAttributeValue (),
174
   std::string n2 = "", const AttributeValue & v2 = EmptyAttributeValue (),
175
   std::string n3 = "", const AttributeValue & v3 = EmptyAttributeValue (),
176
   std::string n4 = "", const AttributeValue & v4 = EmptyAttributeValue (),
177
   std::string n5 = "", const AttributeValue & v5 = EmptyAttributeValue (),
178
   std::string n6 = "", const AttributeValue & v6 = EmptyAttributeValue (),
179
   std::string n7 = "", const AttributeValue & v7 = EmptyAttributeValue (),
180
   std::string n8 = "", const AttributeValue & v8 = EmptyAttributeValue (),
181
   std::string n9 = "", const AttributeValue & v9 = EmptyAttributeValue ()
182
   );
183
180
184
181
185
ATTRIBUTE_HELPER_HEADER (ObjectFactory);
182
ATTRIBUTE_HELPER_HEADER (ObjectFactory);
 Lines 201-233   ObjectFactory::Create (void) const Link Here 
201
  return object->GetObject<T> ();
198
  return object->GetObject<T> ();
202
}
199
}
203
200
204
template <typename T>
201
template <std::size_t... Is, typename Tuple>
202
void
203
ObjectFactory::SetImpl (std::index_sequence<Is...>, Tuple tuple)
204
{
205
  std::map<std::string, const AttributeValue &> m {
206
        std::make_pair (std::get<2*Is> (tuple), std::cref (std::get<2*Is+1> (tuple)))...
207
  };
208
  for (auto p : m)
209
    {
210
      DoSet (p.first, p.second);
211
    }
212
}
213
214
template <typename... Args>
215
void
216
ObjectFactory::Set (Args&&... args)
217
{
218
  static_assert (sizeof...(args) % 2 == 0, "ObjectFactory::Set requires an even number of arguments");
219
  SetImpl (std::make_index_sequence<sizeof...(args)/2>{}, std::forward_as_tuple (args...));
220
}
221
222
template <typename T, typename... Args>
205
Ptr<T> 
223
Ptr<T> 
206
CreateObjectWithAttributes (std::string n1, const AttributeValue & v1,
224
CreateObjectWithAttributes (Args... args)
207
                            std::string n2, const AttributeValue & v2,
208
                            std::string n3, const AttributeValue & v3,
209
                            std::string n4, const AttributeValue & v4,
210
                            std::string n5, const AttributeValue & v5,
211
                            std::string n6, const AttributeValue & v6,
212
                            std::string n7, const AttributeValue & v7,
213
                            std::string n8, const AttributeValue & v8,
214
                            std::string n9, const AttributeValue & v9)
215
{
225
{
216
  ObjectFactory factory;
226
  ObjectFactory factory;
217
  factory.SetTypeId (T::GetTypeId ());
227
  factory.SetTypeId (T::GetTypeId ());
218
  factory.Set(n1, v1);
228
  factory.Set (args...);
219
  factory.Set(n2, v2);
220
  factory.Set(n3, v3);
221
  factory.Set(n4, v4);
222
  factory.Set(n5, v5);
223
  factory.Set(n6, v6);
224
  factory.Set(n7, v7);
225
  factory.Set(n8, v8);
226
  factory.Set(n9, v9);
227
  return factory.Create<T> ();
229
  return factory.Create<T> ();
228
}
230
}
229
231
230
231
} // namespace ns3
232
} // namespace ns3
232
233
233
#endif /* OBJECT_FACTORY_H */
234
#endif /* OBJECT_FACTORY_H */
(-)a/src/traffic-control/helper/traffic-control-helper.cc (-238 lines)
 Lines 21-27    Link Here 
21
#include "ns3/log.h"
21
#include "ns3/log.h"
22
#include "ns3/abort.h"
22
#include "ns3/abort.h"
23
#include "ns3/queue-limits.h"
23
#include "ns3/queue-limits.h"
24
#include "ns3/queue.h"
25
#include "ns3/net-device-queue-interface.h"
24
#include "ns3/net-device-queue-interface.h"
26
#include "ns3/uinteger.h"
25
#include "ns3/uinteger.h"
27
#include "ns3/pointer.h"
26
#include "ns3/pointer.h"
 Lines 115-357   TrafficControlHelper::Default (void) Link Here 
115
  return helper;
114
  return helper;
116
}
115
}
117
116
118
uint16_t
119
TrafficControlHelper::SetRootQueueDisc (std::string type,
120
                                        std::string n01, const AttributeValue& v01,
121
                                        std::string n02, const AttributeValue& v02,
122
                                        std::string n03, const AttributeValue& v03,
123
                                        std::string n04, const AttributeValue& v04,
124
                                        std::string n05, const AttributeValue& v05,
125
                                        std::string n06, const AttributeValue& v06,
126
                                        std::string n07, const AttributeValue& v07,
127
                                        std::string n08, const AttributeValue& v08,
128
                                        std::string n09, const AttributeValue& v09,
129
                                        std::string n10, const AttributeValue& v10,
130
                                        std::string n11, const AttributeValue& v11,
131
                                        std::string n12, const AttributeValue& v12,
132
                                        std::string n13, const AttributeValue& v13,
133
                                        std::string n14, const AttributeValue& v14,
134
                                        std::string n15, const AttributeValue& v15)
135
{
136
  NS_ABORT_MSG_UNLESS (m_queueDiscFactory.empty (), "A root queue disc has been already added to this factory");
137
138
  ObjectFactory factory;
139
  factory.SetTypeId (type);
140
  factory.Set (n01, v01);
141
  factory.Set (n02, v02);
142
  factory.Set (n03, v03);
143
  factory.Set (n04, v04);
144
  factory.Set (n05, v05);
145
  factory.Set (n06, v06);
146
  factory.Set (n07, v07);
147
  factory.Set (n08, v08);
148
  factory.Set (n09, v09);
149
  factory.Set (n10, v10);
150
  factory.Set (n11, v11);
151
  factory.Set (n12, v12);
152
  factory.Set (n13, v13);
153
  factory.Set (n14, v14);
154
  factory.Set (n15, v15);
155
156
  m_queueDiscFactory.push_back (QueueDiscFactory (factory));
157
  return 0;
158
}
159
160
void
161
TrafficControlHelper::AddInternalQueues (uint16_t handle, uint16_t count, std::string type,
162
                                         std::string n01, const AttributeValue& v01,
163
                                         std::string n02, const AttributeValue& v02,
164
                                         std::string n03, const AttributeValue& v03,
165
                                         std::string n04, const AttributeValue& v04,
166
                                         std::string n05, const AttributeValue& v05,
167
                                         std::string n06, const AttributeValue& v06,
168
                                         std::string n07, const AttributeValue& v07,
169
                                         std::string n08, const AttributeValue& v08)
170
{
171
  NS_ABORT_MSG_IF (handle >= m_queueDiscFactory.size (), "A queue disc with handle "
172
                   << handle << " does not exist");
173
174
  QueueBase::AppendItemTypeIfNotPresent (type, "QueueDiscItem");
175
176
  ObjectFactory factory;
177
  factory.SetTypeId (type);
178
  factory.Set (n01, v01);
179
  factory.Set (n02, v02);
180
  factory.Set (n03, v03);
181
  factory.Set (n04, v04);
182
  factory.Set (n05, v05);
183
  factory.Set (n06, v06);
184
  factory.Set (n07, v07);
185
  factory.Set (n08, v08);
186
187
  for (int i = 0; i < count; i++)
188
    {
189
      m_queueDiscFactory[handle].AddInternalQueue (factory);
190
    }
191
}
192
193
void
194
TrafficControlHelper::AddPacketFilter (uint16_t handle, std::string type,
195
                                       std::string n01, const AttributeValue& v01,
196
                                       std::string n02, const AttributeValue& v02,
197
                                       std::string n03, const AttributeValue& v03,
198
                                       std::string n04, const AttributeValue& v04,
199
                                       std::string n05, const AttributeValue& v05,
200
                                       std::string n06, const AttributeValue& v06,
201
                                       std::string n07, const AttributeValue& v07,
202
                                       std::string n08, const AttributeValue& v08)
203
{
204
  NS_ABORT_MSG_IF (handle >= m_queueDiscFactory.size (), "A queue disc with handle "
205
                   << handle << " does not exist");
206
207
  ObjectFactory factory;
208
  factory.SetTypeId (type);
209
  factory.Set (n01, v01);
210
  factory.Set (n02, v02);
211
  factory.Set (n03, v03);
212
  factory.Set (n04, v04);
213
  factory.Set (n05, v05);
214
  factory.Set (n06, v06);
215
  factory.Set (n07, v07);
216
  factory.Set (n08, v08);
217
218
  m_queueDiscFactory[handle].AddPacketFilter (factory);
219
}
220
221
TrafficControlHelper::ClassIdList
222
TrafficControlHelper::AddQueueDiscClasses (uint16_t handle, uint16_t count, std::string type,
223
                                           std::string n01, const AttributeValue& v01,
224
                                           std::string n02, const AttributeValue& v02,
225
                                           std::string n03, const AttributeValue& v03,
226
                                           std::string n04, const AttributeValue& v04,
227
                                           std::string n05, const AttributeValue& v05,
228
                                           std::string n06, const AttributeValue& v06,
229
                                           std::string n07, const AttributeValue& v07,
230
                                           std::string n08, const AttributeValue& v08)
231
{
232
  NS_ABORT_MSG_IF (handle >= m_queueDiscFactory.size (), "A queue disc with handle "
233
                   << handle << " does not exist");
234
235
  ObjectFactory factory;
236
  factory.SetTypeId (type);
237
  factory.Set (n01, v01);
238
  factory.Set (n02, v02);
239
  factory.Set (n03, v03);
240
  factory.Set (n04, v04);
241
  factory.Set (n05, v05);
242
  factory.Set (n06, v06);
243
  factory.Set (n07, v07);
244
  factory.Set (n08, v08);
245
246
  ClassIdList list;
247
  uint16_t classId;
248
249
  for (int i = 0; i < count; i++)
250
    {
251
      classId = m_queueDiscFactory[handle].AddQueueDiscClass (factory);
252
      list.push_back (classId);
253
    }
254
  return list;
255
}
256
257
uint16_t
258
TrafficControlHelper::AddChildQueueDisc (uint16_t handle, uint16_t classId, std::string type,
259
                                         std::string n01, const AttributeValue& v01,
260
                                         std::string n02, const AttributeValue& v02,
261
                                         std::string n03, const AttributeValue& v03,
262
                                         std::string n04, const AttributeValue& v04,
263
                                         std::string n05, const AttributeValue& v05,
264
                                         std::string n06, const AttributeValue& v06,
265
                                         std::string n07, const AttributeValue& v07,
266
                                         std::string n08, const AttributeValue& v08,
267
                                         std::string n09, const AttributeValue& v09,
268
                                         std::string n10, const AttributeValue& v10,
269
                                         std::string n11, const AttributeValue& v11,
270
                                         std::string n12, const AttributeValue& v12,
271
                                         std::string n13, const AttributeValue& v13,
272
                                         std::string n14, const AttributeValue& v14,
273
                                         std::string n15, const AttributeValue& v15)
274
{
275
  NS_ABORT_MSG_IF (handle >= m_queueDiscFactory.size (), "A queue disc with handle "
276
                   << handle << " does not exist");
277
278
  ObjectFactory factory;
279
  factory.SetTypeId (type);
280
  factory.Set (n01, v01);
281
  factory.Set (n02, v02);
282
  factory.Set (n03, v03);
283
  factory.Set (n04, v04);
284
  factory.Set (n05, v05);
285
  factory.Set (n06, v06);
286
  factory.Set (n07, v07);
287
  factory.Set (n08, v08);
288
  factory.Set (n09, v09);
289
  factory.Set (n10, v10);
290
  factory.Set (n11, v11);
291
  factory.Set (n12, v12);
292
  factory.Set (n13, v13);
293
  factory.Set (n14, v14);
294
  factory.Set (n15, v15);
295
296
  uint16_t childHandle = m_queueDiscFactory.size ();
297
  m_queueDiscFactory.push_back (QueueDiscFactory (factory));
298
  m_queueDiscFactory[handle].SetChildQueueDisc (classId, childHandle);
299
300
  return childHandle;
301
}
302
303
TrafficControlHelper::HandleList
304
TrafficControlHelper::AddChildQueueDiscs (uint16_t handle, const TrafficControlHelper::ClassIdList &classes,
305
                                          std::string type,
306
                                          std::string n01, const AttributeValue& v01,
307
                                          std::string n02, const AttributeValue& v02,
308
                                          std::string n03, const AttributeValue& v03,
309
                                          std::string n04, const AttributeValue& v04,
310
                                          std::string n05, const AttributeValue& v05,
311
                                          std::string n06, const AttributeValue& v06,
312
                                          std::string n07, const AttributeValue& v07,
313
                                          std::string n08, const AttributeValue& v08,
314
                                          std::string n09, const AttributeValue& v09,
315
                                          std::string n10, const AttributeValue& v10,
316
                                          std::string n11, const AttributeValue& v11,
317
                                          std::string n12, const AttributeValue& v12,
318
                                          std::string n13, const AttributeValue& v13,
319
                                          std::string n14, const AttributeValue& v14,
320
                                          std::string n15, const AttributeValue& v15)
321
{
322
  HandleList list;
323
  for (ClassIdList::const_iterator c = classes.begin (); c != classes.end (); c++)
324
    {
325
      uint16_t childHandle = AddChildQueueDisc (handle, *c, type, n01, v01, n02, v02, n03, v03,
326
                                                n04, v04, n05, v05, n06, v06, n07, v07, n08, v08, n09, v09,
327
                                                n10, v10, n11, v11, n12, v12, n13, v13, n14, v14, n15, v15);
328
      list.push_back (childHandle);
329
    }
330
  return list;
331
}
332
333
void
334
TrafficControlHelper::SetQueueLimits (std::string type,
335
                                      std::string n01, const AttributeValue& v01,
336
                                      std::string n02, const AttributeValue& v02,
337
                                      std::string n03, const AttributeValue& v03,
338
                                      std::string n04, const AttributeValue& v04,
339
                                      std::string n05, const AttributeValue& v05,
340
                                      std::string n06, const AttributeValue& v06,
341
                                      std::string n07, const AttributeValue& v07,
342
                                      std::string n08, const AttributeValue& v08)
343
{
344
  m_queueLimitsFactory.SetTypeId (type);
345
  m_queueLimitsFactory.Set (n01, v01);
346
  m_queueLimitsFactory.Set (n02, v02);
347
  m_queueLimitsFactory.Set (n03, v03);
348
  m_queueLimitsFactory.Set (n04, v04);
349
  m_queueLimitsFactory.Set (n05, v05);
350
  m_queueLimitsFactory.Set (n06, v06);
351
  m_queueLimitsFactory.Set (n07, v07);
352
  m_queueLimitsFactory.Set (n08, v08);
353
}
354
355
QueueDiscContainer
117
QueueDiscContainer
356
TrafficControlHelper::Install (Ptr<NetDevice> d)
118
TrafficControlHelper::Install (Ptr<NetDevice> d)
357
{
119
{
(-)a/src/traffic-control/helper/traffic-control-helper.h (-231 / +134 lines)
 Lines 26-31    Link Here 
26
#include "ns3/object-factory.h"
26
#include "ns3/object-factory.h"
27
#include "ns3/net-device-container.h"
27
#include "ns3/net-device-container.h"
28
#include "ns3/queue-disc-container.h"
28
#include "ns3/queue-disc-container.h"
29
#include "ns3/queue.h"
29
30
30
namespace ns3 {
31
namespace ns3 {
31
32
 Lines 139-192   public: Link Here 
139
   * attributes, use the AddInternalQueue, AddPacketFilter and AddChildQueueDisc methods.
140
   * attributes, use the AddInternalQueue, AddPacketFilter and AddChildQueueDisc methods.
140
   *
141
   *
141
   * \param type the type of queue disc
142
   * \param type the type of queue disc
142
   * \param n01 the name of the attribute to set on the queue disc
143
   * \param v01 the value of the attribute to set on the queue disc
144
   * \param n02 the name of the attribute to set on the queue disc
145
   * \param v02 the value of the attribute to set on the queue disc
146
   * \param n03 the name of the attribute to set on the queue disc
147
   * \param v03 the value of the attribute to set on the queue disc
148
   * \param n04 the name of the attribute to set on the queue disc
149
   * \param v04 the value of the attribute to set on the queue disc
150
   * \param n05 the name of the attribute to set on the queue disc
151
   * \param v05 the value of the attribute to set on the queue disc
152
   * \param n06 the name of the attribute to set on the queue disc
153
   * \param v06 the value of the attribute to set on the queue disc
154
   * \param n07 the name of the attribute to set on the queue disc
155
   * \param v07 the value of the attribute to set on the queue disc
156
   * \param n08 the name of the attribute to set on the queue disc
157
   * \param v08 the value of the attribute to set on the queue disc
158
   * \param n09 the name of the attribute to set on the queue disc
159
   * \param v09 the value of the attribute to set on the queue disc
160
   * \param n10 the name of the attribute to set on the queue disc
161
   * \param v10 the value of the attribute to set on the queue disc
162
   * \param n11 the name of the attribute to set on the queue disc
163
   * \param v11 the value of the attribute to set on the queue disc
164
   * \param n12 the name of the attribute to set on the queue disc
165
   * \param v12 the value of the attribute to set on the queue disc
166
   * \param n13 the name of the attribute to set on the queue disc
167
   * \param v13 the value of the attribute to set on the queue disc
168
   * \param n14 the name of the attribute to set on the queue disc
169
   * \param v14 the value of the attribute to set on the queue disc
170
   * \param n15 the name of the attribute to set on the queue disc
171
   * \param v15 the value of the attribute to set on the queue disc
143
   * \param v15 the value of the attribute to set on the queue disc
172
   * \return the handle of the root queue disc (zero)
144
   * \return the handle of the root queue disc (zero)
173
   */
145
   */
174
  uint16_t SetRootQueueDisc (std::string type,
146
  template <typename... Args>
175
                             std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
147
  uint16_t SetRootQueueDisc (std::string type, Args... args);
176
                             std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
177
                             std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
178
                             std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
179
                             std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
180
                             std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
181
                             std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
182
                             std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue (),
183
                             std::string n09 = "", const AttributeValue &v09 = EmptyAttributeValue (),
184
                             std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue (),
185
                             std::string n11 = "", const AttributeValue &v11 = EmptyAttributeValue (),
186
                             std::string n12 = "", const AttributeValue &v12 = EmptyAttributeValue (),
187
                             std::string n13 = "", const AttributeValue &v13 = EmptyAttributeValue (),
188
                             std::string n14 = "", const AttributeValue &v14 = EmptyAttributeValue (),
189
                             std::string n15 = "", const AttributeValue &v15 = EmptyAttributeValue ());
190
148
191
  /**
149
  /**
192
   * Helper function used to add the given number of internal queues (of the given
150
   * Helper function used to add the given number of internal queues (of the given
 Lines 196-226   public: Link Here 
196
   * \param count the number of queues to add
154
   * \param count the number of queues to add
197
   * \param type the type of queue
155
   * \param type the type of queue
198
   * \param n01 the name of the attribute to set on the queue
156
   * \param n01 the name of the attribute to set on the queue
199
   * \param v01 the value of the attribute to set on the queue
200
   * \param n02 the name of the attribute to set on the queue
201
   * \param v02 the value of the attribute to set on the queue
202
   * \param n03 the name of the attribute to set on the queue
203
   * \param v03 the value of the attribute to set on the queue
204
   * \param n04 the name of the attribute to set on the queue
205
   * \param v04 the value of the attribute to set on the queue
206
   * \param n05 the name of the attribute to set on the queue
207
   * \param v05 the value of the attribute to set on the queue
208
   * \param n06 the name of the attribute to set on the queue
209
   * \param v06 the value of the attribute to set on the queue
210
   * \param n07 the name of the attribute to set on the queue
211
   * \param v07 the value of the attribute to set on the queue
212
   * \param n08 the name of the attribute to set on the queue
213
   * \param v08 the value of the attribute to set on the queue
214
   */
157
   */
215
  void AddInternalQueues (uint16_t handle, uint16_t count, std::string type,
158
  template <typename... Args>
216
                          std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
159
  void AddInternalQueues (uint16_t handle, uint16_t count, std::string type, Args... args);
217
                          std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
218
                          std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
219
                          std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
220
                          std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
221
                          std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
222
                          std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
223
                          std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue ());
224
160
225
  /**
161
  /**
226
   * Helper function used to add a packet filter (of the given type and with
162
   * Helper function used to add a packet filter (of the given type and with
 Lines 229-259   public: Link Here 
229
   * \param handle the handle of the parent queue disc
165
   * \param handle the handle of the parent queue disc
230
   * \param type the type of packet filter
166
   * \param type the type of packet filter
231
   * \param n01 the name of the attribute to set on the packet filter
167
   * \param n01 the name of the attribute to set on the packet filter
232
   * \param v01 the value of the attribute to set on the packet filter
233
   * \param n02 the name of the attribute to set on the packet filter
234
   * \param v02 the value of the attribute to set on the packet filter
235
   * \param n03 the name of the attribute to set on the packet filter
236
   * \param v03 the value of the attribute to set on the packet filter
237
   * \param n04 the name of the attribute to set on the packet filter
238
   * \param v04 the value of the attribute to set on the packet filter
239
   * \param n05 the name of the attribute to set on the packet filter
240
   * \param v05 the value of the attribute to set on the packet filter
241
   * \param n06 the name of the attribute to set on the packet filter
242
   * \param v06 the value of the attribute to set on the packet filter
243
   * \param n07 the name of the attribute to set on the packet filter
244
   * \param v07 the value of the attribute to set on the packet filter
245
   * \param n08 the name of the attribute to set on the packet filter
246
   * \param v08 the value of the attribute to set on the packet filter
247
   */
168
   */
248
  void AddPacketFilter (uint16_t handle, std::string type,
169
  template <typename... Args>
249
                        std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
170
  void AddPacketFilter (uint16_t handle, std::string type, Args... args);
250
                        std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
251
                        std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
252
                        std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
253
                        std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
254
                        std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
255
                        std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
256
                        std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue ());
257
171
258
  /**
172
  /**
259
   * Container type for Class IDs
173
   * Container type for Class IDs
 Lines 268-299   public: Link Here 
268
   * \param count the number of queue disc classes to add
182
   * \param count the number of queue disc classes to add
269
   * \param type the type of queue disc class
183
   * \param type the type of queue disc class
270
   * \param n01 the name of the attribute to set on the queue disc class
184
   * \param n01 the name of the attribute to set on the queue disc class
271
   * \param v01 the value of the attribute to set on the queue disc class
272
   * \param n02 the name of the attribute to set on the queue disc class
273
   * \param v02 the value of the attribute to set on the queue disc class
274
   * \param n03 the name of the attribute to set on the queue disc class
275
   * \param v03 the value of the attribute to set on the queue disc class
276
   * \param n04 the name of the attribute to set on the queue disc class
277
   * \param v04 the value of the attribute to set on the queue disc class
278
   * \param n05 the name of the attribute to set on the queue disc class
279
   * \param v05 the value of the attribute to set on the queue disc class
280
   * \param n06 the name of the attribute to set on the queue disc class
281
   * \param v06 the value of the attribute to set on the queue disc class
282
   * \param n07 the name of the attribute to set on the queue disc class
283
   * \param v07 the value of the attribute to set on the queue disc class
284
   * \param n08 the name of the attribute to set on the queue disc class
285
   * \param v08 the value of the attribute to set on the queue disc class
286
   * \return the list of class IDs
185
   * \return the list of class IDs
287
   */
186
   */
288
  ClassIdList AddQueueDiscClasses (uint16_t handle, uint16_t count, std::string type,
187
  template <typename... Args>
289
                                   std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
188
  ClassIdList AddQueueDiscClasses (uint16_t handle, uint16_t count, std::string type, Args... args);
290
                                   std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
291
                                   std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
292
                                   std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
293
                                   std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
294
                                   std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
295
                                   std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
296
                                   std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue ());
297
189
298
  /**
190
  /**
299
   * Helper function used to attach a child queue disc (of the given type and with
191
   * Helper function used to attach a child queue disc (of the given type and with
 Lines 304-356   public: Link Here 
304
   * \param classId the class ID of the class to attach the queue disc to
196
   * \param classId the class ID of the class to attach the queue disc to
305
   * \param type the type of queue disc
197
   * \param type the type of queue disc
306
   * \param n01 the name of the attribute to set on the queue disc
198
   * \param n01 the name of the attribute to set on the queue disc
307
   * \param v01 the value of the attribute to set on the queue disc
308
   * \param n02 the name of the attribute to set on the queue disc
309
   * \param v02 the value of the attribute to set on the queue disc
310
   * \param n03 the name of the attribute to set on the queue disc
311
   * \param v03 the value of the attribute to set on the queue disc
312
   * \param n04 the name of the attribute to set on the queue disc
313
   * \param v04 the value of the attribute to set on the queue disc
314
   * \param n05 the name of the attribute to set on the queue disc
315
   * \param v05 the value of the attribute to set on the queue disc
316
   * \param n06 the name of the attribute to set on the queue disc
317
   * \param v06 the value of the attribute to set on the queue disc
318
   * \param n07 the name of the attribute to set on the queue disc
319
   * \param v07 the value of the attribute to set on the queue disc
320
   * \param n08 the name of the attribute to set on the queue disc
321
   * \param v08 the value of the attribute to set on the queue disc
322
   * \param n09 the name of the attribute to set on the queue disc
323
   * \param v09 the value of the attribute to set on the queue disc
324
   * \param n10 the name of the attribute to set on the queue disc
325
   * \param v10 the value of the attribute to set on the queue disc
326
   * \param n11 the name of the attribute to set on the queue disc
327
   * \param v11 the value of the attribute to set on the queue disc
328
   * \param n12 the name of the attribute to set on the queue disc
329
   * \param v12 the value of the attribute to set on the queue disc
330
   * \param n13 the name of the attribute to set on the queue disc
331
   * \param v13 the value of the attribute to set on the queue disc
332
   * \param n14 the name of the attribute to set on the queue disc
333
   * \param v14 the value of the attribute to set on the queue disc
334
   * \param n15 the name of the attribute to set on the queue disc
335
   * \param v15 the value of the attribute to set on the queue disc
336
   * \return the handle of the created child queue disc
199
   * \return the handle of the created child queue disc
337
   */
200
   */
338
  uint16_t AddChildQueueDisc (uint16_t handle, uint16_t classId, std::string type,
201
  template <typename... Args>
339
                              std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
202
  uint16_t AddChildQueueDisc (uint16_t handle, uint16_t classId, std::string type, Args... args);
340
                              std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
341
                              std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
342
                              std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
343
                              std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
344
                              std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
345
                              std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
346
                              std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue (),
347
                              std::string n09 = "", const AttributeValue &v09 = EmptyAttributeValue (),
348
                              std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue (),
349
                              std::string n11 = "", const AttributeValue &v11 = EmptyAttributeValue (),
350
                              std::string n12 = "", const AttributeValue &v12 = EmptyAttributeValue (),
351
                              std::string n13 = "", const AttributeValue &v13 = EmptyAttributeValue (),
352
                              std::string n14 = "", const AttributeValue &v14 = EmptyAttributeValue (),
353
                              std::string n15 = "", const AttributeValue &v15 = EmptyAttributeValue ());
354
203
355
  /**
204
  /**
356
   * Container type for Handlers
205
   * Container type for Handlers
 Lines 366-418   public: Link Here 
366
   * \param classes the class IDs of the classes to attach a queue disc to
215
   * \param classes the class IDs of the classes to attach a queue disc to
367
   * \param type the type of queue disc
216
   * \param type the type of queue disc
368
   * \param n01 the name of the attribute to set on the queue disc
217
   * \param n01 the name of the attribute to set on the queue disc
369
   * \param v01 the value of the attribute to set on the queue disc
370
   * \param n02 the name of the attribute to set on the queue disc
371
   * \param v02 the value of the attribute to set on the queue disc
372
   * \param n03 the name of the attribute to set on the queue disc
373
   * \param v03 the value of the attribute to set on the queue disc
374
   * \param n04 the name of the attribute to set on the queue disc
375
   * \param v04 the value of the attribute to set on the queue disc
376
   * \param n05 the name of the attribute to set on the queue disc
377
   * \param v05 the value of the attribute to set on the queue disc
378
   * \param n06 the name of the attribute to set on the queue disc
379
   * \param v06 the value of the attribute to set on the queue disc
380
   * \param n07 the name of the attribute to set on the queue disc
381
   * \param v07 the value of the attribute to set on the queue disc
382
   * \param n08 the name of the attribute to set on the queue disc
383
   * \param v08 the value of the attribute to set on the queue disc
384
   * \param n09 the name of the attribute to set on the queue disc
385
   * \param v09 the value of the attribute to set on the queue disc
386
   * \param n10 the name of the attribute to set on the queue disc
387
   * \param v10 the value of the attribute to set on the queue disc
388
   * \param n11 the name of the attribute to set on the queue disc
389
   * \param v11 the value of the attribute to set on the queue disc
390
   * \param n12 the name of the attribute to set on the queue disc
391
   * \param v12 the value of the attribute to set on the queue disc
392
   * \param n13 the name of the attribute to set on the queue disc
393
   * \param v13 the value of the attribute to set on the queue disc
394
   * \param n14 the name of the attribute to set on the queue disc
395
   * \param v14 the value of the attribute to set on the queue disc
396
   * \param n15 the name of the attribute to set on the queue disc
397
   * \param v15 the value of the attribute to set on the queue disc
398
   * \return the list of handles of the created child queue discs
218
   * \return the list of handles of the created child queue discs
399
   */
219
   */
400
  HandleList AddChildQueueDiscs (uint16_t handle, const ClassIdList &classes, std::string type,
220
  template <typename... Args>
401
                                 std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
221
  HandleList AddChildQueueDiscs (uint16_t handle, const ClassIdList &classes, std::string type, Args... args);
402
                                 std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
403
                                 std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
404
                                 std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
405
                                 std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
406
                                 std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
407
                                 std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
408
                                 std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue (),
409
                                 std::string n09 = "", const AttributeValue &v09 = EmptyAttributeValue (),
410
                                 std::string n10 = "", const AttributeValue &v10 = EmptyAttributeValue (),
411
                                 std::string n11 = "", const AttributeValue &v11 = EmptyAttributeValue (),
412
                                 std::string n12 = "", const AttributeValue &v12 = EmptyAttributeValue (),
413
                                 std::string n13 = "", const AttributeValue &v13 = EmptyAttributeValue (),
414
                                 std::string n14 = "", const AttributeValue &v14 = EmptyAttributeValue (),
415
                                 std::string n15 = "", const AttributeValue &v15 = EmptyAttributeValue ());
416
222
417
  /**
223
  /**
418
   * Helper function used to add a queue limits object to the transmission
224
   * Helper function used to add a queue limits object to the transmission
 Lines 420-450   public: Link Here 
420
   *
226
   *
421
   * \param type the type of queue
227
   * \param type the type of queue
422
   * \param n01 the name of the attribute to set on the queue limits object
228
   * \param n01 the name of the attribute to set on the queue limits object
423
   * \param v01 the value of the attribute to set on the queue limits object
424
   * \param n02 the name of the attribute to set on the queue limits object
425
   * \param v02 the value of the attribute to set on the queue limits object
426
   * \param n03 the name of the attribute to set on the queue limits object
427
   * \param v03 the value of the attribute to set on the queue limits object
428
   * \param n04 the name of the attribute to set on the queue limits object
429
   * \param v04 the value of the attribute to set on the queue limits object
430
   * \param n05 the name of the attribute to set on the queue limits object
431
   * \param v05 the value of the attribute to set on the queue limits object
432
   * \param n06 the name of the attribute to set on the queue limits object
433
   * \param v06 the value of the attribute to set on the queue limits object
434
   * \param n07 the name of the attribute to set on the queue limits object
435
   * \param v07 the value of the attribute to set on the queue limits object
436
   * \param n08 the name of the attribute to set on the queue limits object
437
   * \param v08 the value of the attribute to set on the queue limits object
438
   */
229
   */
439
  void SetQueueLimits (std::string type,
230
  template <typename... Args>
440
                       std::string n01 = "", const AttributeValue &v01 = EmptyAttributeValue (),
231
  void SetQueueLimits (std::string type, Args... args);
441
                       std::string n02 = "", const AttributeValue &v02 = EmptyAttributeValue (),
442
                       std::string n03 = "", const AttributeValue &v03 = EmptyAttributeValue (),
443
                       std::string n04 = "", const AttributeValue &v04 = EmptyAttributeValue (),
444
                       std::string n05 = "", const AttributeValue &v05 = EmptyAttributeValue (),
445
                       std::string n06 = "", const AttributeValue &v06 = EmptyAttributeValue (),
446
                       std::string n07 = "", const AttributeValue &v07 = EmptyAttributeValue (),
447
                       std::string n08 = "", const AttributeValue &v08 = EmptyAttributeValue ());
448
232
449
  /**
233
  /**
450
   * \param c set of devices
234
   * \param c set of devices
 Lines 501-504   private: Link Here 
501
285
502
} // namespace ns3
286
} // namespace ns3
503
287
288
289
/***************************************************************
290
 *  Implementation of the templates declared above.
291
 ***************************************************************/
292
293
namespace ns3 {
294
295
template <typename... Args>
296
uint16_t
297
TrafficControlHelper::SetRootQueueDisc (std::string type, Args... args)
298
{
299
  NS_ABORT_MSG_UNLESS (m_queueDiscFactory.empty (), "A root queue disc has been already added to this factory");
300
301
  ObjectFactory factory;
302
  factory.SetTypeId (type);
303
  factory.Set (args...);
304
305
  m_queueDiscFactory.push_back (QueueDiscFactory (factory));
306
  return 0;
307
}
308
309
template <typename... Args>
310
void
311
TrafficControlHelper::AddInternalQueues (uint16_t handle, uint16_t count, std::string type, Args... args)
312
{
313
  NS_ABORT_MSG_IF (handle >= m_queueDiscFactory.size (), "A queue disc with handle "
314
                   << handle << " does not exist");
315
316
  QueueBase::AppendItemTypeIfNotPresent (type, "QueueDiscItem");
317
318
  ObjectFactory factory;
319
  factory.SetTypeId (type);
320
  factory.Set (args...);
321
322
  for (int i = 0; i < count; i++)
323
    {
324
      m_queueDiscFactory[handle].AddInternalQueue (factory);
325
    }
326
}
327
328
template <typename... Args>
329
void
330
TrafficControlHelper::AddPacketFilter (uint16_t handle, std::string type, Args... args)
331
{
332
  NS_ABORT_MSG_IF (handle >= m_queueDiscFactory.size (), "A queue disc with handle "
333
                   << handle << " does not exist");
334
335
  ObjectFactory factory;
336
  factory.SetTypeId (type);
337
  factory.Set (args...);
338
339
  m_queueDiscFactory[handle].AddPacketFilter (factory);
340
}
341
342
template <typename... Args>
343
TrafficControlHelper::ClassIdList
344
TrafficControlHelper::AddQueueDiscClasses (uint16_t handle, uint16_t count, std::string type, Args... args)
345
{
346
  NS_ABORT_MSG_IF (handle >= m_queueDiscFactory.size (), "A queue disc with handle "
347
                   << handle << " does not exist");
348
349
  ObjectFactory factory;
350
  factory.SetTypeId (type);
351
  factory.Set (args...);
352
353
  ClassIdList list;
354
  uint16_t classId;
355
356
  for (int i = 0; i < count; i++)
357
    {
358
      classId = m_queueDiscFactory[handle].AddQueueDiscClass (factory);
359
      list.push_back (classId);
360
    }
361
  return list;
362
}
363
364
template <typename... Args>
365
uint16_t
366
TrafficControlHelper::AddChildQueueDisc (uint16_t handle, uint16_t classId, std::string type, Args... args)
367
{
368
  NS_ABORT_MSG_IF (handle >= m_queueDiscFactory.size (), "A queue disc with handle "
369
                   << handle << " does not exist");
370
371
  ObjectFactory factory;
372
  factory.SetTypeId (type);
373
  factory.Set (args...);
374
375
  uint16_t childHandle = m_queueDiscFactory.size ();
376
  m_queueDiscFactory.push_back (QueueDiscFactory (factory));
377
  m_queueDiscFactory[handle].SetChildQueueDisc (classId, childHandle);
378
379
  return childHandle;
380
}
381
382
template <typename... Args>
383
TrafficControlHelper::HandleList
384
TrafficControlHelper::AddChildQueueDiscs (uint16_t handle, const TrafficControlHelper::ClassIdList &classes,
385
                                          std::string type, Args... args)
386
{
387
  HandleList list;
388
  for (ClassIdList::const_iterator c = classes.begin (); c != classes.end (); c++)
389
    {
390
      uint16_t childHandle = AddChildQueueDisc (handle, *c, type, args...);
391
      list.push_back (childHandle);
392
    }
393
  return list;
394
}
395
396
template <typename... Args>
397
void
398
TrafficControlHelper::SetQueueLimits (std::string type, Args... args)
399
{
400
  m_queueLimitsFactory.SetTypeId (type);
401
  m_queueLimitsFactory.Set (args...);
402
}
403
404
405
} // namespace ns3
406
504
#endif /* TRAFFIC_CONTROL_HELPER_H */
407
#endif /* TRAFFIC_CONTROL_HELPER_H */

Return to bug 2780