src/core/object.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 4472 e20a31541404
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707
mathieu@699
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
mathieu@699
     2
/*
mathieu@699
     3
 * Copyright (c) 2007 INRIA, Gustavo Carneiro
mathieu@699
     4
 *
mathieu@699
     5
 * This program is free software; you can redistribute it and/or modify
mathieu@699
     6
 * it under the terms of the GNU General Public License version 2 as
mathieu@699
     7
 * published by the Free Software Foundation;
mathieu@699
     8
 *
mathieu@699
     9
 * This program is distributed in the hope that it will be useful,
mathieu@699
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
mathieu@699
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
mathieu@699
    12
 * GNU General Public License for more details.
mathieu@699
    13
 *
mathieu@699
    14
 * You should have received a copy of the GNU General Public License
mathieu@699
    15
 * along with this program; if not, write to the Free Software
mathieu@699
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
mathieu@699
    17
 *
mathieu@699
    18
 * Authors: Gustavo Carneiro <gjcarneiro@gmail.com>,
mathieu@699
    19
 *          Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
mathieu@699
    20
 */
mathieu@706
    21
#ifndef OBJECT_H
mathieu@706
    22
#define OBJECT_H
mathieu@699
    23
mathieu@699
    24
#include <stdint.h>
mathieu@699
    25
#include <string>
mathieu@2542
    26
#include <vector>
mathieu@699
    27
#include "ptr.h"
mathieu@2438
    28
#include "attribute.h"
mathieu@2372
    29
#include "object-base.h"
mathieu@2633
    30
#include "attribute-list.h"
mathieu@2246
    31
mathieu@2246
    32
mathieu@699
    33
