daeErrorHandler.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2006 Sony Computer Entertainment Inc.
  3. *
  4. * Licensed under the MIT Open Source License, for details please see license.txt or the website
  5. * http://www.opensource.org/licenses/mit-license.php
  6. *
  7. */
  8. #ifndef _DAE_ERROR_HANDLER_
  9. #define _DAE_ERROR_HANDLER_
  10. #include <memory>
  11. #include <dae/daeTypes.h>
  12. /**
  13. * The @c daeErrorHandler class is a plugin that allows the use to overwrite how error and warning
  14. * messages get handled in the client application. An example of this would be a class that reports
  15. * the message to a gui front end instead of just printing on stdout.
  16. */
  17. class DLLSPEC daeErrorHandler {
  18. public:
  19. /**
  20. * Constructor.
  21. */
  22. daeErrorHandler();
  23. /**
  24. * Destructor.
  25. */
  26. virtual ~daeErrorHandler();
  27. /**
  28. * This function is called when there is an error and a string needs to be sent to the user.
  29. * You must overwrite this function in your plugin.
  30. * @param msg Error message.
  31. */
  32. virtual void handleError( daeString msg ) = 0;
  33. /**
  34. * This function is called when there is a warning and a string needs to be sent to the user.
  35. * You must overwrite this function in your plugin.
  36. * @param msg Warning message.
  37. */
  38. virtual void handleWarning( daeString msg ) = 0;
  39. /**
  40. * Sets the daeErrorHandler to the one specified.
  41. * @param eh The new daeErrorHandler to use. Passing in NULL results in the default plugin being used.
  42. */
  43. static void setErrorHandler( daeErrorHandler *eh );
  44. /**
  45. * Returns the current daeErrorHandlerPlugin. A program has one globally-accessible
  46. * daeErrorHandler active at a time.
  47. * @return The current daeErrorHandler.
  48. */
  49. static daeErrorHandler *get();
  50. private:
  51. static daeErrorHandler *_instance;
  52. static std::unique_ptr<daeErrorHandler> _defaultInstance;
  53. };
  54. #endif