Home | History | Annotate | Download | only in dae
      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 
      9 #ifndef _DAE_ERROR_HANDLER_
     10 #define _DAE_ERROR_HANDLER_
     11 
     12 #include <memory>
     13 #include <dae/daeTypes.h>
     14 
     15 /**
     16  * The @c daeErrorHandler class is a plugin that allows the use to overwrite how error and warning
     17  * messages get handled in the client application. An example of this would be a class that reports
     18  * the message to a gui front end instead of just printing on stdout.
     19  */
     20 class DLLSPEC daeErrorHandler {
     21 public:
     22 	/**
     23 	 * Constructor.
     24 	 */
     25 	daeErrorHandler();
     26 	/**
     27 	 * Destructor.
     28 	 */
     29 	virtual ~daeErrorHandler();
     30 
     31 	/**
     32 	 * This function is called when there is an error and a string needs to be sent to the user.
     33 	 * You must overwrite this function in your plugin.
     34 	 * @param msg Error message.
     35 	 */
     36 	virtual void handleError( daeString msg ) = 0;
     37 	/**
     38 	 * This function is called when there is a warning and a string needs to be sent to the user.
     39 	 * You must overwrite this function in your plugin.
     40 	 * @param msg Warning message.
     41 	 */
     42 	virtual void handleWarning( daeString msg ) = 0;
     43 
     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 
     56 private:
     57 	static daeErrorHandler *_instance;
     58 	static std::auto_ptr<daeErrorHandler> _defaultInstance;
     59 };
     60 
     61 #endif
     62