namespace ns3 {
mathieu@699
    34
mathieu@2237
    35
class Object;
mathieu@2436
    36
class AttributeAccessor;
mathieu@2437
    37
class AttributeValue;
mathieu@2459
    38
class AttributeList;
mathieu@2463
    39
class TraceSourceAccessor;
mathieu@1336
    40
mathieu@718
    41
/**
tomh@3182
    42
 * \ingroup core
tomh@3182
    43
 * \defgroup object Object
tomh@3182
    44
 */
tomh@3182
    45
/**
tomh@3182
    46
 * \ingroup object
mathieu@718
    47
 * \brief a base class which provides memory management and object aggregation
mathieu@718
    48
 *
mathieu@3190
    49
 * The memory management scheme is based on reference-counting with dispose-like
mathieu@3190
    50
 * functionality to break the reference cycles. The reference count is increamented
mathieu@3190
    51
 * and decremented with the methods Object::Ref and Object::Unref. If a reference cycle is
mathieu@3190
    52
 * present, the user is responsible for breaking it by calling Object::Dispose in
mathieu@3190
    53
 * a single location. This will eventually trigger the invocation of Object::DoDispose 
mathieu@3190
    54
 * on itself and all its aggregates. The Object::DoDispose method is always automatically
mathieu@3190
    55
 * invoked from the Object::Unref method before destroying the object, even if the user 
mathieu@3190
    56
 * did not call Object::Dispose directly.
mathieu@718
    57
 */
mathieu@2370
    58
class Object : public ObjectBase
mathieu@699
    59
{
mathieu@699
    60
public:
mathieu@2251
    61
  static TypeId GetTypeId (void);
mathieu@699
    62
mathieu@2938
    63
  /**
mathieu@2938
    64
   * \brief Iterate over the objects aggregated to an ns3::Object.
mathieu@2938
    65
   *
mathieu@2938
    66
   * This iterator does not allow you to iterate over the initial
mathieu@2938
    67
   * object used to call Object::GetAggregateIterator. 
mathieu@2938
    68
   *
mathieu@2938
    69
   * Note: this is a java-style iterator.
mathieu@2938
    70
   */
mathieu@2937
    71
  class AggregateIterator
mathieu@2937
    72
  {
mathieu@2937
    73
  public:
mathieu@2937
    74
    AggregateIterator ();
mathieu@2937
    75
mathieu@2938
    76
    /**
mathieu@2938
    77
     * \returns true if HasNext can be called and return a non-null
mathieu@2938
    78
     *          pointer, false otherwise.
mathieu@2938
    79
     */
mathieu@2937
    80
    bool HasNext (void) const;
mathieu@2938
    81
mathieu@2938
    82
    /**
mathieu@2938
    83
     * \returns the next aggregated object.
mathieu@2938
    84
     */
mathieu@2937
    85
    Ptr<const Object> Next (void);
mathieu@2937
    86
  private:
mathieu@2937
    87
    friend class Object;
mathieu@2937
    88
    AggregateIterator (Ptr<const Object> first);
mathieu@2937
    89
    Ptr<const Object> m_first;
mathieu@2937
    90
    Ptr<const Object> m_current;
mathieu@2937
    91
  };
mathieu@2937
    92
mathieu@706
    93
  Object ();
mathieu@706
    94
  virtual ~Object ();
mathieu@2372
    95
mathieu@2670
    96
  /*
mathieu@2670
    97
   * Implement the GetInstanceTypeId method defined in ObjectBase.
mathieu@2670
    98
   */
mathieu@2634
    99
  virtual TypeId GetInstanceTypeId (void) const;
mathieu@2634
   100
mathieu@2372
   101
  /**
mathieu@718
   102
   * Increment the reference count. This method should not be called
mathieu@718
   103
   * by user code. Object instances are expected to be used in conjunction
mathieu@718
   104
   * of the Ptr template which would make calling Ref unecessary and 
mathieu@718
   105
   * dangerous.
mathieu@718
   106
   */
mathieu@706
   107
  inline void Ref (void) const;
mathieu@718
   108
  /**
mathieu@718
   109
   * Decrement the reference count. This method should not be called
mathieu@718
   110
   * by user code. Object instances are expected to be used in conjunction
mathieu@718
   111
   * of the Ptr template which would make calling Ref unecessary and 
mathieu@718
   112
   * dangerous.
mathieu@718
   113
   */
mathieu@706
   114
  inline void Unref (void) const;
mathieu@3394
   115
mathieu@3394
   116
  /**
mathieu@3394
   117
   * Get the reference count of the object.  Normally not needed; for language bindings.
mathieu@3394
   118
   */
mathieu@3394
   119
  uint32_t GetReferenceCount (void) const;
mathieu@3394
   120
mathieu@718
   121
  /**
mathieu@718
   122
   * \returns a pointer to the requested interface or zero if it could not be found.
mathieu@2231
   123
   */
mathieu@2231
   124
  template <typename T>
mathieu@2257
   125
  Ptr<T> GetObject (void) const;
mathieu@2231
   126
  /**
mathieu@2252
   127
   * \param tid the interface id of the requested interface
mathieu@2231
   128
   * \returns a pointer to the requested interface or zero if it could not be found.
mathieu@718
   129
   */
mathieu@699
   130
  template <typename T>
mathieu@2257
   131
  Ptr<T> GetObject (TypeId tid) const;
mathieu@718
   132
  /**
mathieu@718
   133
   * Run the DoDispose methods of this object and all the
mathieu@718
   134
   * objects aggregated to it.
mathieu@718
   135
   * After calling this method, the object is expected to be
mathieu@718
   136
   * totally unusable except for the Ref and Unref methods.
mathieu@718
   137
   * It is an error to call Dispose twice on the same object 
mathieu@2715
   138
   * instance.
mathieu@2715
   139
   *
mathieu@2715
   140
   * This method is typically used to break reference cycles.
mathieu@718
   141
   */
mathieu@699
   142
  void Dispose (void);
mathieu@718
   143
  /**
mathieu@718
   144
   * \param other another object pointer
mathieu@718
   145
   *
mathieu@718
   146
   * This method aggregates the two objects together: after this
mathieu@2257
   147
   * method returns, it becomes possible to call GetObject
mathieu@718
   148
   * on one to get the other, and vice-versa. 
mathieu@718
   149
   */
mathieu@2258
   150
  void AggregateObject (Ptr<Object> other);
mathieu@1330
   151
mathieu@2938
   152
  /**
mathieu@2938
   153
   * \returns an iterator to the first object aggregated to this
mathieu@2938
   154
   *          object.
mathieu@2938
   155
   *
mathieu@2938
   156
   * If no objects are aggregated to this object, then, the returned
mathieu@2938
   157
   * iterator will be empty and AggregateIterator::HasNext will
mathieu@2938
   158
   * always return false.
mathieu@2938
   159
   */
mathieu@2937
   160
  AggregateIterator GetAggregateIterator (void) const;
mathieu@2937
   161
mathieu@699
   162
protected:
tomh@4472
   163
 /**
tomh@4472
   164
  * This function is called by the AggregateObject on all the objects connected in the listed chain.
tomh@4472
   165
  * This way the new object aggregated will be used if needed by the NotifyNewAggregate corresponding
tomh@4472
   166
  * to each object connected in the listed chain. It should be implemented by objects needing an
tomh@4472
   167
  * additional/special behavior when aggregated to another object.
tomh@4472
   168
  */
tomh@4472
   169
  virtual void NotifyNewAggregate ();
mathieu@718
   170
  /**
mathieu@2715
   171
   * This method is called by Object::Dispose or by the object's 
mathieu@2715
   172
   * destructor, whichever comes first.
mathieu@2715
   173
   *
mathieu@2715
   174
   * Subclasses are expected to implement their real destruction
mathieu@2715
   175
   * code in an overriden version of this method and chain
mathieu@2230
   176
   * up to their parent's implementation once they are done.
mathieu@2715
   177
   * i.e., for simplicity, the destructor of every subclass should
mathieu@2715
   178
   * be empty and its content should be moved to the associated
mathieu@2715
   179
   * DoDispose method.
mathieu@2230
   180
   */
mathieu@2230
   181
  virtual void DoDispose (void);
mathieu@2667
   182
  /**
mathieu@2667
   183
   * \param o the object to copy.
mathieu@2667
   184
   *
mathieu@2667
   185
   * Allow subclasses to implement a copy constructor.
mathieu@2667
   186
   * While it is technically possible to implement a copy
mathieu@2667
   187
   * constructor in a subclass, we strongly discourage you
mathieu@2667
   188
   * to do so. If you really want to do it anyway, you have
mathieu@2667
   189
   * to understand that this copy constructor will _not_
mathieu@2667
   190
   * copy aggregated objects. i.e., if your object instance
mathieu@2667
   191
   * is already aggregated to another object and if you invoke
mathieu@2667
   192
   * this copy constructor, the new object instance will be
mathieu@2667
   193
   * a pristine standlone object instance not aggregated to
mathieu@2667
   194
   * any other object. It is thus _your_ responsability
mathieu@2667
   195
   * as a caller of this method to do what needs to be done
mathieu@2667
   196
   * (if it is needed) to ensure that the object stays in a
mathieu@2667
   197
   * valid state.
mathieu@2667
   198
   */
mathieu@2667
   199
  Object (const Object &o);
mathieu@2230
   200
private:
mathieu@2667
   201
mathieu@2372
   202
  template <typename T>
mathieu@4554
   203
  friend Ptr<T> CreateObjectWithAttributes (const AttributeList &attributes);
mathieu@2607
   204
  template <typename T>
mathieu@2607
   205
  friend Ptr<T> CopyObject (Ptr<T> object);
mathieu@2924
   206
  template <typename T>
mathieu@2924
   207
  friend Ptr<T> CopyObject (Ptr<const T> object);
mathieu@3396
   208
  // The following friend method declaration is used only
mathieu@3396
   209
  // by our python bindings to call the protected ObjectBase::Construct
mathieu@3396
   210
  // method.
mathieu@3396
   211
  friend void PythonCompleteConstruct (Ptr<Object> object, TypeId typeId, const AttributeList &attributes);
mathieu@4554
   212
  template <typename T>
mathieu@4554
   213
  friend Ptr<T> CompleteConstruct (T *object);
mathieu@2372
   214
mathieu@2631
   215
  friend class ObjectFactory;
mathieu@2937
   216
  friend class AggregateIterator;
mathieu@2631
   217
mathieu@2257
   218
  Ptr<Object> DoGetObject (TypeId tid) const;
mathieu@2230
   219
  bool Check (void) const;
mathieu@2230
   220
  bool CheckLoose (void) const;
mathieu@2372
   221
  /**
mathieu@2372
   222
   * Attempt to delete this object. This method iterates
mathieu@2372
   223
   * over all aggregated objects to check if they all 
mathieu@2372
   224
   * have a zero refcount. If yes, the object and all
mathieu@2372
   225
   * its aggregates are deleted. If not, nothing is done.
mathieu@2372
   226
   */
mathieu@2230
   227
  void MaybeDelete (void) const;
mathieu@2230
   228
  /**
mathieu@2252
   229
   * \param tid an TypeId
mathieu@718
   230
   *
mathieu@2372
   231
   * Invoked from ns3::CreateObject only.
mathieu@2372
   232
   * Initialize the m_tid member variable to
mathieu@2372
   233
   * keep track of the type of this object instance.
mathieu@718
   234
   */
mathieu@2252
   235
  void SetTypeId (TypeId tid);
mathieu@2637
   236
   /**
mathieu@2458
   237
   * \param attributes the attribute values used to initialize 
mathieu@2372
   238
   *        the member variables of this object's instance.
mathieu@2372
   239
   *
mathieu@2637
   240
   * Invoked from ns3::ObjectFactory::Create and ns3::CreateObject only.
mathieu@2372
   241
   * Initialize all the member variables which were
mathieu@2372
   242
   * registered with the associated TypeId.
mathieu@2372
   243
   */
mathieu@2459
   244
  void Construct (const AttributeList &attributes);
mathieu@2230
   245
mathieu@2372
   246
  /**
mathieu@2372
   247
   * The reference count for this object. Each aggregate
mathieu@2372
   248
   * has an individual reference count. When the global
mathieu@2372
   249
   * reference count (the sum of all reference counts) 
mathieu@2372
   250
   * reaches zero, the object and all its aggregates is 
mathieu@2372
   251
   * deleted.
mathieu@2372
   252
   */
mathieu@706
   253
  mutable uint32_t m_count;
mathieu@2372
   254
  /**
mathieu@2372
   255
   * Identifies the type of this object instance.
mathieu@2372
   256
   */
mathieu@2252
   257
  TypeId m_tid;
mathieu@2372
   258
  /**
mathieu@2372
   259
   * Set to true when the DoDispose method of the object
mathieu@2372
   260
   * has run, false otherwise.
mathieu@2372
   261
   */
mathieu@713
   262
  bool m_disposed;
mathieu@2372
   263
  /**
mathieu@2372
   264
   * A pointer to the next aggregate object. This is a circular
mathieu@2372
   265
   * linked list of aggregated objects: the last one points
mathieu@2372
   266
   * back to the first one. If an object is not aggregated to
mathieu@2372
   267
   * any other object, the value of this field is equal to the
mathieu@2372
   268
   * value of the 'this' pointer.
mathieu@2372
   269
   */
mathieu@706
   270
  Object *m_next;
mathieu@699
   271
};
mathieu@699
   272
mathieu@2670
   273
/**
mathieu@2688
   274
 * \param object a pointer to the object to copy.
mathieu@2670
   275
 * \returns a copy of the input object.
mathieu@2670
   276
 *
mathieu@2670
   277
 * This method invoke the copy constructor of the input object
mathieu@2670
   278
 * and returns the new instance.
mathieu@2670
   279
 */
mathieu@2667
   280
template <typename T>
mathieu@2924
   281
Ptr<T> CopyObject (Ptr<const T> object);
mathieu@2924
   282
template <typename T>
mathieu@2688
   283
Ptr<T> CopyObject (Ptr<T> object);
mathieu@2667
   284
mathieu@2924
   285
mathieu@2670
   286
/**
mathieu@2670
   287
 * \param attributes a list of attributes to set on the 
mathieu@2670
   288
 *        object during construction.
mathieu@2670
   289
 * \returns a pointer to a newly allocated object.
mathieu@2670
   290
 *
mathieu@2670
   291
 * This allocates an object on the heap and initializes
mathieu@2670
   292
 * it with a set of attributes.
mathieu@2670
   293
 */
mathieu@2667
   294
template <typename T>
mathieu@4554
   295
Ptr<T> CreateObjectWithAttributes (const AttributeList &attributes);
mathieu@2667
   296
mathieu@2670
   297
/**
mathieu@2670
   298
 * \param n1 name of attribute
mathieu@2670
   299
 * \param v1 value of attribute
mathieu@2670
   300
 * \param n2 name of attribute
mathieu@2670
   301
 * \param v2 value of attribute
mathieu@2670
   302
 * \param n3 name of attribute
mathieu@2670
   303
 * \param v3 value of attribute
mathieu@2670
   304
 * \param n4 name of attribute
mathieu@2670
   305
 * \param v4 value of attribute
mathieu@2670
   306
 * \param n5 name of attribute
mathieu@2670
   307
 * \param v5 value of attribute
mathieu@2670
   308
 * \param n6 name of attribute
mathieu@2670
   309
 * \param v6 value of attribute
mathieu@2670
   310
 * \param n7 name of attribute
mathieu@2670
   311
 * \param v7 value of attribute
mathieu@2670
   312
 * \param n8 name of attribute
mathieu@2670
   313
 * \param v8 value of attribute
mathieu@2670
   314
 * \param n9 name of attribute
mathieu@2670
   315
 * \param v9 value of attribute
mathieu@2670
   316
 * \returns a pointer to a newly allocated object.
mathieu@2670
   317
 *
mathieu@2670
   318
 * This allocates an object on the heap and initializes
mathieu@2670
   319
 * it with a set of attributes.
mathieu@2670
   320
 */
mathieu@2667
   321
template <typename T>
mathieu@2667
   322
Ptr<T> 
mathieu@4554
   323
CreateObjectWithAttributes (std::string n1 = "", const AttributeValue & v1 = EmptyAttributeValue (),
mathieu@2965
   324
              std::string n2 = "", const AttributeValue & v2 = EmptyAttributeValue (),
mathieu@2965
   325
              std::string n3 = "", const AttributeValue & v3 = EmptyAttributeValue (),
mathieu@2965
   326
              std::string n4 = "", const AttributeValue & v4 = EmptyAttributeValue (),
mathieu@2965
   327
              std::string n5 = "", const AttributeValue & v5 = EmptyAttributeValue (),
mathieu@2965
   328
              std::string n6 = "", const AttributeValue & v6 = EmptyAttributeValue (),
mathieu@2965
   329
              std::string n7 = "", const AttributeValue & v7 = EmptyAttributeValue (),
mathieu@2965
   330
              std::string n8 = "", const AttributeValue & v8 = EmptyAttributeValue (),
mathieu@2965
   331
              std::string n9 = "", const AttributeValue & v9 = EmptyAttributeValue ());
mathieu@2667
   332
  
mathieu@2667
   333
mathieu@2667
   334
mathieu@699
   335
} // namespace ns3
mathieu@699
   336
