daeErrorHandler.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2006 Sony Computer Entertainment Inc.
  3. *
  4. * Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
  5. * file except in compliance with the License. You may obtain a copy of the License at:
  6. * http://research.scea.com/scea_shared_source_license.html
  7. *
  8. * Unless required by applicable law or agreed to in writing, software distributed under the License
  9. * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied. See the License for the specific language governing permissions and limitations under the
  11. * License.
  12. */
  13. #ifndef _DAE_ERROR_HANDLER_
  14. #define _DAE_ERROR_HANDLER_
  15. #include <memory>
  16. #include <dae/daeTypes.h>
  17. /**
  18. * The @c daeErrorHandler class is a plugin that allows the use to overwrite how error and warning
  19. * messages get handled in the client application. An example of this would be a class that reports
  20. * the message to a gui front end instead of just printing on stdout.
  21. */
  22. class DLLSPEC daeErrorHandler {
  23. public:
  24. /**
  25. * Constructor.
  26. */
  27. daeErrorHandler();
  28. /**
  29. * Destructor.
  30. */
  31. virtual ~daeErrorHandler();
  32. /**
  33. * This function is called when there is an error and a string needs to be sent to the user.
  34. * You must overwrite this function in your plugin.
  35. * @param msg Error message.
  36. */
  37. virtual void handleError( daeString msg ) = 0;
  38. /**
  39. * This function is called when there is a warning and a string needs to be sent to the user.
  40. * You must overwrite this function in your plugin.
  41. * @param msg Warning message.
  42. */
  43. virtual void handleWarning( daeString msg ) = 0;
  44. /**
  45. * Sets the daeErrorHandler to the one specified.
  46. * @param eh The new daeErrorHandler to use. Passing in NULL results in the default plugin being used.
  47. */
  48. static void setErrorHandler( daeErrorHandler *eh );
  49. /**
  50. * Returns the current daeErrorHandlerPlugin. A program has one globally-accessible
  51. * daeErrorHandler active at a time.
  52. * @return The current daeErrorHandler.
  53. */
  54. static daeErrorHandler *get();
  55. private:
  56. static daeErrorHandler *_instance;
  57. static std::unique_ptr<daeErrorHandler> _defaultInstance;
  58. };
  59. #endif