AkWwiseErrorHandler.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. Copyright (c) 2023 Audiokinetic Inc.
  10. *******************************************************************************/
  11. // MessageTranslator.h
  12. /// \file
  13. /// Contains the wwiseErrorHandler
  14. /// Has a static callback function that can recieved an error message from the sound engine.
  15. /// Has a translator used to translate the message coming from the sound engine.
  16. /// The translator can be a combination of multiple different type of translators. (See AddTranslator)
  17. /// The translated message is then send back to the sound engine through another callback function.
  18. #ifndef AK_OPTIMIZED
  19. #pragma once
  20. #include <AK/SoundEngine/Common/AkSoundEngine.h> // Sound engine
  21. #include <AK/SoundEngine/Common/AkSoundEngineExport.h>
  22. class AkErrorMessageTranslator;
  23. class AkDefaultErrorMessageTranslator;
  24. class AkWwiseErrorHandler
  25. {
  26. public:
  27. /// ErrorHandler class destructor.
  28. virtual ~AkWwiseErrorHandler() {};
  29. /**
  30. On initialization, a DefaultErrorMessageTranslator is created and affected to the m_currentMessageTranslator
  31. */
  32. static void Init();
  33. /**
  34. Set the m_currentMessageTranslator to the given translator.
  35. The added translator can either override previously added translator, or attach them to itself.
  36. In the case overridePreviousTranslator is true, the responsibility of deleting all the translator previously attached to
  37. the m_currentMessageTranslator will fall back to the class that created them.
  38. Also, the given translator can override all previous translator(s) except the DefaultErrorMessageTranslator, which will
  39. always be attached to the given translator.
  40. @param[in] in_errorMessageTranslator The new translator that should be used by the error handler
  41. @param[in] in_overridePreviousTranslator Whether or not the given translator should override previously set translator(s)
  42. */
  43. static void AddTranslator(AkErrorMessageTranslator* in_errorMessageTranslator, bool in_overridePreviousTranslator);
  44. /**
  45. Delete the DefaultMessageTranslator and sets the m_currentMessageTranslator pointer to nullptr
  46. */
  47. static void Release();
  48. ///Translate and then send back the translated message to the sound engine via it's m_funcLocalOutput
  49. static void Execute(
  50. AK::Monitor::ErrorCode in_eErrorCode, ///< Error code number value
  51. const AkOSChar* in_pszError, ///< Message or error string to be displayed
  52. AK::Monitor::ErrorLevel in_errorLevel, ///< The error level of the message
  53. AkPlayingID in_pID, ///< Related Playing ID if applicable, AK_INVALID_PLAYING_ID otherwise
  54. AkUInt64 in_gId, ///< Related Game Object ID if applicable, AK_INVALID_GAME_OBJECT otherwise
  55. AkUniqueID in_sId, ///< Related Sound ID if applicable, AK_INVALID__ID otherwise
  56. char* in_args, ///< Variable arguments to replace the wwise tags contained in the message or error string
  57. AkUInt32 in_uArgSize ///< Size of argument blob.
  58. );
  59. ///Sets the localoutputfunc
  60. static void SetLocalOutputFunc(AkUInt32 in_uErrorLevel, AK::Monitor::LocalOutputFunc in_pMonitorFunc) { m_uLocalOutputErrorLevel = in_uErrorLevel; m_funcLocalOutput = in_pMonitorFunc;};
  61. static AK::Monitor::LocalOutputFunc GetLocalOutputFunc() { return m_funcLocalOutput; }
  62. static AkUInt32 GetLocalOutputErrorLevel() { return m_uLocalOutputErrorLevel; }
  63. private:
  64. /// ErrorHandler class constructor.
  65. AkWwiseErrorHandler() {};
  66. static AK::Monitor::LocalOutputFunc m_funcLocalOutput;
  67. static AkUInt32 m_uLocalOutputErrorLevel;
  68. static AkDefaultErrorMessageTranslator m_defaultErrorMessageTranslator;
  69. static AkErrorMessageTranslator* m_currentMessageTranslator;
  70. };
  71. #endif // !AK_OPTIMIZED