mathieu@699
   337
namespace ns3 {
mathieu@699
   338
mathieu@2372
   339
/*************************************************************************
mathieu@2372
   340
 *   The Object implementation which depends on templates
mathieu@2372
   341
 *************************************************************************/
mathieu@2237
   342
mathieu@701
   343
void
mathieu@706
   344
Object::Ref (void) const
mathieu@701
   345
{
mathieu@701
   346
  m_count++;
mathieu@701
   347
}
mathieu@701
   348
void
mathieu@706
   349
Object::Unref (void) const
mathieu@701
   350
{
mathieu@701
   351
  NS_ASSERT (Check ());
mathieu@701
   352
  m_count--;
mathieu@701
   353
  if (m_count == 0)
mathieu@701
   354
    {
mathieu@701
   355
      MaybeDelete ();
mathieu@701
   356
    }
mathieu@701
   357
}
mathieu@701
   358
mathieu@699
   359
template <typename T>
mathieu@699
   360
Ptr<T> 
mathieu@2257
   361
Object::GetObject () const
mathieu@2231
   362
{
mathieu@2257
   363
  Ptr<Object> found = DoGetObject (T::GetTypeId ());
mathieu@2231
   364
  if (found != 0)
mathieu@2231
   365
    {
mathieu@2231
   366
      return Ptr<T> (dynamic_cast<T *> (PeekPointer (found)));
mathieu@2231
   367
    }
mathieu@2231
   368
  return 0;
mathieu@2231
   369
}
mathieu@2231
   370
mathieu@2231
   371
template <typename T>
mathieu@2231
   372
Ptr<T> 
mathieu@2257
   373
Object::GetObject (TypeId tid) const
mathieu@699
   374
{
mathieu@2257
   375
  Ptr<Object> found = DoGetObject (tid);
mathieu@699
   376
  if (found != 0)
mathieu@699
   377
    {
mathieu@699
   378
      return Ptr<T> (dynamic_cast<T *> (PeekPointer (found)));
mathieu@699
   379
    }
mathieu@699
   380
  return 0;
mathieu@699
   381
}
mathieu@699
   382
mathieu@2372
   383
/*************************************************************************
mathieu@2372
   384
 *   The helper functions which need templates.
mathieu@2372
   385
 *************************************************************************/
mathieu@2372
   386
mathieu@2607
   387
template <typename T>
mathieu@2688
   388
Ptr<T> CopyObject (Ptr<T> object)
mathieu@2607
   389
{
mathieu@2690
   390
  Ptr<T> p = Ptr<T> (new T (*PeekPointer (object)), false);
mathieu@3397
   391
  NS_ASSERT (p->GetInstanceTypeId () == object->GetInstanceTypeId ());
mathieu@2607
   392
  return p;
mathieu@2607
   393
}
mathieu@2607
   394
mathieu@2924
   395
template <typename T>
mathieu@2924
   396
Ptr<T> CopyObject (Ptr<const T> object)
mathieu@2924
   397
{
mathieu@2924
   398
  Ptr<T> p = Ptr<T> (new T (*PeekPointer (object)), false);
mathieu@3397
   399
  NS_ASSERT (p->GetInstanceTypeId () == object->GetInstanceTypeId ());
mathieu@2924
   400
  return p;
mathieu@2924
   401
}
mathieu@2924
   402
mathieu@2372
   403
template <typename T>
mathieu@4554
   404
Ptr<T> CompleteConstruct (T *p)
mathieu@4554
   405
{
mathieu@4554
   406
  p->SetTypeId (T::GetTypeId ());
mathieu@4554
   407
  p->Object::Construct (AttributeList());
mathieu@4554
   408
  return Ptr<T> (p, false);
mathieu@4554
   409
}
mathieu@4554
   410
template <typename T>
mathieu@4554
   411
Ptr<T> CreateObjectWithAttributes (const AttributeList &attributes)
mathieu@2372
   412
{
mathieu@2372
   413
  Ptr<T> p = Ptr<T> (new T (), false);
mathieu@2372
   414
  p->SetTypeId (T::GetTypeId ());
mathieu@2458
   415
  p->Object::Construct (attributes);
mathieu@2372
   416
  return p;  
mathieu@2372
   417
}
mathieu@2372
   418
mathieu@2230
   419
template <typename T>
mathieu@2372
   420
Ptr<T> 
mathieu@4554
   421
CreateObjectWithAttributes (std::string n1 , const AttributeValue & v1,
timo@4210
   422
              std::string n2 , const AttributeValue & v2,
timo@4210
   423
              std::string n3 , const AttributeValue & v3,
timo@4210
   424
              std::string n4 , const AttributeValue & v4,
timo@4210
   425
              std::string n5 , const AttributeValue & v5,
timo@4210
   426
              std::string n6 , const AttributeValue & v6,
timo@4210
   427
              std::string n7 , const AttributeValue & v7,
timo@4210
   428
              std::string n8 , const AttributeValue & v8,
timo@4210
   429
              std::string n9 , const AttributeValue & v9)
mathieu@2372
   430
{
mathieu@2459
   431
  AttributeList attributes;
mathieu@2591
   432
  if (n1 == "")
mathieu@2591
   433
    {
mathieu@2591
   434
      goto end;
mathieu@2591
   435
    }
mathieu@2458
   436
  attributes.SetWithTid (T::GetTypeId (), n1, v1);
mathieu@2591
   437
  if (n2 == "")
mathieu@2591
   438
    {
mathieu@2591
   439
      goto end;
mathieu@2591
   440
    }
mathieu@2458
   441
  attributes.SetWithTid (T::GetTypeId (), n2, v2);
mathieu@2591
   442
  if (n3 == "")
mathieu@2591
   443
    {
mathieu@2591
   444
      goto end;
mathieu@2591
   445
    }
mathieu@2489
   446
  attributes.SetWithTid (T::GetTypeId (), n3, v3);
mathieu@2591
   447
  if (n4 == "")
mathieu@2591
   448
    {
mathieu@2591
   449
      goto end;
mathieu@2591
   450
    }
mathieu@2489
   451
  attributes.SetWithTid (T::GetTypeId (), n4, v4);
mathieu@2591
   452
  if (n5 == "")
mathieu@2591
   453
    {
mathieu@2591
   454
      goto end;
mathieu@2591
   455
    }
mathieu@2489
   456
  attributes.SetWithTid (T::GetTypeId (), n5, v5);
mathieu@2591
   457
  if (n6 == "")
mathieu@2591
   458
    {
mathieu@2591
   459
      goto end;
mathieu@2591
   460
    }
mathieu@2489
   461
  attributes.SetWithTid (T::GetTypeId (), n6, v6);
mathieu@2591
   462
  if (n7 == "")
mathieu@2591
   463
    {
mathieu@2591
   464
      goto end;
mathieu@2591
   465
    }
mathieu@2489
   466
  attributes.SetWithTid (T::GetTypeId (), n7, v7);
mathieu@2591
   467
  if (n8 == "")
mathieu@2591
   468
    {
mathieu@2591
   469
      goto end;
mathieu@2591
   470
    }
mathieu@2489
   471
  attributes.SetWithTid (T::GetTypeId (), n8, v8);
mathieu@2591
   472
  if (n9 == "")
mathieu@2591
   473
    {
mathieu@2591
   474
      goto end;
mathieu@2591
   475
    }
mathieu@2489
   476
  attributes.SetWithTid (T::GetTypeId (), n9, v9);
mathieu@2591
   477
 end:
mathieu@4554
   478
  return CreateObjectWithAttributes<T> (attributes);
mathieu@2372
   479
}
mathieu@2372
   480
mathieu@4554
   481
template <typename T>
mathieu@4554
   482
Ptr<T> CreateObject (void)
mathieu@4554
   483
{
mathieu@4554
   484
  return CompleteConstruct (new T ());
mathieu@4554
   485
}
mathieu@4554
   486
mathieu@4554
   487
template <typename T, typename T1>
mathieu@4554
   488
Ptr<T> CreateObject (T1 a1)
mathieu@4554
   489
{
mathieu@4554
   490
  return CompleteConstruct (new T (a1));
mathieu@4554
   491
}
mathieu@4554
   492
mathieu@4554
   493
template <typename T, typename T1, typename T2>
mathieu@4554
   494
Ptr<T> CreateObject (T1 a1, T2 a2)
mathieu@4554
   495
{
mathieu@4554
   496
  return CompleteConstruct (new T (a1,a2));
mathieu@4554
   497
}
mathieu@4554
   498
mathieu@4554
   499
template <typename T, typename T1, typename T2, typename T3>
mathieu@4554
   500
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3)
mathieu@4554
   501
{
mathieu@4554
   502
  return CompleteConstruct (new T (a1,a2,a3));
mathieu@4554
   503
}
mathieu@4554
   504
