AkGuid.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*******************************************************************************
  2. The content of this file includes portions of the AUDIOKINETIC Wwise Technology
  3. released in source code form as part of the SDK installer package.
  4. Commercial License Usage
  5. Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
  6. may use this file in accordance with the end user license agreement provided
  7. with the software or, alternatively, in accordance with the terms contained in a
  8. written agreement between you and Audiokinetic Inc.
  9. Apache License Usage
  10. Alternatively, this file may be used under the Apache License, Version 2.0 (the
  11. "Apache License"); you may not use this file except in compliance with the
  12. Apache License. You may obtain a copy of the Apache License at
  13. http://www.apache.org/licenses/LICENSE-2.0.
  14. Unless required by applicable law or agreed to in writing, software distributed
  15. under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  16. OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
  17. the specific language governing permissions and limitations under the License.
  18. Copyright (c) 2023 Audiokinetic Inc.
  19. *******************************************************************************/
  20. #pragma once
  21. #include <stdint.h>
  22. #include <string>
  23. namespace AK
  24. {
  25. namespace WwiseAuthoringAPI
  26. {
  27. #define AkGuidIsEqual(rguid1, rguid2) ( \
  28. ((uint32_t*) rguid1)[0] == ((uint32_t*) rguid2)[0] && \
  29. ((uint32_t*) rguid1)[1] == ((uint32_t*) rguid2)[1] && \
  30. ((uint32_t*) rguid1)[2] == ((uint32_t*) rguid2)[2] && \
  31. ((uint32_t*) rguid1)[3] == ((uint32_t*) rguid2)[3] )
  32. struct AkGuid
  33. {
  34. AkGuid() = default;
  35. AkGuid( const AkGuid& other )
  36. {
  37. memcpy( this, &other, sizeof other );
  38. }
  39. #ifdef GUID_DEFINED
  40. AkGuid( const GUID& guid )
  41. {
  42. *this = guid;
  43. }
  44. inline AkGuid& operator=(const GUID& other)
  45. {
  46. return *this = * reinterpret_cast<const AkGuid*>( &other );
  47. }
  48. inline operator GUID() const
  49. {
  50. return *reinterpret_cast<const GUID*>(this);
  51. }
  52. inline bool operator==(const GUID& other) const
  53. {
  54. return AkGuidIsEqual(this, &other);
  55. }
  56. inline bool operator!=(const GUID& other) const
  57. {
  58. return !AkGuidIsEqual(this, &other);
  59. }
  60. #endif
  61. inline bool operator==(const AkGuid& other) const
  62. {
  63. return AkGuidIsEqual(this, &other);
  64. }
  65. inline bool operator!=(const AkGuid& other) const
  66. {
  67. return !AkGuidIsEqual(this, &other);
  68. }
  69. inline AkGuid& operator=(const AkGuid& other)
  70. {
  71. memcpy( this, &other, sizeof other );
  72. return *this;
  73. }
  74. inline bool IsNull() const
  75. {
  76. for (int i = 0; i < 8; ++i)
  77. {
  78. if (data4[i] != 0)
  79. {
  80. return false;
  81. }
  82. }
  83. return (data1 == 0 && data2 == 0 && data3 == 0);
  84. }
  85. inline AkGuid& Nullify()
  86. {
  87. memset(this, 0, sizeof(AkGuid));
  88. return *this;
  89. }
  90. uint32_t data1;
  91. uint16_t data2;
  92. uint16_t data3;
  93. uint8_t data4[8];
  94. };
  95. }
  96. }