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) 2008 INRIA | 3 * Copyright (c) 2008 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 * | 166 * |
167 * \param [in] i Index of the TypeId. | 167 * \param [in] i Index of the TypeId. |
168 * \returns The TypeId instance whose index is \c i. | 168 * \returns The TypeId instance whose index is \c i. |
169 */ | 169 */ |
170 static TypeId GetRegistered (uint16_t i); | 170 static TypeId GetRegistered (uint16_t i); |
171 | 171 |
172 /** | 172 /** |
173 * Constructor. | 173 * Constructor. |
174 * | 174 * |
175 * \param [in] name The name of the interface to construct. | 175 * \param [in] name The name of the interface to construct. |
| 176 * \param [in] canBeDuplicate If true, this class can be registered more than
once |
176 * | 177 * |
177 * No two instances can share the same name. The name is expected to be | 178 * No two instances can share the same name. The name is expected to be |
178 * the full c++ typename of associated c++ object. | 179 * the full c++ typename of associated c++ object. |
179 */ | 180 */ |
180 explicit TypeId (const char * name); | 181 explicit TypeId (const char * name, bool canBeDuplicate = false); |
181 | 182 |
182 /** | 183 /** |
183 * Get the parent of this TypeId. | 184 * Get the parent of this TypeId. |
184 * | 185 * |
185 * \returns The parent of this TypeId | 186 * \returns The parent of this TypeId |
186 * | 187 * |
187 * This method cannot fail. It will return itself | 188 * This method cannot fail. It will return itself |
188 * if this TypeId has no parent. i.e., it is at the top | 189 * if this TypeId has no parent. i.e., it is at the top |
189 * of the TypeId hierarchy. Currently, this is the | 190 * of the TypeId hierarchy. Currently, this is the |
190 * case for the TypeId associated to the ns3::ObjectBase class· | 191 * case for the TypeId associated to the ns3::ObjectBase class· |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 * \param [in] size The size of the object, in bytes. | 346 * \param [in] size The size of the object, in bytes. |
346 * \returns This TypeId instance. | 347 * \returns This TypeId instance. |
347 */ | 348 */ |
348 TypeId SetSize (std::size_t size); | 349 TypeId SetSize (std::size_t size); |
349 ·· | 350 ·· |
350 /** | 351 /** |
351 * Record in this TypeId the fact that the default constructor | 352 * Record in this TypeId the fact that the default constructor |
352 * is accessible. | 353 * is accessible. |
353 * | 354 * |
354 * \tparam T \explicit The class name represented by this TypeId. | 355 * \tparam T \explicit The class name represented by this TypeId. |
| 356 * \param [in] canBeDuplicate If true, this class can be registered more than
once |
355 * \returns This TypeId instance | 357 * \returns This TypeId instance |
356 */ | 358 */ |
357 template <typename T> | 359 template <typename T> |
358 TypeId AddConstructor (void); | 360 TypeId AddConstructor (bool canBeDuplicate = false); |
359 | 361 |
360 /** | 362 /** |
361 * Record in this TypeId the fact that a new attribute exists. | 363 * Record in this TypeId the fact that a new attribute exists. |
362 * | 364 * |
363 * \param [in] name The name of the new attribute | 365 * \param [in] name The name of the new attribute |
364 * \param [in] help Some help text which describes the purpose of this | 366 * \param [in] help Some help text which describes the purpose of this |
365 * attribute. | 367 * attribute. |
366 * \param [in] initialValue The initial value for this attribute. | 368 * \param [in] initialValue The initial value for this attribute. |
367 * \param [in] accessor An instance of the associated AttributeAccessor | 369 * \param [in] accessor An instance of the associated AttributeAccessor |
368 * subclass. | 370 * subclass. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 * "ns3::" namespace qualifier. | 459 * "ns3::" namespace qualifier. |
458 * \param [in] supportLevel Support/deprecation status of the attribute. | 460 * \param [in] supportLevel Support/deprecation status of the attribute. |
459 * \param [in] supportMsg Upgrade hint if this attribute is no longer | 461 * \param [in] supportMsg Upgrade hint if this attribute is no longer |
460 * supported. If the attribute is \c DEPRECATED the attribute | 462 * supported. If the attribute is \c DEPRECATED the attribute |
461 * behavior still exists, but user code should be updated | 463 * behavior still exists, but user code should be updated |
462 * following guidance in the hint.. | 464 * following guidance in the hint.. |
463 * If the attribute is \c OBSOLETE, the hint should indicate | 465 * If the attribute is \c OBSOLETE, the hint should indicate |
464 * which class the attribute functional has been moved to, | 466 * which class the attribute functional has been moved to, |
465 * or that the functionality is no longer supported. | 467 * or that the functionality is no longer supported. |
466 * See test file type-id-test-suite.cc for examples. | 468 * See test file type-id-test-suite.cc for examples. |
| 469 * \param [in] canBeDuplicate If true, this class can be registered more than
once |
467 * \returns This TypeId instance. | 470 * \returns This TypeId instance. |
468 */ | 471 */ |
469 TypeId AddTraceSource (std::string name, | 472 TypeId AddTraceSource (std::string name, |
470 std::string help, | 473 std::string help, |
471 Ptr<const TraceSourceAccessor> accessor, | 474 Ptr<const TraceSourceAccessor> accessor, |
472 std::string callback, | 475 std::string callback, |
473 SupportLevel supportLevel = SUPPORTED, | 476 SupportLevel supportLevel = SUPPORTED, |
474 const std::string &supportMsg = ""); | 477 const std::string &supportMsg = "", |
| 478 bool canBeDuplicate = false); |
475 | 479 |
476 /** | 480 /** |
477 * Hide this TypeId from documentation. | 481 * Hide this TypeId from documentation. |
478 * \returns This TypeId instance. | 482 * \returns This TypeId instance. |
479 */ | 483 */ |
480 TypeId HideFromDocumentation (void); | 484 TypeId HideFromDocumentation (void); |
481 | 485 |
482 /** | 486 /** |
483 * Find an Attribute by name, retrieving the associated AttributeInformation. | 487 * Find an Attribute by name, retrieving the associated AttributeInformation. |
484 * | 488 * |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 569 |
566 /** | 570 /** |
567 * Construct from an integer value. | 571 * Construct from an integer value. |
568 * \param [in] tid The TypeId value as an integer. | 572 * \param [in] tid The TypeId value as an integer. |
569 */ | 573 */ |
570 explicit TypeId (uint16_t tid); | 574 explicit TypeId (uint16_t tid); |
571 /** | 575 /** |
572 * Implementation for AddConstructor(). | 576 * Implementation for AddConstructor(). |
573 * | 577 * |
574 * \param [in] callback Callback which constructs an instance of this TypeId. | 578 * \param [in] callback Callback which constructs an instance of this TypeId. |
575 */ | 579 * \param [in] canBeDuplicate True if this class can be registered more than o
nce |
576 void DoAddConstructor (Callback<ObjectBase *> callback); | 580 */ |
| 581 void DoAddConstructor (Callback<ObjectBase *> callback, bool canBeDuplicate =
false); |
577 ·· | 582 ·· |
578 /** The TypeId value. */· | 583 /** The TypeId value. */· |
579 uint16_t m_tid; | 584 uint16_t m_tid; |
580 }; | 585 }; |
581 | 586 |
582 /** | 587 /** |
583 * \relates TypeId | 588 * \relates TypeId |
584 * Output streamer. | 589 * Output streamer. |
585 * | 590 * |
586 * \param [in,out] os The output stream. | 591 * \param [in,out] os The output stream. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 651 |
647 template <typename T> | 652 template <typename T> |
648 TypeId· | 653 TypeId· |
649 TypeId::SetParent (void) | 654 TypeId::SetParent (void) |
650 { | 655 { |
651 return SetParent (T::GetTypeId ()); | 656 return SetParent (T::GetTypeId ()); |
652 } | 657 } |
653 | 658 |
654 template <typename T> | 659 template <typename T> |
655 TypeId· | 660 TypeId· |
656 TypeId::AddConstructor (void) | 661 TypeId::AddConstructor (bool canBeDuplicate) |
657 { | 662 { |
658 struct Maker { | 663 struct Maker { |
659 static ObjectBase * Create () { | 664 static ObjectBase * Create () { |
660 ObjectBase * base = new T (); | 665 ObjectBase * base = new T (); |
661 return base; | 666 return base; |
662 } | 667 } |
663 }; | 668 }; |
664 Callback<ObjectBase *> cb = MakeCallback (&Maker::Create); | 669 Callback<ObjectBase *> cb = MakeCallback (&Maker::Create); |
665 DoAddConstructor (cb); | 670 DoAddConstructor (cb, canBeDuplicate); |
666 return *this; | 671 return *this; |
667 } | 672 } |
668 | 673 |
669 } // namespace ns3 | 674 } // namespace ns3 |
670 | 675 |
671 #endif /* TYPE_ID_H */ | 676 #endif /* TYPE_ID_H */ |
LEFT | RIGHT |