DbgTypeMap.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #pragma once
  2. #include "DebugCommon.h"
  3. #include "BeefySysLib/Util/BumpAllocator.h"
  4. #include "BeefySysLib/Util/HashSet.h"
  5. namespace Beefy
  6. {
  7. enum DbgLanguage : int8;
  8. }
  9. NS_BF_DBG_BEGIN
  10. class DbgType;
  11. /*class DbgTypeMap
  12. {
  13. public:
  14. static const int HashSize = 9973;
  15. Beefy::BumpAllocator mAlloc;
  16. struct Entry
  17. {
  18. DbgType* mValue;
  19. Entry* mNext;
  20. };
  21. struct Iterator
  22. {
  23. public:
  24. DbgTypeMap* mMap;
  25. Entry* mCurEntry;
  26. int mCurBucket;
  27. public:
  28. Iterator(DbgTypeMap* map);
  29. Iterator& operator++();
  30. bool operator!=(const Iterator& itr) const;
  31. Entry* operator*();
  32. };
  33. public:
  34. int GetHash(const char* str, Beefy::DbgLanguage language);
  35. bool StrEqual(const char* strA, const char* strB);
  36. public:
  37. Entry** mHashHeads;
  38. public:
  39. DbgTypeMap();
  40. bool IsEmpty();
  41. void Clear();
  42. void Insert(DbgType* value);
  43. Entry* Find(const char* name, Beefy::DbgLanguage language);
  44. Iterator begin();
  45. Iterator end();
  46. };*/
  47. class DbgTypeMap
  48. {
  49. public:
  50. struct Entry
  51. {
  52. DbgType* mValue;
  53. bool operator==(const Entry& rhs)
  54. {
  55. return mValue == rhs.mValue;
  56. }
  57. };
  58. public:
  59. Beefy::HashSet<Entry> mMap;
  60. public:
  61. static int GetHash(const char* str, Beefy::DbgLanguage language);
  62. static int GetHash(DbgType* dbgType);
  63. static bool StrEqual(const char* strA, const char* strB);
  64. bool IsEmpty();
  65. void Clear();
  66. void Insert(DbgType* value);
  67. Entry* Find(const char* name, Beefy::DbgLanguage language);
  68. Beefy::HashSet<Entry>::iterator begin();
  69. Beefy::HashSet<Entry>::iterator end();
  70. };
  71. NS_BF_DBG_END
  72. namespace std
  73. {
  74. template<>
  75. struct hash<NS_BF_DBG::DbgTypeMap::Entry>
  76. {
  77. size_t operator()(const NS_BF_DBG::DbgTypeMap::Entry& val) const
  78. {
  79. return NS_BF_DBG::DbgTypeMap::GetHash(val.mValue);
  80. }
  81. };
  82. }