A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
type-id.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
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
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #include "log.h" // NS_ASSERT and NS_LOG
21 #include "hash.h"
22 #include "type-id.h"
23 #include "singleton.h"
24 #include "trace-source-accessor.h"
25 
26 #include <map>
27 #include <vector>
28 #include <sstream>
29 #include <iomanip>
30 
31 /*********************************************************************
32  * Helper code
33  *********************************************************************/
34 
35 namespace ns3 {
36 
37 NS_LOG_COMPONENT_DEFINE ("TypeId")
38  ;
39 
40 // IidManager needs to be in ns3 namespace for NS_ASSERT and NS_LOG
41 // to find g_log
42 
72 {
73 public:
74  IidManager ();
75  uint16_t AllocateUid (std::string name);
76  void SetParent (uint16_t uid, uint16_t parent);
77  void SetGroupName (uint16_t uid, std::string groupName);
78  void AddConstructor (uint16_t uid, Callback<ObjectBase *> callback);
79  void HideFromDocumentation (uint16_t uid);
80  uint16_t GetUid (std::string name) const;
81  uint16_t GetUid (TypeId::hash_t hash) const;
82  std::string GetName (uint16_t uid) const;
83  TypeId::hash_t GetHash (uint16_t uid) const;
84  uint16_t GetParent (uint16_t uid) const;
85  std::string GetGroupName (uint16_t uid) const;
86  Callback<ObjectBase *> GetConstructor (uint16_t uid) const;
87  bool HasConstructor (uint16_t uid) const;
88  uint32_t GetRegisteredN (void) const;
89  uint16_t GetRegistered (uint32_t i) const;
90  void AddAttribute (uint16_t uid,
91  std::string name,
92  std::string help,
93  uint32_t flags,
94  Ptr<const AttributeValue> initialValue,
97  void SetAttributeInitialValue(uint16_t uid,
98  uint32_t i,
99  Ptr<const AttributeValue> initialValue);
100  uint32_t GetAttributeN (uint16_t uid) const;
101  struct TypeId::AttributeInformation GetAttribute(uint16_t uid, uint32_t i) const;
102  void AddTraceSource (uint16_t uid,
103  std::string name,
104  std::string help,
106  uint32_t GetTraceSourceN (uint16_t uid) const;
107  struct TypeId::TraceSourceInformation GetTraceSource(uint16_t uid, uint32_t i) const;
108  bool MustHideFromDocumentation (uint16_t uid) const;
109 
110 private:
111  bool HasTraceSource (uint16_t uid, std::string name);
112  bool HasAttribute (uint16_t uid, std::string name);
113  static TypeId::hash_t Hasher (const std::string name);
114 
115  struct IidInformation {
116  std::string name;
118  uint16_t parent;
119  std::string groupName;
123  std::vector<struct TypeId::AttributeInformation> attributes;
124  std::vector<struct TypeId::TraceSourceInformation> traceSources;
125  };
126  typedef std::vector<struct IidInformation>::const_iterator Iterator;
127 
128  struct IidManager::IidInformation *LookupInformation (uint16_t uid) const;
129 
130  std::vector<struct IidInformation> m_information;
131 
132  typedef std::map<std::string, uint16_t> namemap_t;
134 
135  typedef std::map<TypeId::hash_t, uint16_t> hashmap_t;
137 
138 
139  // To handle the first collision, we reserve the high bit as a
140  // chain flag:
141  enum { HashChainFlag = 0x80000000};
142 };
143 
145 {
146  NS_LOG_FUNCTION (this);
147 }
148 
149  //static
151 IidManager::Hasher (const std::string name)
152 {
153  static ns3::Hasher hasher ( Create<Hash::Function::Murmur3> () );
154  return hasher.clear ().GetHash32 (name);
155 }
156 
157 uint16_t
158 IidManager::AllocateUid (std::string name)
159 {
160  NS_LOG_FUNCTION (this << name);
161  // Type names are definitive: equal names are equal types
162  NS_ASSERT_MSG (m_namemap.count (name) == 0,
163  "Trying to allocate twice the same uid: " << name);
164 
165  TypeId::hash_t hash = Hasher (name) & (~HashChainFlag);
166  if (m_hashmap.count (hash) == 1) {
167  NS_LOG_ERROR ("Hash chaining TypeId for '" << name << "'. "
168  << "This is not a bug, but is extremely unlikely. "
169  << "Please contact the ns3 developers.");
170  // ns3 developer contacted about this message:
171  // You have four options (in order of difficulty):
172  // 1. Let it ride, and play the odds that a third collision
173  // never appears.
174  // 2. Change the name of the new (or old) tag, even trivially, to
175  // remove the collision.
176  // 3. Switch to 64-bit hashes.
177  // 4. Implement 2-bit (or higher) chaining.
178  //
179  // Oh, by the way, I owe you a beer, since I bet Mathieu that
180  // this would never happen.. -- Peter Barnes, LLNL
181 
182  NS_ASSERT_MSG (m_hashmap.count (hash | HashChainFlag) == 0,
183  "Triplicate hash detected while chaining TypeId for '"
184  << name
185  << "'. Please contact the ns3 developers for assistance.");
186  // ns3 developer contacted about this message:
187  // You have three options: #2-4 above.
188  //
189  // Oh, by the way, I have no idea how this crazy hashing idea got
190  // into ns3. -- Peter Barnes, LLNL
191 
192  // Alphabetize the two types, so it's deterministic
193  struct IidInformation * hinfo = LookupInformation (GetUid (hash));
194  if (name > hinfo->name)
195  { // new type gets chained
196  NS_LOG_LOGIC ("New TypeId '" << name << "' getting chained.");
197  hash = hash | HashChainFlag;
198  }
199  else
200  { // chain old type
201  NS_LOG_LOGIC ("Old TypeId '" << hinfo->name << "' getting chained.");
202  uint32_t oldUid = GetUid (hinfo->hash);
203  m_hashmap.erase (m_hashmap.find (hinfo->hash));
204  hinfo->hash = hash | HashChainFlag;
205  m_hashmap.insert (std::make_pair (hinfo->hash, oldUid));
206  // leave new hash unchained
207  }
208  }
209 
210  struct IidInformation information;
211  information.name = name;
212  information.hash = hash;
213  information.parent = 0;
214  information.groupName = "";
215  information.hasConstructor = false;
216  information.mustHideFromDocumentation = false;
217  m_information.push_back (information);
218  uint32_t uid = m_information.size ();
219  NS_ASSERT (uid <= 0xffff);
220 
221  // Add to both maps:
222  m_namemap.insert (std::make_pair (name, uid));
223  m_hashmap.insert (std::make_pair (hash, uid));
224  return uid;
225 }
226 
228 IidManager::LookupInformation (uint16_t uid) const
229 {
230  NS_LOG_FUNCTION (this << uid);
231  NS_ASSERT (uid <= m_information.size () && uid != 0);
232  return const_cast<struct IidInformation *> (&m_information[uid-1]);
233 }
234 
235 void
236 IidManager::SetParent (uint16_t uid, uint16_t parent)
237 {
238  NS_LOG_FUNCTION (this << uid << parent);
239  NS_ASSERT (parent <= m_information.size ());
240  struct IidInformation *information = LookupInformation (uid);
241  information->parent = parent;
242 }
243 void
244 IidManager::SetGroupName (uint16_t uid, std::string groupName)
245 {
246  NS_LOG_FUNCTION (this << uid << groupName);
247  struct IidInformation *information = LookupInformation (uid);
248  information->groupName = groupName;
249 }
250 void
252 {
253  NS_LOG_FUNCTION (this << uid);
254  struct IidInformation *information = LookupInformation (uid);
255  information->mustHideFromDocumentation = true;
256 }
257 
258 void
260 {
261  NS_LOG_FUNCTION (this << uid << &callback);
262  struct IidInformation *information = LookupInformation (uid);
263  if (information->hasConstructor)
264  {
265  NS_FATAL_ERROR (information->name<<" already has a constructor.");
266  }
267  information->hasConstructor = true;
268  information->constructor = callback;
269 }
270 
271 uint16_t
272 IidManager::GetUid (std::string name) const
273 {
274  NS_LOG_FUNCTION (this << name);
275  namemap_t::const_iterator it = m_namemap.find (name);
276  if (it != m_namemap.end ())
277  {
278  return it->second;
279  }
280  else
281  {
282  return 0;
283  }
284 }
285 uint16_t
287 {
288  hashmap_t::const_iterator it = m_hashmap.find (hash);
289  if (it != m_hashmap.end ())
290  {
291  return it->second;
292  }
293  else
294  { // hash not found
295  return 0;
296  }
297 }
298 std::string
299 IidManager::GetName (uint16_t uid) const
300 {
301  NS_LOG_FUNCTION (this << uid);
302  struct IidInformation *information = LookupInformation (uid);
303  return information->name;
304 }
306 IidManager::GetHash (uint16_t uid) const
307 {
308  NS_LOG_FUNCTION (this << uid);
309  struct IidInformation *information = LookupInformation (uid);
310  return information->hash;
311 }
312 uint16_t
313 IidManager::GetParent (uint16_t uid) const
314 {
315  NS_LOG_FUNCTION (this << uid);
316  struct IidInformation *information = LookupInformation (uid);
317  return information->parent;
318 }
319 std::string
320 IidManager::GetGroupName (uint16_t uid) const
321 {
322  NS_LOG_FUNCTION (this << uid);
323  struct IidInformation *information = LookupInformation (uid);
324  return information->groupName;
325 }
326 
328 IidManager::GetConstructor (uint16_t uid) const
329 {
330  NS_LOG_FUNCTION (this << uid);
331  struct IidInformation *information = LookupInformation (uid);
332  if (!information->hasConstructor)
333  {
334  NS_FATAL_ERROR ("Requested constructor for "<<information->name<<" but it does not have one.");
335  }
336  return information->constructor;
337 }
338 
339 bool
340 IidManager::HasConstructor (uint16_t uid) const
341 {
342  NS_LOG_FUNCTION (this << uid);
343  struct IidInformation *information = LookupInformation (uid);
344  return information->hasConstructor;
345 }
346 
347 uint32_t
349 {
350  NS_LOG_FUNCTION (this);
351  return m_information.size ();
352 }
353 uint16_t
354 IidManager::GetRegistered (uint32_t i) const
355 {
356  NS_LOG_FUNCTION (this << i);
357  return i + 1;
358 }
359 
360 bool
362  std::string name)
363 {
364  NS_LOG_FUNCTION (this << uid << name);
365  struct IidInformation *information = LookupInformation (uid);
366  while (true)
367  {
368  for (std::vector<struct TypeId::AttributeInformation>::const_iterator i = information->attributes.begin ();
369  i != information->attributes.end (); ++i)
370  {
371  if (i->name == name)
372  {
373  return true;
374  }
375  }
376  struct IidInformation *parent = LookupInformation (information->parent);
377  if (parent == information)
378  {
379  // top of inheritance tree
380  return false;
381  }
382  // check parent
383  information = parent;
384  }
385  return false;
386 }
387 
388 void
390  std::string name,
391  std::string help,
392  uint32_t flags,
393  Ptr<const AttributeValue> initialValue,
396 {
397  NS_LOG_FUNCTION (this << uid << name << help << flags << initialValue << accessor << checker);
398  struct IidInformation *information = LookupInformation (uid);
399  if (HasAttribute (uid, name))
400  {
401  NS_FATAL_ERROR ("Attribute \"" << name << "\" already registered on tid=\"" <<
402  information->name << "\"");
403  }
404  struct TypeId::AttributeInformation info;
405  info.name = name;
406  info.help = help;
407  info.flags = flags;
408  info.initialValue = initialValue;
409  info.originalInitialValue = initialValue;
410  info.accessor = accessor;
411  info.checker = checker;
412  information->attributes.push_back (info);
413 }
414 void
416  uint32_t i,
417  Ptr<const AttributeValue> initialValue)
418 {
419  NS_LOG_FUNCTION (this << uid << i << initialValue);
420  struct IidInformation *information = LookupInformation (uid);
421  NS_ASSERT (i < information->attributes.size ());
422  information->attributes[i].initialValue = initialValue;
423 }
424 
425 
426 
427 uint32_t
428 IidManager::GetAttributeN (uint16_t uid) const
429 {
430  NS_LOG_FUNCTION (this << uid);
431  struct IidInformation *information = LookupInformation (uid);
432  return information->attributes.size ();
433 }
435 IidManager::GetAttribute(uint16_t uid, uint32_t i) const
436 {
437  NS_LOG_FUNCTION (this << uid << i);
438  struct IidInformation *information = LookupInformation (uid);
439  NS_ASSERT (i < information->attributes.size ());
440  return information->attributes[i];
441 }
442 
443 bool
445  std::string name)
446 {
447  NS_LOG_FUNCTION (this << uid << name);
448  struct IidInformation *information = LookupInformation (uid);
449  while (true)
450  {
451  for (std::vector<struct TypeId::TraceSourceInformation>::const_iterator i = information->traceSources.begin ();
452  i != information->traceSources.end (); ++i)
453  {
454  if (i->name == name)
455  {
456  return true;
457  }
458  }
459  struct IidInformation *parent = LookupInformation (information->parent);
460  if (parent == information)
461  {
462  // top of inheritance tree
463  return false;
464  }
465  // check parent
466  information = parent;
467  }
468  return false;
469 }
470 
471 void
473  std::string name,
474  std::string help,
476 {
477  NS_LOG_FUNCTION (this << uid << name << help << accessor);
478  struct IidInformation *information = LookupInformation (uid);
479  if (HasTraceSource (uid, name))
480  {
481  NS_FATAL_ERROR ("Trace source \"" << name << "\" already registered on tid=\"" <<
482  information->name << "\"");
483  }
484  struct TypeId::TraceSourceInformation source;
485  source.name = name;
486  source.help = help;
487  source.accessor = accessor;
488  information->traceSources.push_back (source);
489 }
490 uint32_t
491 IidManager::GetTraceSourceN (uint16_t uid) const
492 {
493  NS_LOG_FUNCTION (this << uid);
494  struct IidInformation *information = LookupInformation (uid);
495  return information->traceSources.size ();
496 }
498 IidManager::GetTraceSource(uint16_t uid, uint32_t i) const
499 {
500  NS_LOG_FUNCTION (this << uid << i);
501  struct IidInformation *information = LookupInformation (uid);
502  NS_ASSERT (i < information->traceSources.size ());
503  return information->traceSources[i];
504 }
505 bool
507 {
508  NS_LOG_FUNCTION (this << uid);
509  struct IidInformation *information = LookupInformation (uid);
510  return information->mustHideFromDocumentation;
511 }
512 
513 } // namespace ns3
514 
515 namespace ns3 {
516 
517 /*********************************************************************
518  * The TypeId class
519  *********************************************************************/
520 
521 TypeId::TypeId (const char *name)
522 {
523  NS_LOG_FUNCTION (this << name);
524  uint16_t uid = Singleton<IidManager>::Get ()->AllocateUid (name);
525  NS_ASSERT (uid != 0);
526  m_tid = uid;
527 }
528 
529 
530 TypeId::TypeId (uint16_t tid)
531  : m_tid (tid)
532 {
533  NS_LOG_FUNCTION (this << tid);
534 }
535 TypeId
536 TypeId::LookupByName (std::string name)
537 {
538  NS_LOG_FUNCTION (name);
539  uint16_t uid = Singleton<IidManager>::Get ()->GetUid (name);
540  NS_ASSERT_MSG (uid != 0, "Assert in TypeId::LookupByName: " << name << " not found");
541  return TypeId (uid);
542 }
543 bool
544 TypeId::LookupByNameFailSafe (std::string name, TypeId *tid)
545 {
546  NS_LOG_FUNCTION (name << tid);
547  uint16_t uid = Singleton<IidManager>::Get ()->GetUid (name);
548  if (uid == 0)
549  {
550  return false;
551  }
552  *tid = TypeId (uid);
553  return true;
554 }
555 TypeId
557 {
558  uint16_t uid = Singleton<IidManager>::Get ()->GetUid (hash);
559  NS_ASSERT_MSG (uid != 0, "Assert in TypeId::LookupByHash: 0x"
560  << std::hex << hash << std::dec << " not found");
561  return TypeId (uid);
562 }
563 bool
565 {
566  uint16_t uid = Singleton<IidManager>::Get ()->GetUid (hash);
567  if (uid == 0)
568  {
569  return false;
570  }
571  *tid = TypeId (uid);
572  return true;
573 }
574 
575 uint32_t
577 {
579  return Singleton<IidManager>::Get ()->GetRegisteredN ();
580 }
581 TypeId
583 {
584  NS_LOG_FUNCTION (i);
586 }
587 
588 bool
589 TypeId::LookupAttributeByName (std::string name, struct TypeId::AttributeInformation *info) const
590 {
591  NS_LOG_FUNCTION (this << name << info);
592  TypeId tid;
593  TypeId nextTid = *this;
594  do {
595  tid = nextTid;
596  for (uint32_t i = 0; i < tid.GetAttributeN (); i++)
597  {
598  struct TypeId::AttributeInformation tmp = tid.GetAttribute(i);
599  if (tmp.name == name)
600  {
601  *info = tmp;
602  return true;
603  }
604  }
605  nextTid = tid.GetParent ();
606  } while (nextTid != tid);
607  return false;
608 }
609 
610 TypeId
612 {
613  NS_LOG_FUNCTION (this << tid);
614  Singleton<IidManager>::Get ()->SetParent (m_tid, tid.m_tid);
615  return *this;
616 }
617 TypeId
618 TypeId::SetGroupName (std::string groupName)
619 {
620  NS_LOG_FUNCTION (this << groupName);
621  Singleton<IidManager>::Get ()->SetGroupName (m_tid, groupName);
622  return *this;
623 }
624 TypeId
625 TypeId::GetParent (void) const
626 {
627  NS_LOG_FUNCTION (this);
628  uint16_t parent = Singleton<IidManager>::Get ()->GetParent (m_tid);
629  return TypeId (parent);
630 }
631 bool
632 TypeId::HasParent (void) const
633 {
634  NS_LOG_FUNCTION (this);
635  uint16_t parent = Singleton<IidManager>::Get ()->GetParent (m_tid);
636  return parent != m_tid;
637 }
638 bool
640 {
641  NS_LOG_FUNCTION (this << other);
642  TypeId tmp = *this;
643  while (tmp != other && tmp != tmp.GetParent ())
644  {
645  tmp = tmp.GetParent ();
646  }
647  return tmp == other && *this != other;
648 }
649 std::string
651 {
652  NS_LOG_FUNCTION (this);
653  std::string groupName = Singleton<IidManager>::Get ()->GetGroupName (m_tid);
654  return groupName;
655 }
656 
657 std::string
658 TypeId::GetName (void) const
659 {
660  NS_LOG_FUNCTION (this);
661  std::string name = Singleton<IidManager>::Get ()->GetName (m_tid);
662  return name;
663 }
664 
666 TypeId::GetHash (void) const
667 {
668  hash_t hash = Singleton<IidManager>::Get ()->GetHash (m_tid);
669  return hash;
670 }
671 
672 bool
674 {
675  NS_LOG_FUNCTION (this);
676  bool hasConstructor = Singleton<IidManager>::Get ()->HasConstructor (m_tid);
677  return hasConstructor;
678 }
679 
680 void
682 {
683  NS_LOG_FUNCTION (this << &cb);
684  Singleton<IidManager>::Get ()->AddConstructor (m_tid, cb);
685 }
686 
687 TypeId
688 TypeId::AddAttribute (std::string name,
689  std::string help,
690  const AttributeValue &initialValue,
693 {
694  NS_LOG_FUNCTION (this << name << help << &initialValue << accessor << checker);
695  Singleton<IidManager>::Get ()->AddAttribute (m_tid, name, help, ATTR_SGC, initialValue.Copy (), accessor, checker);
696  return *this;
697 }
698 
699 TypeId
700 TypeId::AddAttribute (std::string name,
701  std::string help,
702  uint32_t flags,
703  const AttributeValue &initialValue,
706 {
707  NS_LOG_FUNCTION (this << name << help << flags << &initialValue << accessor << checker);
708  Singleton<IidManager>::Get ()->AddAttribute (m_tid, name, help, flags, initialValue.Copy (), accessor, checker);
709  return *this;
710 }
711 
712 bool
714  Ptr<const AttributeValue> initialValue)
715 {
716  NS_LOG_FUNCTION (this << i << initialValue);
717  Singleton<IidManager>::Get ()->SetAttributeInitialValue (m_tid, i, initialValue);
718  return true;
719 }
720 
721 
724 {
725  NS_LOG_FUNCTION (this);
726  Callback<ObjectBase *> cb = Singleton<IidManager>::Get ()->GetConstructor (m_tid);
727  return cb;
728 }
729 
730 bool
732 {
733  NS_LOG_FUNCTION (this);
734  bool mustHide = Singleton<IidManager>::Get ()->MustHideFromDocumentation (m_tid);
735  return mustHide;
736 }
737 
738 uint32_t
740 {
741  NS_LOG_FUNCTION (this);
742  uint32_t n = Singleton<IidManager>::Get ()->GetAttributeN (m_tid);
743  return n;
744 }
746 TypeId::GetAttribute(uint32_t i) const
747 {
748  NS_LOG_FUNCTION (this << i);
749  return Singleton<IidManager>::Get ()->GetAttribute(m_tid, i);
750 }
751 std::string
753 {
754  NS_LOG_FUNCTION (this << i);
756  return GetName () + "::" + info.name;
757 }
758 
759 uint32_t
761 {
762  NS_LOG_FUNCTION (this);
763  return Singleton<IidManager>::Get ()->GetTraceSourceN (m_tid);
764 }
766 TypeId::GetTraceSource(uint32_t i) const
767 {
768  NS_LOG_FUNCTION (this << i);
769  return Singleton<IidManager>::Get ()->GetTraceSource(m_tid, i);
770 }
771 
772 TypeId
773 TypeId::AddTraceSource (std::string name,
774  std::string help,
776 {
777  NS_LOG_FUNCTION (this << name << help << accessor);
778  Singleton<IidManager>::Get ()->AddTraceSource (m_tid, name, help, accessor);
779  return *this;
780 }
781 
782 TypeId
784 {
785  NS_LOG_FUNCTION (this);
786  Singleton<IidManager>::Get ()->HideFromDocumentation (m_tid);
787  return *this;
788 }
789 
790 
792 TypeId::LookupTraceSourceByName (std::string name) const
793 {
794  NS_LOG_FUNCTION (this << name);
795  TypeId tid;
796  TypeId nextTid = *this;
797  do {
798  tid = nextTid;
799  for (uint32_t i = 0; i < tid.GetTraceSourceN (); i++)
800  {
801  struct TypeId::TraceSourceInformation info = tid.GetTraceSource (i);
802  if (info.name == name)
803  {
804  return info.accessor;
805  }
806  }
807  nextTid = tid.GetParent ();
808  } while (nextTid != tid);
809  return 0;
810 }
811 
812 uint16_t
813 TypeId::GetUid (void) const
814 {
815  NS_LOG_FUNCTION (this);
816  return m_tid;
817 }
818 void
819 TypeId::SetUid (uint16_t tid)
820 {
821  NS_LOG_FUNCTION (this << tid);
822  m_tid = tid;
823 }
824 
825 std::ostream & operator << (std::ostream &os, TypeId tid)
826 {
827  os << tid.GetName ();
828  return os;
829 }
830 std::istream & operator >> (std::istream &is, TypeId &tid)
831 {
832  std::string tidString;
833  is >> tidString;
834  bool ok = TypeId::LookupByNameFailSafe (tidString, &tid);
835  if (!ok)
836  {
837  is.setstate (std::ios_base::badbit);
838  }
839  return is;
840 }
841 
842 
843 ATTRIBUTE_HELPER_CPP (TypeId);
844 
846 {
847  return a.m_tid < b.m_tid;
848 }
849 
850 } // namespace ns3
std::vector< struct TypeId::TraceSourceInformation > traceSources
Definition: type-id.cc:124
uint32_t GetAttributeN(void) const
Definition: type-id.cc:739
static TypeId::hash_t Hasher(const std::string name)
Definition: type-id.cc:151
uint32_t hash_t
Type of hash values.
Definition: type-id.h:79
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:49
bool HasAttribute(uint16_t uid, std::string name)
Definition: type-id.cc:361
Callback< ObjectBase * > GetConstructor(uint16_t uid) const
Definition: type-id.cc:328
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Callback template class.
Definition: callback.h:920
bool HasTraceSource(uint16_t uid, std::string name)
Definition: type-id.cc:444
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
TypeId SetParent(void)
Definition: type-id.h:411
std::vector< struct IidInformation > m_information
Definition: type-id.cc:130
std::string GetGroupName(uint16_t uid) const
Definition: type-id.cc:320
static TypeId LookupByHash(hash_t hash)
Definition: type-id.cc:556
hashmap_t m_hashmap
Definition: type-id.cc:136
namemap_t m_namemap
Definition: type-id.cc:133
std::map< TypeId::hash_t, uint16_t > hashmap_t
Definition: type-id.cc:135
Hold a value for an Attribute.
Definition: attribute.h:56
Ptr< const AttributeValue > originalInitialValue
Definition: type-id.h:65
Ptr< const TraceSourceAccessor > accessor
Definition: type-id.h:73
void SetGroupName(uint16_t uid, std::string groupName)
Definition: type-id.cc:244
#define NS_ASSERT(condition)
Definition: assert.h:64
TypeId GetParent(void) const
Definition: type-id.cc:625
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Definition: type-id.cc:544
bool operator<(const Room &a, const Room &b)
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition: log.h:309
uint32_t GetRegisteredN(void) const
Definition: type-id.cc:348
The attribute can be read, and written at any time.
Definition: type-id.h:59
static T * Get(void)
Definition: singleton.h:50
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
Callback< ObjectBase * > GetConstructor(void) const
Definition: type-id.cc:723
static bool LookupByHashFailSafe(hash_t hash, TypeId *tid)
Definition: type-id.cc:564
bool HasConstructor(void) const
Definition: type-id.cc:673
bool MustHideFromDocumentation(void) const
Definition: type-id.cc:731
a template singleton
Definition: singleton.h:37
TypeId information manager.
Definition: type-id.cc:71
Ptr< const AttributeAccessor > accessor
Definition: type-id.h:67
static uint32_t GetRegisteredN(void)
Definition: type-id.cc:576
Ptr< const TraceSourceAccessor > LookupTraceSourceByName(std::string name) const
Definition: type-id.cc:792
uint32_t GetAttributeN(uint16_t uid) const
Definition: type-id.cc:428
Ptr< const AttributeValue > initialValue
Definition: type-id.h:66
uint16_t m_tid
Definition: type-id.h:359
bool HasParent(void) const
Definition: type-id.cc:632
uint32_t GetHash32(const char *buffer, const size_t size)
Compute 32-bit hash of a byte buffer.
Definition: hash.h:219
uint32_t GetTraceSourceN(void) const
Definition: type-id.cc:760
static TypeId GetRegistered(uint32_t i)
Definition: type-id.cc:582
uint32_t GetTraceSourceN(uint16_t uid) const
Definition: type-id.cc:491
void AddAttribute(uint16_t uid, std::string name, std::string help, uint32_t flags, Ptr< const AttributeValue > initialValue, Ptr< const AttributeAccessor > spec, Ptr< const AttributeChecker > checker)
Definition: type-id.cc:389
void SetAttributeInitialValue(uint16_t uid, uint32_t i, Ptr< const AttributeValue > initialValue)
Definition: type-id.cc:415
std::vector< struct TypeId::AttributeInformation > attributes
Definition: type-id.cc:123
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
void HideFromDocumentation(uint16_t uid)
Definition: type-id.cc:251
bool MustHideFromDocumentation(uint16_t uid) const
Definition: type-id.cc:506
TypeId SetGroupName(std::string groupName)
Definition: type-id.cc:618
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:43
TypeId AddAttribute(std::string name, std::string help, const AttributeValue &initialValue, Ptr< const AttributeAccessor > accessor, Ptr< const AttributeChecker > checker)
Definition: type-id.cc:688
Ptr< const AttributeChecker > checker
Definition: type-id.h:68
virtual Ptr< AttributeValue > Copy(void) const =0
Hasher & clear(void)
Restore initial state.
Definition: hash.cc:43
void SetUid(uint16_t tid)
Definition: type-id.cc:819
bool LookupAttributeByName(std::string name, struct AttributeInformation *info) const
Definition: type-id.cc:589
std::map< std::string, uint16_t > namemap_t
Definition: type-id.cc:132
uint16_t GetRegistered(uint32_t i) const
Definition: type-id.cc:354
std::string GetName(void) const
Definition: type-id.cc:658
uint16_t GetUid(void) const
Definition: type-id.cc:813
void DoAddConstructor(Callback< ObjectBase * > callback)
Definition: type-id.cc:681
hash_t GetHash(void) const
Definition: type-id.cc:666
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
bool SetAttributeInitialValue(uint32_t i, Ptr< const AttributeValue > initialValue)
Definition: type-id.cc:713
TypeId AddTraceSource(std::string name, std::string help, Ptr< const TraceSourceAccessor > accessor)
Definition: type-id.cc:773
uint16_t AllocateUid(std::string name)
Definition: type-id.cc:158
void SetParent(uint16_t uid, uint16_t parent)
Definition: type-id.cc:236
uint16_t GetParent(uint16_t uid) const
Definition: type-id.cc:313
std::string GetName(uint16_t uid) const
Definition: type-id.cc:299
TypeId::hash_t GetHash(uint16_t uid) const
Definition: type-id.cc:306
std::string GetAttributeFullName(uint32_t i) const
Definition: type-id.cc:752
bool HasConstructor(uint16_t uid) const
Definition: type-id.cc:340
bool IsChildOf(TypeId other) const
Definition: type-id.cc:639
#define NS_LOG_ERROR(msg)
Definition: log.h:271
void AddTraceSource(uint16_t uid, std::string name, std::string help, Ptr< const TraceSourceAccessor > accessor)
Definition: type-id.cc:472
Callback< ObjectBase * > constructor
Definition: type-id.cc:121
struct TypeId::TraceSourceInformation GetTraceSource(uint32_t i) const
Definition: type-id.cc:766
std::string GetGroupName(void) const
Definition: type-id.cc:650
ATTRIBUTE_HELPER_CPP(ObjectFactory)
struct IidManager::IidInformation * LookupInformation(uint16_t uid) const
Definition: type-id.cc:228
struct TypeId::AttributeInformation GetAttribute(uint32_t i) const
Definition: type-id.cc:746
void AddConstructor(uint16_t uid, Callback< ObjectBase * > callback)
Definition: type-id.cc:259
a unique identifier for an interface.
Definition: type-id.h:49
std::vector< struct IidInformation >::const_iterator Iterator
Definition: type-id.cc:126
Generic Hash function interface.
Definition: hash.h:76
TypeId HideFromDocumentation(void)
Definition: type-id.cc:783
static TypeId LookupByName(std::string name)
Definition: type-id.cc:536
uint16_t GetUid(std::string name) const
Definition: type-id.cc:272