A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
type-id.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#include "type-id.h"
9
10#include "hash.h"
11#include "log.h" // NS_ASSERT and NS_LOG
12#include "singleton.h"
14
15#include <map>
16#include <vector>
17
18/**
19 * @file
20 * @ingroup object
21 * ns3::TypeId and ns3::IidManager implementations.
22 */
23
24/*********************************************************************
25 * Helper code
26 *********************************************************************/
27
28namespace ns3
29{
30
32
33// IidManager needs to be in ns3 namespace for NS_ASSERT and NS_LOG
34// to find g_log
35
36/**
37 * @ingroup object
38 * @brief TypeId information manager
39 *
40 * Information records are stored in a vector. Name and hash lookup
41 * are performed by maps to the vector index.
42 *
43 * @internal
44 * <b>Hash Chaining</b>
45 *
46 * We require all types to produce distinct hashes. What if we encounter
47 * two types that produce the same hash value? As we move to a
48 * federated distribution model (the App store), it becomes increasingly
49 * likely that the core ns3 team *won't* discover this in test builds.
50 * Therefore, we need to handle this case explicitly.
51 *
52 * Note, we expect this to be *extremely* rare. As of this writing we
53 * have ~400 < 2^9 types, so the probability of getting a collision
54 * when we introduce a new type is ~2^9/2^31 = 2^-22, assuming we
55 * reserve 31 bits for the hash, and one bit for chaining. Even with
56 * double the number of types the probability of having a collision
57 * is only 2 x 10^-4. The probability for a three-fold collision is
58 * 1 x 10^-10.
59 *
60 * Therefore, we'll handle one collision explicitly by reserving
61 * the high order bit of the hash value, and assert on higher level
62 * collisions. The three-fold collision probability should be an
63 * acceptablly small error rate.
64 */
65class IidManager : public Singleton<IidManager>
66{
67 public:
68 /**
69 * Create a new unique type id.
70 * @param [in] name The name of this type id.
71 * @returns The id.
72 */
73 uint16_t AllocateUid(std::string name);
74 /**
75 * Add a deprecated name for the type id. Use of this name raises
76 * a runtime warning, and only one deprecated name is supported.
77 * @param [in] uid The id.
78 * @param [in] name The deprecated name.
79 */
80 void AddDeprecatedName(uint16_t uid, const std::string& name);
81 /**
82 * Set the parent of a type id.
83 * @param [in] uid The id.
84 * @param [in] parent The id of the parent.
85 */
86 void SetParent(uint16_t uid, uint16_t parent);
87 /**
88 * Set the group name of a type id.
89 * @param [in] uid The id.
90 * @param [in] groupName The group name.
91 */
92 void SetGroupName(uint16_t uid, std::string groupName);
93 /**
94 * Set the size of the object class referred to by this id.
95 * @param [in] uid The id.
96 * @param [in] size The object size.
97 */
98 void SetSize(uint16_t uid, std::size_t size);
99 /**
100 * Add a constructor Callback to this type id.
101 * @param [in] uid The id.
102 * @param [in] callback The Callback for the constructor.
103 */
104 void AddConstructor(uint16_t uid, Callback<ObjectBase*> callback);
105 /**
106 * Mark this type id to be excluded from documentation.
107 * @param [in] uid The id.
108 */
109 void HideFromDocumentation(uint16_t uid);
110 /**
111 * Get a type id by name.
112 * @param [in] name The type id to find.
113 * @returns The type id. A type id of 0 means \pname{name} wasn't found.
114 */
115 uint16_t GetUid(std::string name) const;
116 /**
117 * Get a type id by hash value.
118 * @param [in] hash The type id to find.
119 * @returns The type id. A type id of 0 means \pname{hash} wasn't found.
120 */
121 uint16_t GetUid(TypeId::hash_t hash) const;
122 /**
123 * Get the name of a type id.
124 * @param [in] uid The id.
125 * @returns The name of the type id.
126 */
127 std::string GetName(uint16_t uid) const;
128 /**
129 * Get the deprecated name of a type id.
130 * @param [in] uid The id.
131 * @returns The name of the type id.
132 */
133 std::string GetDeprecatedName(uint16_t uid) const;
134 /**
135 * Get the hash of a type id.
136 * @param [in] uid The id.
137 * @returns The hash of the type id.
138 */
139 TypeId::hash_t GetHash(uint16_t uid) const;
140 /**
141 * Get the parent of a type id.
142 * @param [in] uid The id.
143 * @returns The parent type id of the type id.
144 */
145 uint16_t GetParent(uint16_t uid) const;
146 /**
147 * Get the group name of a type id.
148 * @param [in] uid The id.
149 * @returns The group name of the type id.
150 */
151 std::string GetGroupName(uint16_t uid) const;
152 /**
153 * Get the size of a type id.
154 * @param [in] uid The id.
155 * @returns The size of the type id.
156 */
157 std::size_t GetSize(uint16_t uid) const;
158 /**
159 * Get the constructor Callback of a type id.
160 * @param [in] uid The id.
161 * @returns The constructor Callback of the type id.
162 */
163 Callback<ObjectBase*> GetConstructor(uint16_t uid) const;
164 /**
165 * Check if a type id has a constructor Callback.
166 * @param [in] uid The id.
167 * @returns \c true if the type id has a constructor Callback.
168 */
169 bool HasConstructor(uint16_t uid) const;
170 /**
171 * Get the total number of type ids.
172 * @returns The total number.
173 */
174 uint16_t GetRegisteredN() const;
175 /**
176 * Get a type id by index.
177 *
178 * The type id value 0 indicates not registered, so there is an offset
179 * of 1 between the index and the type id value. This function converts
180 * from an index to the type id value.
181 * @param [in] i The index.
182 * @returns The type id.
183 */
184 uint16_t GetRegistered(uint16_t i) const;
185 /**
186 * Record a new attribute in a type id.
187 * @param [in] uid The id.
188 * @param [in] name The name of the new attribute
189 * @param [in] help Some help text which describes the purpose of this
190 * attribute.
191 * @param [in] flags Flags which describe how this attribute can be
192 * read and/or written.
193 * @param [in] initialValue The initial value for this attribute.
194 * @param [in] accessor An instance of the associated AttributeAccessor
195 * subclass.
196 * @param [in] checker An instance of the associated AttributeChecker
197 * subclass.
198 * @param [in] supportLevel The support/deprecation status for this attribute.
199 * @param [in] supportMsg Upgrade hint if this attribute is no longer supported.
200 */
201 void AddAttribute(uint16_t uid,
202 std::string name,
203 std::string help,
204 uint32_t flags,
205 Ptr<const AttributeValue> initialValue,
209 const std::string& supportMsg = "");
210 /**
211 * Set the initial value of an Attribute.
212 * @param [in] uid The id.
213 * @param [in] i The attribute to manipulate
214 * @param [in] initialValue The new initial value to use for this attribute.
215 */
216 void SetAttributeInitialValue(uint16_t uid,
217 std::size_t i,
218 Ptr<const AttributeValue> initialValue);
219 /**
220 * Get the number of attributes.
221 * @param [in] uid The id.
222 * @returns The number of attributes associated to this TypeId
223 */
224 std::size_t GetAttributeN(uint16_t uid) const;
225 /**
226 * Get Attribute information by index.
227 * @param [in] uid The id.
228 * @param [in] i Index into attribute array
229 * @returns The information associated to attribute whose index is \pname{i}.
230 */
231 TypeId::AttributeInformation GetAttribute(uint16_t uid, std::size_t i) const;
232 /**
233 * Record a new TraceSource.
234 * @param [in] uid The id.
235 * @param [in] name The name of the new trace source
236 * @param [in] help Some help text which describes the purpose of this
237 * trace source.
238 * @param [in] accessor A pointer to a TraceSourceAccessor which can be
239 * used to connect/disconnect sinks to this trace source.
240 * @param [in] callback Fully qualified typedef name for the callback
241 * signature. Generally this should begin with the
242 * "ns3::" namespace qualifier.
243 * @param [in] supportLevel The support/deprecation status for this attribute.
244 * @param [in] supportMsg Upgrade hint if this attribute is no longer supported.
245 */
246 void AddTraceSource(uint16_t uid,
247 std::string name,
248 std::string help,
250 std::string callback,
252 const std::string& supportMsg = "");
253 /**
254 * Get the number of Trace sources.
255 * @param [in] uid The id.
256 * @returns The number of trace sources defined in this TypeId.
257 */
258 std::size_t GetTraceSourceN(uint16_t uid) const;
259 /**
260 * Get the trace source by index.
261 * @param [in] uid The id.
262 * @param [in] i Index into trace source array.
263 * @returns Detailed information about the requested trace source.
264 */
265 TypeId::TraceSourceInformation GetTraceSource(uint16_t uid, std::size_t i) const;
266 /**
267 * Check if this TypeId should not be listed in documentation.
268 * @param [in] uid The id.
269 * @returns \c true if this TypeId should be hidden from the user.
270 */
271 bool MustHideFromDocumentation(uint16_t uid) const;
272
273 private:
274 /**
275 * Check if a type id has a given TraceSource.
276 * @param [in] uid The id.
277 * @param [in] name The TraceSource name.
278 * @returns \c true if \pname{uid} has the TraceSource \pname{name}.
279 */
280 bool HasTraceSource(uint16_t uid, std::string name);
281 /**
282 * Check if a type id has a given Attribute.
283 * @param [in] uid The id.
284 * @param [in] name The Attribute name.
285 * @returns \c true if \pname{uid} has the Attribute \pname{name}.
286 */
287 bool HasAttribute(uint16_t uid, std::string name);
288 /**
289 * Hashing function.
290 * @param [in] name The type id name.
291 * @returns The hashed value of \pname{name}.
292 */
293 static TypeId::hash_t Hasher(const std::string name);
294
295 /** The information record about a single type id. */
297 {
298 /** The type id name. */
299 std::string name;
300 /** A deprecated type id name. */
301 std::string deprecatedName;
302 /** The type id hash value. */
304 /** The parent type id. */
305 uint16_t parent;
306 /** The group name. */
307 std::string groupName;
308 /** The size of the object represented by this type id. */
309 std::size_t size;
310 /** \c true if a constructor Callback has been registered. */
312 /** The constructor Callback. */
314 /** \c true if this type should be omitted from documentation. */
316 /** The container of Attributes. */
317 std::vector<TypeId::AttributeInformation> attributes;
318 /** The container of TraceSources. */
319 std::vector<TypeId::TraceSourceInformation> traceSources;
320 /** Support level/deprecation. */
322 /** Support message. */
323 std::string supportMsg;
324 };
325
326 /** Iterator type. */
327 typedef std::vector<IidInformation>::const_iterator Iterator;
328
329 /**
330 * Retrieve the information record for a type.
331 * @param [in] uid The id.
332 * @returns The information record.
333 */
335
336 /** The container of all type id records. */
337 std::vector<IidInformation> m_information;
338
339 /** Type of the by-name index. */
340 typedef std::map<std::string, uint16_t> namemap_t;
341 /** The by-name index. */
343
344 /** Type of the by-hash index. */
345 typedef std::map<TypeId::hash_t, uint16_t> hashmap_t;
346 /** The by-hash index. */
348
349 /** IidManager constants. */
350 enum
351 {
352 /**
353 * Hash chaining flag.
354 *
355 * To handle the first collision, we reserve the high bit as a
356 * chain flag.
357 */
358 HashChainFlag = 0x80000000
359 };
360};
361
362// static
364IidManager::Hasher(const std::string name)
365{
367 return hasher.clear().GetHash32(name);
368}
369
370/**
371 * @ingroup object
372 * @internal
373 * IidManager shorthand for use in NS_LOG
374 */
375#define IID "IidManager"
376/**
377 * @ingroup object
378 * @internal
379 * IidManager shorthand for use in NS_LOG
380 */
381#define IIDL IID << ": "
382
383uint16_t
384IidManager::AllocateUid(std::string name)
385{
386 NS_LOG_FUNCTION(IID << name);
387 // Type names are definitive: equal names are equal types
388 NS_ABORT_MSG_UNLESS(m_namemap.count(name) == 0,
389 "Trying to allocate twice the same uid: " << name);
390
391 TypeId::hash_t hash = Hasher(name) & (~HashChainFlag);
392 if (m_hashmap.count(hash) == 1)
393 {
394 NS_LOG_ERROR("Hash chaining TypeId for '"
395 << name << "'. "
396 << "This is not a bug, but is extremely unlikely. "
397 << "Please contact the ns3 developers.");
398 // ns3 developer contacted about this message:
399 // You have four options (in order of difficulty):
400 // 1. Let it ride, and play the odds that a third collision
401 // never appears.
402 // 2. Change the name of the new (or old) tag, even trivially, to
403 // remove the collision.
404 // 3. Switch to 64-bit hashes.
405 // 4. Implement 2-bit (or higher) chaining.
406 //
407 // Oh, by the way, I owe you a beer, since I bet Mathieu that
408 // this would never happen.. -- Peter Barnes, LLNL
409
410 NS_ASSERT_MSG(m_hashmap.count(hash | HashChainFlag) == 0,
411 "Triplicate hash detected while chaining TypeId for '"
412 << name << "'. Please contact the ns3 developers for assistance.");
413 // ns3 developer contacted about this message:
414 // You have three options: #2-4 above.
415 //
416 // Oh, by the way, I have no idea how this crazy hashing idea got
417 // into ns3. -- Peter Barnes, LLNL
418
419 // Alphabetize the two types, so it's deterministic
421 if (name > hinfo->name)
422 { // new type gets chained
423 NS_LOG_LOGIC(IIDL << "New TypeId '" << name << "' getting chained.");
424 hash = hash | HashChainFlag;
425 }
426 else
427 { // chain old type
428 NS_LOG_LOGIC(IIDL << "Old TypeId '" << hinfo->name << "' getting chained.");
429 uint16_t oldUid = GetUid(hinfo->hash);
430 m_hashmap.erase(m_hashmap.find(hinfo->hash));
431 hinfo->hash = hash | HashChainFlag;
432 m_hashmap.insert({hinfo->hash, oldUid});
433 // leave new hash unchained
434 }
435 }
436
437 IidInformation information;
438 information.name = name;
439 information.hash = hash;
440 information.parent = 0;
441 information.groupName = "";
442 information.size = (std::size_t)(-1);
443 information.hasConstructor = false;
444 information.mustHideFromDocumentation = false;
446 m_information.push_back(information);
447 std::size_t tuid = m_information.size();
448 NS_ASSERT(tuid <= 0xffff);
449 auto uid = static_cast<uint16_t>(tuid);
450
451 // Add to both maps:
452 m_namemap.insert({name, uid});
453 m_hashmap.insert({hash, uid});
454 NS_LOG_LOGIC(IIDL << uid);
455 return uid;
456}
457
460{
461 NS_LOG_FUNCTION(IID << uid);
462 NS_ASSERT_MSG(uid <= m_information.size() && uid != 0,
463 "The uid " << uid << " for this TypeId is invalid");
464 NS_LOG_LOGIC(IIDL << m_information[uid - 1].name);
465 return const_cast<IidInformation*>(&m_information[uid - 1]);
466}
467
468void
469IidManager::AddDeprecatedName(uint16_t uid, const std::string& name)
470{
471 NS_LOG_FUNCTION(IID << uid << name);
473 NS_ASSERT_MSG(info->deprecatedName.empty(),
474 "Deprecated name already added: " << info->deprecatedName);
475 const auto [it, success] = m_namemap.insert({name, uid});
476 NS_ASSERT_MSG(success,
477 "Deprecated name " << name << " insertion failed (possibly a duplicate?)");
478 info->deprecatedName = name;
479}
480
481void
482IidManager::SetParent(uint16_t uid, uint16_t parent)
483{
484 NS_LOG_FUNCTION(IID << uid << parent);
485 NS_ASSERT(parent <= m_information.size());
486 IidInformation* information = LookupInformation(uid);
487 information->parent = parent;
488}
489
490void
491IidManager::SetGroupName(uint16_t uid, std::string groupName)
492{
493 NS_LOG_FUNCTION(IID << uid << groupName);
494 IidInformation* information = LookupInformation(uid);
495 information->groupName = groupName;
496}
497
498void
499IidManager::SetSize(uint16_t uid, std::size_t size)
500{
501 NS_LOG_FUNCTION(IID << uid << size);
502 IidInformation* information = LookupInformation(uid);
503 information->size = size;
504}
505
506void
508{
509 NS_LOG_FUNCTION(IID << uid);
510 IidInformation* information = LookupInformation(uid);
511 information->mustHideFromDocumentation = true;
512}
513
514void
516{
517 NS_LOG_FUNCTION(IID << uid << &callback);
518 IidInformation* information = LookupInformation(uid);
519 if (information->hasConstructor)
520 {
521 NS_FATAL_ERROR(information->name << " already has a constructor.");
522 }
523 information->hasConstructor = true;
524 information->constructor = callback;
525}
526
527uint16_t
528IidManager::GetUid(std::string name) const
529{
530 NS_LOG_FUNCTION(IID << name);
531 uint16_t uid = 0;
532 auto it = m_namemap.find(name);
533 if (it != m_namemap.end())
534 {
535 uid = it->second;
536 }
537 NS_LOG_LOGIC(IIDL << uid);
538 return uid;
539}
540
541uint16_t
543{
544 NS_LOG_FUNCTION(IID << hash);
545 auto it = m_hashmap.find(hash);
546 uint16_t uid = 0;
547 if (it != m_hashmap.end())
548 {
549 uid = it->second;
550 }
551 NS_LOG_LOGIC(IIDL << uid);
552 return uid;
553}
554
555std::string
556IidManager::GetName(uint16_t uid) const
557{
558 NS_LOG_FUNCTION(IID << uid);
559 IidInformation* information = LookupInformation(uid);
560 NS_LOG_LOGIC(IIDL << information->name);
561 return information->name;
562}
563
564std::string
566{
567 NS_LOG_FUNCTION(IID << uid);
568 IidInformation* information = LookupInformation(uid);
569 NS_LOG_LOGIC(IIDL << information->deprecatedName);
570 return information->deprecatedName;
571}
572
574IidManager::GetHash(uint16_t uid) const
575{
576 NS_LOG_FUNCTION(IID << uid);
577 IidInformation* information = LookupInformation(uid);
578 TypeId::hash_t hash = information->hash;
579 NS_LOG_LOGIC(IIDL << hash);
580 return hash;
581}
582
583uint16_t
584IidManager::GetParent(uint16_t uid) const
585{
586 NS_LOG_FUNCTION(IID << uid);
587 IidInformation* information = LookupInformation(uid);
588 uint16_t pid = information->parent;
589 NS_LOG_LOGIC(IIDL << pid);
590 return pid;
591}
592
593std::string
594IidManager::GetGroupName(uint16_t uid) const
595{
596 NS_LOG_FUNCTION(IID << uid);
597 IidInformation* information = LookupInformation(uid);
598 NS_LOG_LOGIC(IIDL << information->groupName);
599 return information->groupName;
600}
601
602std::size_t
603IidManager::GetSize(uint16_t uid) const
604{
605 NS_LOG_FUNCTION(IID << uid);
606 IidInformation* information = LookupInformation(uid);
607 std::size_t size = information->size;
608 NS_LOG_LOGIC(IIDL << size);
609 return size;
610}
611
613IidManager::GetConstructor(uint16_t uid) const
614{
615 NS_LOG_FUNCTION(IID << uid);
616 IidInformation* information = LookupInformation(uid);
617 if (!information->hasConstructor)
618 {
619 NS_FATAL_ERROR("Requested constructor for " << information->name
620 << " but it does not have one.");
621 }
622 return information->constructor;
623}
624
625bool
626IidManager::HasConstructor(uint16_t uid) const
627{
628 NS_LOG_FUNCTION(IID << uid);
629 IidInformation* information = LookupInformation(uid);
630 bool hasC = information->hasConstructor;
631 NS_LOG_LOGIC(IIDL << hasC);
632 return hasC;
633}
634
635uint16_t
637{
639 return static_cast<uint16_t>(m_information.size());
640}
641
642uint16_t
644{
645 NS_LOG_FUNCTION(IID << i);
646 return i + 1;
647}
648
649bool
650IidManager::HasAttribute(uint16_t uid, std::string name)
651{
652 NS_LOG_FUNCTION(IID << uid << name);
653 IidInformation* information = LookupInformation(uid);
654 while (true)
655 {
656 for (auto i = information->attributes.begin(); i != information->attributes.end(); ++i)
657 {
658 if (i->name == name)
659 {
660 NS_LOG_LOGIC(IIDL << true);
661 return true;
662 }
663 }
664 IidInformation* parent = LookupInformation(information->parent);
665 if (parent == information)
666 {
667 // top of inheritance tree
668 NS_LOG_LOGIC(IIDL << false);
669 return false;
670 }
671 // check parent
672 information = parent;
673 }
674 NS_LOG_LOGIC(IIDL << false);
675 return false;
676}
677
678void
680 std::string name,
681 std::string help,
682 uint32_t flags,
683 Ptr<const AttributeValue> initialValue,
686 TypeId::SupportLevel supportLevel,
687 const std::string& supportMsg)
688{
689 NS_LOG_FUNCTION(IID << uid << name << help << flags << initialValue << accessor << checker
690 << supportLevel << supportMsg);
691 IidInformation* information = LookupInformation(uid);
692 if (name.find(' ') != std::string::npos)
693 {
694 NS_FATAL_ERROR("Attribute name \"" << name << "\" may not contain spaces ' ', "
695 << "encountered when registering TypeId \""
696 << information->name << "\"");
697 }
698 if (HasAttribute(uid, name))
699 {
700 NS_FATAL_ERROR("Attribute \"" << name << "\" already registered on tid=\""
701 << information->name << "\"");
702 }
704 info.name = name;
705 info.help = help;
706 info.flags = flags;
707 info.initialValue = initialValue;
708 info.originalInitialValue = initialValue;
709 info.accessor = accessor;
710 info.checker = checker;
711 info.supportLevel = supportLevel;
712 info.supportMsg = supportMsg;
713 information->attributes.push_back(info);
714 NS_LOG_LOGIC(IIDL << information->attributes.size() - 1);
715}
716
717void
719 std::size_t i,
720 Ptr<const AttributeValue> initialValue)
721{
722 NS_LOG_FUNCTION(IID << uid << i << initialValue);
723 IidInformation* information = LookupInformation(uid);
724 NS_ASSERT(i < information->attributes.size());
725 information->attributes[i].initialValue = initialValue;
726}
727
728std::size_t
729IidManager::GetAttributeN(uint16_t uid) const
730{
731 NS_LOG_FUNCTION(IID << uid);
732 IidInformation* information = LookupInformation(uid);
733 std::size_t size = information->attributes.size();
734 NS_LOG_LOGIC(IIDL << size);
735 return size;
736}
737
739IidManager::GetAttribute(uint16_t uid, std::size_t i) const
740{
741 NS_LOG_FUNCTION(IID << uid << i);
742 IidInformation* information = LookupInformation(uid);
743 NS_ASSERT(i < information->attributes.size());
744 NS_LOG_LOGIC(IIDL << information->name);
745 return information->attributes[i];
746}
747
748bool
749IidManager::HasTraceSource(uint16_t uid, std::string name)
750{
751 NS_LOG_FUNCTION(IID << uid << name);
752 IidInformation* information = LookupInformation(uid);
753 while (true)
754 {
755 for (auto i = information->traceSources.begin(); i != information->traceSources.end(); ++i)
756 {
757 if (i->name == name)
758 {
759 NS_LOG_LOGIC(IIDL << true);
760 return true;
761 }
762 }
763 IidInformation* parent = LookupInformation(information->parent);
764 if (parent == information)
765 {
766 // top of inheritance tree
767 NS_LOG_LOGIC(IIDL << false);
768 return false;
769 }
770 // check parent
771 information = parent;
772 }
773 NS_LOG_LOGIC(IIDL << false);
774 return false;
775}
776
777void
779 std::string name,
780 std::string help,
782 std::string callback,
783 TypeId::SupportLevel supportLevel,
784 const std::string& supportMsg)
785{
786 NS_LOG_FUNCTION(IID << uid << name << help << accessor << callback << supportLevel
787 << supportMsg);
788 IidInformation* information = LookupInformation(uid);
789 if (HasTraceSource(uid, name))
790 {
791 NS_FATAL_ERROR("Trace source \"" << name << "\" already registered on tid=\""
792 << information->name << "\"");
793 }
795 source.name = name;
796 source.help = help;
797 source.accessor = accessor;
798 source.callback = callback;
799 source.supportLevel = supportLevel;
800 source.supportMsg = supportMsg;
801 information->traceSources.push_back(source);
802 NS_LOG_LOGIC(IIDL << information->traceSources.size() - 1);
803}
804
805std::size_t
807{
808 NS_LOG_FUNCTION(IID << uid);
809 IidInformation* information = LookupInformation(uid);
810 std::size_t size = information->traceSources.size();
811 NS_LOG_LOGIC(IIDL << size);
812 return size;
813}
814
816IidManager::GetTraceSource(uint16_t uid, std::size_t i) const
817{
818 NS_LOG_FUNCTION(IID << uid << i);
819 IidInformation* information = LookupInformation(uid);
820 NS_ASSERT(i < information->traceSources.size());
821 NS_LOG_LOGIC(IIDL << information->name);
822 return information->traceSources[i];
823}
824
825bool
827{
828 NS_LOG_FUNCTION(IID << uid);
829 IidInformation* information = LookupInformation(uid);
830 bool hide = information->mustHideFromDocumentation;
831 NS_LOG_LOGIC(IIDL << hide);
832 return hide;
833}
834
835} // namespace ns3
836
837namespace ns3
838{
839
840/*********************************************************************
841 * The TypeId class
842 *********************************************************************/
843
844TypeId::TypeId(const std::string& name)
845{
846 NS_LOG_FUNCTION(this << name);
847 uint16_t uid = IidManager::Get()->AllocateUid(name);
848 NS_LOG_LOGIC(uid);
849 NS_ASSERT(uid != 0);
850 m_tid = uid;
851}
852
853TypeId::TypeId(uint16_t tid)
854 : m_tid(tid)
855{
856 NS_LOG_FUNCTION(this << tid);
857}
858
859TypeId
860TypeId::AddDeprecatedName(const std::string& name)
861{
862 NS_LOG_FUNCTION(this << name);
864 NS_LOG_INFO("Set deprecated name " << name << " for TypeId "
866 return *this;
867}
868
869TypeId
870TypeId::LookupByName(std::string name)
871{
872 NS_LOG_FUNCTION(name);
873 uint16_t uid = IidManager::Get()->GetUid(name);
874 NS_ASSERT_MSG(uid, "Assert in TypeId::LookupByName: " << name << " not found");
875 if (IidManager::Get()->GetDeprecatedName(uid) == name)
876 {
877 std::cerr << "Deprecation warning for name " << name << "; use "
878 << IidManager::Get()->GetName(uid) << " instead" << std::endl;
879 }
880 return TypeId(uid);
881}
882
883bool
885{
886 NS_LOG_FUNCTION(name << tid->GetUid());
887 uint16_t uid = IidManager::Get()->GetUid(name);
888 if (uid == 0)
889 {
890 return false;
891 }
892 *tid = TypeId(uid);
893 if (IidManager::Get()->GetDeprecatedName(uid) == name)
894 {
895 std::cerr << "Deprecation warning for name " << name << "; use "
896 << IidManager::Get()->GetName(uid) << " instead" << std::endl;
897 }
898 return true;
899}
900
901TypeId
903{
904 uint16_t uid = IidManager::Get()->GetUid(hash);
905 NS_ASSERT_MSG(uid != 0,
906 "Assert in TypeId::LookupByHash: 0x" << std::hex << hash << std::dec
907 << " not found");
908 return TypeId(uid);
909}
910
911bool
913{
914 uint16_t uid = IidManager::Get()->GetUid(hash);
915 if (uid == 0)
916 {
917 return false;
918 }
919 *tid = TypeId(uid);
920 return true;
921}
922
923uint16_t
929
930TypeId
932{
935}
936
937std::tuple<bool, TypeId, TypeId::AttributeInformation>
938TypeId::FindAttribute(const TypeId& tid, const std::string& name)
939{
940 TypeId currentTid = tid;
941 TypeId parentTid;
942 while (true)
943 {
944 for (std::size_t i = 0; i < currentTid.GetAttributeN(); ++i)
945 {
946 const AttributeInformation& attributeInfo = currentTid.GetAttribute(i);
947 if (attributeInfo.name == name)
948 {
949 return {true, currentTid, attributeInfo};
950 }
951 }
952
953 parentTid = currentTid.GetParent();
954
955 if (parentTid == currentTid)
956 {
957 break;
958 }
959
960 currentTid = parentTid;
961 }
962 return {false, TypeId(), AttributeInformation()};
963}
964
965bool
968 bool permissive) const
969{
970 NS_LOG_FUNCTION(this << name << info);
971 auto [found, tid, attribute] = FindAttribute(*this, name);
972 if (found)
973 {
974 if (attribute.supportLevel == SupportLevel::SUPPORTED)
975 {
976 *info = attribute;
977 return true;
978 }
979 else if (attribute.supportLevel == SupportLevel::DEPRECATED)
980 {
981 if (!permissive)
982 {
983 std::cerr << "Attribute '" << name << "' is deprecated: " << attribute.supportMsg
984 << std::endl;
985 }
986 *info = attribute;
987 return true;
988 }
989 else if (attribute.supportLevel == SupportLevel::OBSOLETE)
990 {
991 NS_FATAL_ERROR("Attribute '"
992 << name << "' is obsolete, with no fallback: " << attribute.supportMsg);
993 }
994 }
995 return false;
996}
997
998TypeId
1000{
1001 NS_LOG_FUNCTION(this << tid.GetUid());
1003 return *this;
1004}
1005
1006TypeId
1007TypeId::SetGroupName(std::string groupName)
1008{
1009 NS_LOG_FUNCTION(this << groupName);
1010 IidManager::Get()->SetGroupName(m_tid, groupName);
1011 return *this;
1012}
1013
1014TypeId
1015TypeId::SetSize(std::size_t size)
1016{
1017 NS_LOG_FUNCTION(this << size);
1018 IidManager::Get()->SetSize(m_tid, size);
1019 return *this;
1020}
1021
1022TypeId
1024{
1025 NS_LOG_FUNCTION(this);
1026 uint16_t parent = IidManager::Get()->GetParent(m_tid);
1027 return TypeId(parent);
1028}
1029
1030bool
1032{
1033 NS_LOG_FUNCTION(this);
1034 uint16_t parent = IidManager::Get()->GetParent(m_tid);
1035 return parent != m_tid;
1036}
1037
1038bool
1040{
1041 NS_LOG_FUNCTION(this << other.GetUid());
1042 TypeId tmp = *this;
1043 while (tmp != other && tmp != tmp.GetParent())
1044 {
1045 tmp = tmp.GetParent();
1046 }
1047 return tmp == other && *this != other;
1048}
1049
1050std::string
1052{
1053 NS_LOG_FUNCTION(this);
1054 std::string groupName = IidManager::Get()->GetGroupName(m_tid);
1055 return groupName;
1056}
1057
1058std::string
1060{
1061 NS_LOG_FUNCTION(this);
1062 std::string name = IidManager::Get()->GetName(m_tid);
1063 return name;
1064}
1065
1068{
1070 return hash;
1071}
1072
1073std::size_t
1075{
1076 NS_LOG_FUNCTION(this);
1077 std::size_t size = IidManager::Get()->GetSize(m_tid);
1078 return size;
1079}
1080
1081bool
1083{
1084 NS_LOG_FUNCTION(this);
1085 bool hasConstructor = IidManager::Get()->HasConstructor(m_tid);
1086 return hasConstructor;
1087}
1088
1089void
1095
1096TypeId
1097TypeId::AddAttribute(std::string name,
1098 std::string help,
1099 const AttributeValue& initialValue,
1102 SupportLevel supportLevel,
1103 const std::string& supportMsg)
1104{
1105 NS_LOG_FUNCTION(this << name << help << &initialValue << accessor << checker << supportLevel
1106 << supportMsg);
1108 name,
1109 help,
1110 ATTR_SGC,
1111 initialValue.Copy(),
1112 accessor,
1113 checker,
1114 supportLevel,
1115 supportMsg);
1116 return *this;
1117}
1118
1119TypeId
1120TypeId::AddAttribute(std::string name,
1121 std::string help,
1122 uint32_t flags,
1123 const AttributeValue& initialValue,
1126 SupportLevel supportLevel,
1127 const std::string& supportMsg)
1128{
1129 NS_LOG_FUNCTION(this << name << help << flags << &initialValue << accessor << checker
1130 << supportLevel << supportMsg);
1132 name,
1133 help,
1134 flags,
1135 initialValue.Copy(),
1136 accessor,
1137 checker,
1138 supportLevel,
1139 supportMsg);
1140 return *this;
1141}
1142
1143bool
1145{
1146 NS_LOG_FUNCTION(this << i << initialValue);
1147 IidManager::Get()->SetAttributeInitialValue(m_tid, i, initialValue);
1148 return true;
1149}
1150
1153{
1154 NS_LOG_FUNCTION(this);
1156 return cb;
1157}
1158
1159bool
1161{
1162 NS_LOG_FUNCTION(this);
1164 return mustHide;
1165}
1166
1167std::size_t
1169{
1170 NS_LOG_FUNCTION(this);
1171 std::size_t n = IidManager::Get()->GetAttributeN(m_tid);
1172 return n;
1173}
1174
1176TypeId::GetAttribute(std::size_t i) const
1177{
1178 NS_LOG_FUNCTION(this << i);
1179 return IidManager::Get()->GetAttribute(m_tid, i);
1180}
1181
1182std::string
1184{
1185 NS_LOG_FUNCTION(this << i);
1187 return GetName() + "::" + info.name;
1188}
1189
1190std::size_t
1192{
1193 NS_LOG_FUNCTION(this);
1195}
1196
1198TypeId::GetTraceSource(std::size_t i) const
1199{
1200 NS_LOG_FUNCTION(this << i);
1201 return IidManager::Get()->GetTraceSource(m_tid, i);
1202}
1203
1204TypeId
1205TypeId::AddTraceSource(std::string name,
1206 std::string help,
1208 std::string callback,
1209 SupportLevel supportLevel,
1210 const std::string& supportMsg)
1211{
1212 NS_LOG_FUNCTION(this << name << help << accessor << callback << supportLevel << supportMsg);
1214 ->AddTraceSource(m_tid, name, help, accessor, callback, supportLevel, supportMsg);
1215 return *this;
1216}
1217
1218TypeId
1220{
1221 NS_LOG_FUNCTION(this);
1223 return *this;
1224}
1225
1228{
1229 NS_LOG_FUNCTION(this << name);
1230 TypeId tid;
1231 TypeId nextTid = *this;
1233 do
1234 {
1235 tid = nextTid;
1236 for (std::size_t i = 0; i < tid.GetTraceSourceN(); i++)
1237 {
1238 tmp = tid.GetTraceSource(i);
1239 if (tmp.name == name)
1240 {
1242 {
1243 *info = tmp;
1244 return tmp.accessor;
1245 }
1246 else if (tmp.supportLevel == SupportLevel::DEPRECATED)
1247 {
1248 std::cerr << "TraceSource '" << name << "' is deprecated: " << tmp.supportMsg
1249 << std::endl;
1250 *info = tmp;
1251 return tmp.accessor;
1252 }
1253 else if (tmp.supportLevel == SupportLevel::OBSOLETE)
1254 {
1255 NS_FATAL_ERROR("TraceSource '" << name << "' is obsolete, with no fallback: "
1256 << tmp.supportMsg);
1257 }
1258 }
1259 }
1260 nextTid = tid.GetParent();
1261 } while (nextTid != tid);
1262 return nullptr;
1263}
1264
1266TypeId::LookupTraceSourceByName(std::string name) const
1267{
1269 return LookupTraceSourceByName(name, &info);
1270}
1271
1272uint16_t
1274{
1275 NS_LOG_FUNCTION(this);
1276 return m_tid;
1277}
1278
1279void
1280TypeId::SetUid(uint16_t uid)
1281{
1282 NS_LOG_FUNCTION(this << uid);
1283 m_tid = uid;
1284}
1285
1286/**
1287 * @brief Insertion operator for TypeId
1288 * @param [in] os the output stream
1289 * @param [in] tid the TypeId
1290 * @returns the updated output stream.
1291 */
1292std::ostream&
1293operator<<(std::ostream& os, TypeId tid)
1294{
1295 os << tid.GetName();
1296 return os;
1297}
1298
1299/**
1300 * @brief Extraction operator for TypeId
1301 * @param [in] is the input stream
1302 * @param [out] tid the TypeId value
1303 * @returns the updated input stream.
1304 */
1305std::istream&
1306operator>>(std::istream& is, TypeId& tid)
1307{
1308 std::string tidString;
1309 is >> tidString;
1310 bool ok = TypeId::LookupByNameFailSafe(tidString, &tid);
1311 if (!ok)
1312 {
1313 is.setstate(std::ios_base::badbit);
1314 }
1315 return is;
1316}
1317
1318std::ostream&
1319operator<<(std::ostream& os, TypeId::SupportLevel level)
1320{
1321 switch (level)
1322 {
1324 return os << "SUPPORTED";
1326 return os << "DEPRECATED";
1328 return os << "OBSOLETE";
1329 };
1330 return os << "UNKNOWN(" << static_cast<uint32_t>(level) << ")";
1331}
1332
1334
1335bool
1337{
1338 return a.m_tid < b.m_tid;
1339}
1340
1341} // namespace ns3
Hold a value for an Attribute.
Definition attribute.h:59
virtual Ptr< AttributeValue > Copy() const =0
Callback template class.
Definition callback.h:428
Generic Hash function interface.
Definition hash.h:76
uint32_t GetHash32(const char *buffer, const std::size_t size)
Compute 32-bit hash of a byte buffer.
Definition hash.h:227
Hasher & clear()
Restore initial state.
Definition hash.cc:45
TypeId information manager.
Definition type-id.cc:66
TypeId::hash_t GetHash(uint16_t uid) const
Get the hash of a type id.
Definition type-id.cc:574
std::map< TypeId::hash_t, uint16_t > hashmap_t
Type of the by-hash index.
Definition type-id.cc:345
std::vector< IidInformation >::const_iterator Iterator
Iterator type.
Definition type-id.cc:327
uint16_t GetRegisteredN() const
Get the total number of type ids.
Definition type-id.cc:636
uint16_t GetParent(uint16_t uid) const
Get the parent of a type id.
Definition type-id.cc:584
void AddAttribute(uint16_t uid, std::string name, std::string help, uint32_t flags, Ptr< const AttributeValue > initialValue, Ptr< const AttributeAccessor > accessor, Ptr< const AttributeChecker > checker, TypeId::SupportLevel supportLevel=TypeId::SupportLevel::SUPPORTED, const std::string &supportMsg="")
Record a new attribute in a type id.
Definition type-id.cc:679
std::map< std::string, uint16_t > namemap_t
Type of the by-name index.
Definition type-id.cc:340
void SetAttributeInitialValue(uint16_t uid, std::size_t i, Ptr< const AttributeValue > initialValue)
Set the initial value of an Attribute.
Definition type-id.cc:718
void SetGroupName(uint16_t uid, std::string groupName)
Set the group name of a type id.
Definition type-id.cc:491
void SetParent(uint16_t uid, uint16_t parent)
Set the parent of a type id.
Definition type-id.cc:482
std::vector< IidInformation > m_information
The container of all type id records.
Definition type-id.cc:337
void SetSize(uint16_t uid, std::size_t size)
Set the size of the object class referred to by this id.
Definition type-id.cc:499
std::string GetGroupName(uint16_t uid) const
Get the group name of a type id.
Definition type-id.cc:594
bool HasTraceSource(uint16_t uid, std::string name)
Check if a type id has a given TraceSource.
Definition type-id.cc:749
uint16_t GetRegistered(uint16_t i) const
Get a type id by index.
Definition type-id.cc:643
@ HashChainFlag
Hash chaining flag.
Definition type-id.cc:358
Callback< ObjectBase * > GetConstructor(uint16_t uid) const
Get the constructor Callback of a type id.
Definition type-id.cc:613
void AddTraceSource(uint16_t uid, std::string name, std::string help, Ptr< const TraceSourceAccessor > accessor, std::string callback, TypeId::SupportLevel supportLevel=TypeId::SupportLevel::SUPPORTED, const std::string &supportMsg="")
Record a new TraceSource.
Definition type-id.cc:778
std::size_t GetAttributeN(uint16_t uid) const
Get the number of attributes.
Definition type-id.cc:729
uint16_t GetUid(std::string name) const
Get a type id by name.
Definition type-id.cc:528
void AddConstructor(uint16_t uid, Callback< ObjectBase * > callback)
Add a constructor Callback to this type id.
Definition type-id.cc:515
void HideFromDocumentation(uint16_t uid)
Mark this type id to be excluded from documentation.
Definition type-id.cc:507
std::string GetName(uint16_t uid) const
Get the name of a type id.
Definition type-id.cc:556
std::size_t GetTraceSourceN(uint16_t uid) const
Get the number of Trace sources.
Definition type-id.cc:806
std::size_t GetSize(uint16_t uid) const
Get the size of a type id.
Definition type-id.cc:603
TypeId::TraceSourceInformation GetTraceSource(uint16_t uid, std::size_t i) const
Get the trace source by index.
Definition type-id.cc:816
std::string GetDeprecatedName(uint16_t uid) const
Get the deprecated name of a type id.
Definition type-id.cc:565
bool MustHideFromDocumentation(uint16_t uid) const
Check if this TypeId should not be listed in documentation.
Definition type-id.cc:826
IidManager::IidInformation * LookupInformation(uint16_t uid) const
Retrieve the information record for a type.
Definition type-id.cc:459
bool HasConstructor(uint16_t uid) const
Check if a type id has a constructor Callback.
Definition type-id.cc:626
bool HasAttribute(uint16_t uid, std::string name)
Check if a type id has a given Attribute.
Definition type-id.cc:650
static TypeId::hash_t Hasher(const std::string name)
Hashing function.
Definition type-id.cc:364
void AddDeprecatedName(uint16_t uid, const std::string &name)
Add a deprecated name for the type id.
Definition type-id.cc:469
hashmap_t m_hashmap
The by-hash index.
Definition type-id.cc:347
uint16_t AllocateUid(std::string name)
Create a new unique type id.
Definition type-id.cc:384
TypeId::AttributeInformation GetAttribute(uint16_t uid, std::size_t i) const
Get Attribute information by index.
Definition type-id.cc:739
namemap_t m_namemap
The by-name index.
Definition type-id.cc:342
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Singleton(const Singleton< IidManager > &)=delete
static IidManager * Get()
Definition singleton.h:96
a unique identifier for an interface.
Definition type-id.h:49
bool IsChildOf(TypeId other) const
Check if this TypeId is a child of another.
Definition type-id.cc:1039
std::size_t GetTraceSourceN() const
Get the number of Trace sources.
Definition type-id.cc:1191
bool SetAttributeInitialValue(std::size_t i, Ptr< const AttributeValue > initialValue)
Set the initial value of an Attribute.
Definition type-id.cc:1144
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition type-id.cc:870
TypeId AddAttribute(std::string name, std::string help, const AttributeValue &initialValue, Ptr< const AttributeAccessor > accessor, Ptr< const AttributeChecker > checker, SupportLevel supportLevel=SupportLevel::SUPPORTED, const std::string &supportMsg="")
Record in this TypeId the fact that a new attribute exists.
Definition type-id.cc:1097
bool HasParent() const
Check if this TypeId has a parent.
Definition type-id.cc:1031
TypeId SetSize(std::size_t size)
Set the size of this type.
Definition type-id.cc:1015
hash_t GetHash() const
Get the hash.
Definition type-id.cc:1067
bool MustHideFromDocumentation() const
Check if this TypeId should not be listed in documentation.
Definition type-id.cc:1160
TypeId AddDeprecatedName(const std::string &name)
Add an deprecated name for a TypeId.
Definition type-id.cc:860
@ ATTR_SGC
The attribute can be read, and written at any time.
Definition type-id.h:57
static bool LookupByHashFailSafe(hash_t hash, TypeId *tid)
Get a TypeId by hash.
Definition type-id.cc:912
TypeId::TraceSourceInformation GetTraceSource(std::size_t i) const
Get the trace source by index.
Definition type-id.cc:1198
std::string GetGroupName() const
Get the group name.
Definition type-id.cc:1051
TypeId HideFromDocumentation()
Hide this TypeId from documentation.
Definition type-id.cc:1219
Callback< ObjectBase * > GetConstructor() const
Get the constructor callback.
Definition type-id.cc:1152
static uint16_t GetRegisteredN()
Get the number of registered TypeIds.
Definition type-id.cc:924
std::string GetAttributeFullName(std::size_t i) const
Get the Attribute name by index.
Definition type-id.cc:1183
bool HasConstructor() const
Check if this TypeId has a constructor.
Definition type-id.cc:1082
std::size_t GetAttributeN() const
Get the number of attributes.
Definition type-id.cc:1168
TypeId GetParent() const
Get the parent of this TypeId.
Definition type-id.cc:1023
void SetUid(uint16_t uid)
Set the internal id of this TypeId.
Definition type-id.cc:1280
uint16_t m_tid
The TypeId value.
Definition type-id.h:607
TypeId SetGroupName(std::string groupName)
Set the group name.
Definition type-id.cc:1007
static TypeId LookupByHash(hash_t hash)
Get a TypeId by hash.
Definition type-id.cc:902
static TypeId GetRegistered(uint16_t i)
Get a TypeId by index.
Definition type-id.cc:931
std::size_t GetSize() const
Get the size of this object.
Definition type-id.cc:1074
Ptr< const TraceSourceAccessor > LookupTraceSourceByName(std::string name) const
Find a TraceSource by name.
Definition type-id.cc:1266
uint32_t hash_t
Type of hash values.
Definition type-id.h:125
TypeId()
Default constructor.
Definition type-id.h:655
TypeId::AttributeInformation GetAttribute(std::size_t i) const
Get Attribute information by index.
Definition type-id.cc:1176
uint16_t GetUid() const
Get the internal id of this TypeId.
Definition type-id.cc:1273
TypeId(const std::string &name)
Constructor.
Definition type-id.cc:844
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name.
Definition type-id.cc:884
TypeId AddTraceSource(std::string name, std::string help, Ptr< const TraceSourceAccessor > accessor, std::string callback, SupportLevel supportLevel=SupportLevel::SUPPORTED, const std::string &supportMsg="")
Record a new TraceSource.
Definition type-id.cc:1205
bool LookupAttributeByName(std::string name, AttributeInformation *info, bool permissive=false) const
Find an Attribute by name, retrieving the associated AttributeInformation.
Definition type-id.cc:966
SupportLevel
The level of support or deprecation for attributes or trace sources.
Definition type-id.h:63
@ SUPPORTED
Attribute or trace source is currently used.
Definition type-id.h:64
@ OBSOLETE
Attribute or trace source is not used anymore; simulation fails.
Definition type-id.h:66
@ DEPRECATED
Attribute or trace source is deprecated; user is warned.
Definition type-id.h:65
static std::tuple< bool, TypeId, AttributeInformation > FindAttribute(const TypeId &tid, const std::string &name)
Find an attribute by name in the inheritance tree for a given TypeId.
Definition type-id.cc:938
std::string GetName() const
Get the name.
Definition type-id.cc:1059
TypeId SetParent()
Set the parent TypeId.
Definition type-id.h:694
void DoAddConstructor(Callback< ObjectBase * > callback)
Implementation for AddConstructor().
Definition type-id.cc:1090
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition abort.h:133
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition log.h:246
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:194
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:274
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:267
#define IIDL
Definition type-id.cc:381
#define IID
Definition type-id.cc:375
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:454
ns3::Hasher, ns3::Hash32() and ns3::Hash64() function declarations.
Debug message logging.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
std::istream & operator>>(std::istream &is, Angles &a)
Definition angles.cc:172
bool operator<(const EventId &a, const EventId &b)
Definition event-id.h:159
ns3::Singleton declaration and template implementation.
The information record about a single type id.
Definition type-id.cc:297
std::string groupName
The group name.
Definition type-id.cc:307
uint16_t parent
The parent type id.
Definition type-id.cc:305
std::string deprecatedName
A deprecated type id name.
Definition type-id.cc:301
std::vector< TypeId::TraceSourceInformation > traceSources
The container of TraceSources.
Definition type-id.cc:319
std::size_t size
The size of the object represented by this type id.
Definition type-id.cc:309
std::string supportMsg
Support message.
Definition type-id.cc:323
std::string name
The type id name.
Definition type-id.cc:299
std::vector< TypeId::AttributeInformation > attributes
The container of Attributes.
Definition type-id.cc:317
Callback< ObjectBase * > constructor
The constructor Callback.
Definition type-id.cc:313
bool hasConstructor
true if a constructor Callback has been registered.
Definition type-id.cc:311
bool mustHideFromDocumentation
true if this type should be omitted from documentation.
Definition type-id.cc:315
TypeId::hash_t hash
The type id hash value.
Definition type-id.cc:303
TypeId::SupportLevel supportLevel
Support level/deprecation.
Definition type-id.cc:321
Attribute implementation.
Definition type-id.h:86
Ptr< const AttributeValue > originalInitialValue
Default initial value.
Definition type-id.h:94
TypeId::SupportLevel supportLevel
Support level/deprecation.
Definition type-id.h:102
std::string name
Attribute name.
Definition type-id.h:88
Ptr< const AttributeAccessor > accessor
Accessor object.
Definition type-id.h:98
uint32_t flags
AttributeFlags value.
Definition type-id.h:92
Ptr< const AttributeChecker > checker
Checker object.
Definition type-id.h:100
std::string supportMsg
Support message.
Definition type-id.h:104
Ptr< const AttributeValue > initialValue
Configured initial value.
Definition type-id.h:96
std::string help
Attribute help string.
Definition type-id.h:90
TraceSource implementation.
Definition type-id.h:109
std::string name
Trace name.
Definition type-id.h:111
std::string supportMsg
Support message.
Definition type-id.h:121
std::string help
Trace help string.
Definition type-id.h:113
Ptr< const TraceSourceAccessor > accessor
Trace accessor.
Definition type-id.h:117
std::string callback
Callback function signature type.
Definition type-id.h:115
TypeId::SupportLevel supportLevel
Support level/deprecation.
Definition type-id.h:119
ns3::TraceSourceAccessor and ns3::MakeTraceSourceAccessor declarations.
ns3::TypeId declaration; inline and template implementations.