mathieu@4554
   505
template <typename T, typename T1, typename T2, typename T3, typename T4>
mathieu@4554
   506
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4)
mathieu@4554
   507
{
mathieu@4554
   508
  return CompleteConstruct (new T (a1,a2,a3,a4));
mathieu@4554
   509
}
mathieu@4554
   510
mathieu@4554
   511
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5>
mathieu@4554
   512
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
mathieu@4554
   513
{
mathieu@4554
   514
  return CompleteConstruct (new T (a1,a2,a3,a4,a5));
mathieu@4554
   515
}
mathieu@4554
   516
mathieu@4554
   517
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
mathieu@4554
   518
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
mathieu@4554
   519
{
mathieu@4554
   520
  return CompleteConstruct (new T (a1,a2,a3,a4,a5,a6));
mathieu@4554
   521
}
mathieu@4554
   522
mathieu@4554
   523
template <typename T, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
mathieu@4554
   524
Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7)
mathieu@4554
   525
{
mathieu@4554
   526
  return CompleteConstruct (new T (a1,a2,a3,a4,a5,a6,a7));
mathieu@4554
   527
}
mathieu@4554
   528
mathieu@4554
   529
mathieu@699
   530
} // namespace ns3
mathieu@699
   531
mathieu@706
   532
#endif /* OBJECT_H */
mathieu@699
   533