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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 * result of this function should be stored. | 149 * result of this function should be stored. |
150 * \returns \c true if the requested hash was found. | 150 * \returns \c true if the requested hash was found. |
151 */ | 151 */ |
152 static bool LookupByHashFailSafe (hash_t hash, TypeId *tid); | 152 static bool LookupByHashFailSafe (hash_t hash, TypeId *tid); |
153 | 153 |
154 /** | 154 /** |
155 * Get the number of registered TypeIds. | 155 * Get the number of registered TypeIds. |
156 * | 156 * |
157 * \returns The number of TypeId instances registered. | 157 * \returns The number of TypeId instances registered. |
158 */ | 158 */ |
159 static uint32_t GetRegisteredN (void); | 159 static uint16_t GetRegisteredN (void); |
160 /** | 160 /** |
161 * Get a TypeId by index. | 161 * Get a TypeId by index. |
162 * | 162 * |
163 * \param [in] i Index of the TypeId. | 163 * \param [in] i Index of the TypeId. |
164 * \returns The TypeId instance whose index is \c i. | 164 * \returns The TypeId instance whose index is \c i. |
165 */ | 165 */ |
166 static TypeId GetRegistered (uint32_t i); | 166 static TypeId GetRegistered (uint16_t i); |
167 | 167 |
168 /** | 168 /** |
169 * Constructor. | 169 * Constructor. |
170 * | 170 * |
171 * \param [in] name The name of the interface to construct. | 171 * \param [in] name The name of the interface to construct. |
172 * \param [in] canBeDupicate If true, this class can be registered more than o
nce | |
173 * | 172 * |
174 * No two instances can share the same name. The name is expected to be | 173 * No two instances can share the same name. The name is expected to be |
175 * the full c++ typename of associated c++ object. | 174 * the full c++ typename of associated c++ object. |
176 */ | 175 */ |
177 explicit TypeId (const char * name, bool canBeDuplicate = false); | 176 explicit TypeId (const char * name); |
178 | 177 |
179 /** | 178 /** |
180 * Get the parent of this TypeId. | 179 * Get the parent of this TypeId. |
181 * | 180 * |
182 * \returns The parent of this TypeId | 181 * \returns The parent of this TypeId |
183 * | 182 * |
184 * This method cannot fail. It will return itself | 183 * This method cannot fail. It will return itself |
185 * if this TypeId has no parent. i.e., it is at the top | 184 * if this TypeId has no parent. i.e., it is at the top |
186 * of the TypeId hierarchy. Currently, this is the | 185 * of the TypeId hierarchy. Currently, this is the |
187 * case for the TypeId associated to the ns3::ObjectBase class· | 186 * case for the TypeId associated to the ns3::ObjectBase class· |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 * | 240 * |
242 * \returns \c true if this TypeId has a constructor | 241 * \returns \c true if this TypeId has a constructor |
243 */ | 242 */ |
244 bool HasConstructor (void) const; | 243 bool HasConstructor (void) const; |
245 | 244 |
246 /** | 245 /** |
247 * Get the number of attributes. | 246 * Get the number of attributes. |
248 * | 247 * |
249 * \returns The number of attributes associated to this TypeId | 248 * \returns The number of attributes associated to this TypeId |
250 */ | 249 */ |
251 uint32_t GetAttributeN (void) const; | 250 std::size_t GetAttributeN (void) const; |
252 /** | 251 /** |
253 * Get Attribute information by index. | 252 * Get Attribute information by index. |
254 * | 253 * |
255 * \param [in] i Index into attribute array | 254 * \param [in] i Index into attribute array |
256 * \returns The information associated to attribute whose index is \p i. | 255 * \returns The information associated to attribute whose index is \p i. |
257 */ | 256 */ |
258 struct TypeId::AttributeInformation GetAttribute(uint32_t i) const; | 257 struct TypeId::AttributeInformation GetAttribute (std::size_t i) const; |
259 /** | 258 /** |
260 * Get the Attribute name by index. | 259 * Get the Attribute name by index. |
261 * | 260 * |
262 * \param [in] i Index into attribute array | 261 * \param [in] i Index into attribute array |
263 * \returns The full name associated to the attribute whose index is \p i. | 262 * \returns The full name associated to the attribute whose index is \p i. |
264 */ | 263 */ |
265 std::string GetAttributeFullName (uint32_t i) const; | 264 std::string GetAttributeFullName (std::size_t i) const; |
266 | 265 |
267 /** | 266 /** |
268 * Get the constructor callback. | 267 * Get the constructor callback. |
269 * | 268 * |
270 * \returns A callback which can be used to instanciate an object | 269 * \returns A callback which can be used to instanciate an object |
271 * of this type. | 270 * of this type. |
272 */ | 271 */ |
273 Callback<ObjectBase *> GetConstructor (void) const; | 272 Callback<ObjectBase *> GetConstructor (void) const; |
274 | 273 |
275 /** | 274 /** |
276 * Check if this TypeId should not be listed in documentation. | 275 * Check if this TypeId should not be listed in documentation. |
277 * | 276 * |
278 * \returns \c true if this TypeId should be hidden from the user. | 277 * \returns \c true if this TypeId should be hidden from the user. |
279 */ | 278 */ |
280 bool MustHideFromDocumentation (void) const; | 279 bool MustHideFromDocumentation (void) const; |
281 | 280 |
282 | 281 |
283 /** | 282 /** |
284 * Get the number of Trace sources. | 283 * Get the number of Trace sources. |
285 * | 284 * |
286 * \returns The number of trace sources defined in this TypeId. | 285 * \returns The number of trace sources defined in this TypeId. |
287 */ | 286 */ |
288 uint32_t GetTraceSourceN (void) const; | 287 std::size_t GetTraceSourceN (void) const; |
289 /** | 288 /** |
290 * Get the trace source by index. | 289 * Get the trace source by index. |
291 * | 290 * |
292 * \param [in] i Index into trace source array. | 291 * \param [in] i Index into trace source array. |
293 * \returns Detailed information about the requested trace source. | 292 * \returns Detailed information about the requested trace source. |
294 */ | 293 */ |
295 struct TypeId::TraceSourceInformation GetTraceSource(uint32_t i) const; | 294 struct TypeId::TraceSourceInformation GetTraceSource (std::size_t i) const; |
296 | 295 |
297 /** | 296 /** |
298 * Set the parent TypeId. | 297 * Set the parent TypeId. |
299 * | 298 * |
300 * \param [in] tid The TypeId of the base class. | 299 * \param [in] tid The TypeId of the base class. |
301 * \return This TypeId instance. | 300 * \return This TypeId instance. |
302 * | 301 * |
303 * Record in this TypeId which TypeId is the TypeId | 302 * Record in this TypeId which TypeId is the TypeId |
304 * of the base class of the subclass. | 303 * of the base class of the subclass. |
305 */ | 304 */ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 * \param [in] size The size of the object, in bytes. | 341 * \param [in] size The size of the object, in bytes. |
343 * \returns This TypeId instance. | 342 * \returns This TypeId instance. |
344 */ | 343 */ |
345 TypeId SetSize (std::size_t size); | 344 TypeId SetSize (std::size_t size); |
346 ·· | 345 ·· |
347 /** | 346 /** |
348 * Record in this TypeId the fact that the default constructor | 347 * Record in this TypeId the fact that the default constructor |
349 * is accessible. | 348 * is accessible. |
350 * | 349 * |
351 * \tparam T \explicit The class name represented by this TypeId. | 350 * \tparam T \explicit The class name represented by this TypeId. |
352 * \param [in] canBeDupicate If true, this class can be registered more than o
nce | |
353 * \returns This TypeId instance | 351 * \returns This TypeId instance |
354 */ | 352 */ |
355 template <typename T> | 353 template <typename T> |
356 TypeId AddConstructor (bool canBeDuplicate = false); | 354 TypeId AddConstructor (void); |
357 | 355 |
358 /** | 356 /** |
359 * Record in this TypeId the fact that a new attribute exists. | 357 * Record in this TypeId the fact that a new attribute exists. |
360 * | 358 * |
361 * \param [in] name The name of the new attribute | 359 * \param [in] name The name of the new attribute |
362 * \param [in] help Some help text which describes the purpose of this | 360 * \param [in] help Some help text which describes the purpose of this |
363 * attribute. | 361 * attribute. |
364 * \param [in] initialValue The initial value for this attribute. | 362 * \param [in] initialValue The initial value for this attribute. |
365 * \param [in] accessor An instance of the associated AttributeAccessor | 363 * \param [in] accessor An instance of the associated AttributeAccessor |
366 * subclass. | 364 * subclass. |
(...skipping 18 matching lines...) Expand all Loading... |
385 SupportLevel supportLevel = SUPPORTED, | 383 SupportLevel supportLevel = SUPPORTED, |
386 const std::string &supportMsg = ""); | 384 const std::string &supportMsg = ""); |
387 | 385 |
388 /** | 386 /** |
389 * Set the initial value of an Attribute. | 387 * Set the initial value of an Attribute. |
390 * | 388 * |
391 * \param [in] i The attribute to manipulate | 389 * \param [in] i The attribute to manipulate |
392 * \param [in] initialValue The new initial value to use for this attribute. | 390 * \param [in] initialValue The new initial value to use for this attribute. |
393 * \returns \c true if the call was successfuly. | 391 * \returns \c true if the call was successfuly. |
394 */ | 392 */ |
395 bool SetAttributeInitialValue(uint32_t i,· | 393 bool SetAttributeInitialValue (std::size_t i, |
396 Ptr<const AttributeValue> initialValue); | 394 Ptr<const AttributeValue> initialValue); |
397 | 395 |
398 /** | 396 /** |
399 * Record in this TypeId the fact that a new attribute exists. | 397 * Record in this TypeId the fact that a new attribute exists. |
400 * | 398 * |
401 * \param [in] name The name of the new attribute | 399 * \param [in] name The name of the new attribute |
402 * \param [in] help Some help text which describes the purpose of this | 400 * \param [in] help Some help text which describes the purpose of this |
403 * attribute | 401 * attribute |
404 * \param [in] flags Flags which describe how this attribute can be read and/o
r written. | 402 * \param [in] flags Flags which describe how this attribute can be read and/o
r written. |
405 * \param [in] initialValue The initial value for this attribute. | 403 * \param [in] initialValue The initial value for this attribute. |
406 * \param [in] accessor An instance of the associated AttributeAccessor | 404 * \param [in] accessor An instance of the associated AttributeAccessor |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 * "ns3::" namespace qualifier. | 453 * "ns3::" namespace qualifier. |
456 * \param [in] supportLevel Support/deprecation status of the attribute. | 454 * \param [in] supportLevel Support/deprecation status of the attribute. |
457 * \param [in] supportMsg Upgrade hint if this attribute is no longer | 455 * \param [in] supportMsg Upgrade hint if this attribute is no longer |
458 * supported. If the attribute is \c DEPRECATED the attribute | 456 * supported. If the attribute is \c DEPRECATED the attribute |
459 * behavior still exists, but user code should be updated | 457 * behavior still exists, but user code should be updated |
460 * following guidance in the hint.. | 458 * following guidance in the hint.. |
461 * If the attribute is \c OBSOLETE, the hint should indicate | 459 * If the attribute is \c OBSOLETE, the hint should indicate |
462 * which class the attribute functional has been moved to, | 460 * which class the attribute functional has been moved to, |
463 * or that the functionality is no longer supported. | 461 * or that the functionality is no longer supported. |
464 * See test file type-id-test-suite.cc for examples. | 462 * See test file type-id-test-suite.cc for examples. |
465 * \param [in] canBeDupicate If true, this class can be registered more than o
nce | |
466 * \returns This TypeId instance. | 463 * \returns This TypeId instance. |
467 */ | 464 */ |
468 TypeId AddTraceSource (std::string name, | 465 TypeId AddTraceSource (std::string name, |
469 std::string help, | 466 std::string help, |
470 Ptr<const TraceSourceAccessor> accessor, | 467 Ptr<const TraceSourceAccessor> accessor, |
471 std::string callback, | 468 std::string callback, |
472 SupportLevel supportLevel = SUPPORTED, | 469 SupportLevel supportLevel = SUPPORTED, |
473 const std::string &supportMsg = "", | 470 const std::string &supportMsg = ""); |
474 bool canBeDuplicate = false); | |
475 | 471 |
476 /** | 472 /** |
477 * Hide this TypeId from documentation. | 473 * Hide this TypeId from documentation. |
478 * \returns This TypeId instance. | 474 * \returns This TypeId instance. |
479 */ | 475 */ |
480 TypeId HideFromDocumentation (void); | 476 TypeId HideFromDocumentation (void); |
481 | 477 |
482 /** | 478 /** |
483 * Find an Attribute by name, retrieving the associated AttributeInformation. | 479 * Find an Attribute by name, retrieving the associated AttributeInformation. |
484 * | 480 * |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 | 561 |
566 /** | 562 /** |
567 * Construct from an integer value. | 563 * Construct from an integer value. |
568 * \param [in] tid The TypeId value as an integer. | 564 * \param [in] tid The TypeId value as an integer. |
569 */ | 565 */ |
570 explicit TypeId (uint16_t tid); | 566 explicit TypeId (uint16_t tid); |
571 /** | 567 /** |
572 * Implementation for AddConstructor(). | 568 * Implementation for AddConstructor(). |
573 * | 569 * |
574 * \param [in] callback Callback which constructs an instance of this TypeId. | 570 * \param [in] callback Callback which constructs an instance of this TypeId. |
575 * \param [in] canBeDuplicate True if this class can be registered more than o
nce | 571 */ |
576 */ | 572 void DoAddConstructor (Callback<ObjectBase *> callback); |
577 void DoAddConstructor (Callback<ObjectBase *> callback, bool canBeDuplicate =
false); | |
578 ·· | 573 ·· |
579 /** The TypeId value. */· | 574 /** The TypeId value. */· |
580 uint16_t m_tid; | 575 uint16_t m_tid; |
581 }; | 576 }; |
582 | 577 |
583 /** | 578 /** |
584 * \relates TypeId | 579 * \relates TypeId |
585 * Output streamer. | 580 * Output streamer. |
586 * | 581 * |
587 * \param [in,out] os The output stream. | 582 * \param [in,out] os The output stream. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 642 |
648 template <typename T> | 643 template <typename T> |
649 TypeId· | 644 TypeId· |
650 TypeId::SetParent (void) | 645 TypeId::SetParent (void) |
651 { | 646 { |
652 return SetParent (T::GetTypeId ()); | 647 return SetParent (T::GetTypeId ()); |
653 } | 648 } |
654 | 649 |
655 template <typename T> | 650 template <typename T> |
656 TypeId· | 651 TypeId· |
657 TypeId::AddConstructor (bool canBeDuplicate) | 652 TypeId::AddConstructor (void) |
658 { | 653 { |
659 struct Maker { | 654 struct Maker { |
660 static ObjectBase * Create () { | 655 static ObjectBase * Create () { |
661 ObjectBase * base = new T (); | 656 ObjectBase * base = new T (); |
662 return base; | 657 return base; |
663 } | 658 } |
664 }; | 659 }; |
665 Callback<ObjectBase *> cb = MakeCallback (&Maker::Create); | 660 Callback<ObjectBase *> cb = MakeCallback (&Maker::Create); |
666 DoAddConstructor (cb, canBeDuplicate); | 661 DoAddConstructor (cb); |
667 return *this; | 662 return *this; |
668 } | 663 } |
669 | 664 |
670 } // namespace ns3 | 665 } // namespace ns3 |
671 | 666 |
672 #endif /* TYPE_ID_H */ | 667 #endif /* TYPE_ID_H */ |
LEFT | RIGHT |