/*
	Debug Console.
	Copyright (c) 2008, Darragh Coy.
	All rights reserved.
	Author(s) details available at: http://www.darraghcoy.com

	Redistribution and use in binary form is permitted 
	provided that the following conditions are met:

		* 	Redistributions in binary form must reproduce the above copyright notice, this list of 
			conditions and the following disclaimer in the documentation.
		* 	Neither the name of the author nor the names of contributors may be used to endorse or 
			promote products derived from this software without specific prior written permission.
                        
	THIS SOFTWARE IS PROVIDED BY DARRAGH COY ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
	BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
	ARE DISCLAIMED. IN NO EVENT SHALL DARRAGH COY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
	OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
	OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
	IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef DEBUG_CONSOLE_H
#define DEBUG_CONSOLE_H

// Type for a DLL Function

#define DLL_FUNCTION __declspec( dllexport )

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   DebugConsole
// Purpose:      Contains the definitions for the functions in the DebugConsole.
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class DebugConsole
{
	public:

		//---------------------------------------------------------------------
		// Functions
		//---------------------------------------------------------------------

			 static DLL_FUNCTION void			Create( const char * title = "Debug Console" );		///< Creates the console
			 static DLL_FUNCTION void			Shutdown();											///< Shuts down the console
			 static DLL_FUNCTION void			RunPendingCommands();								///< Runs any pending commands. Has to be called for commands to take effect.
			 static DLL_FUNCTION void			SetLoggingEnabled( bool enabled );					///< Sets if logging is enabled. Will immediately open the current log file if enabling
			 static DLL_FUNCTION bool			GetLoggingEnabled();								///< Tells if logging is enabled.
			 static DLL_FUNCTION void			SetLogFileName( const char * name );				///< Sets the name of the current log file. If logging is enabled and a log file is open, then it will be closed and the new file will open.
			 static DLL_FUNCTION void			GetLogFileName( char * name , int name_len );		///< Gets the name of the current log file and saves it to the buffer with the given length
			 static DLL_FUNCTION void			RunCommand( const char * command );					///< Runs a given command.
			 static DLL_FUNCTION void			BeginProfile( const char * name );					///< Begins profiling a named block of code
			 static DLL_FUNCTION void			EndProfile( const char * name );					///< Ends profiling a named block of code
			 static DLL_FUNCTION void			Print( const char * text );							///< Print to console
			 static DLL_FUNCTION void			Print( int num );									///< Print to console
			 static DLL_FUNCTION void			Print( bool boolean );								///< Print to console
			 static DLL_FUNCTION void			Print( float num );									///< Print to console
			 static DLL_FUNCTION void			PrintTitle( const char * text );					///< Print a title to the console with decorations
			 static DLL_FUNCTION void			Clear();											///< Clear console
			 static DLL_FUNCTION void			SetPosition( int x , int y );						///< Set position
			 static DLL_FUNCTION void			SetSize( int x , int y );							///< Set size
			 static DLL_FUNCTION int			HasFocus();											///< Tell if console has focus	
			 static DLL_FUNCTION int			Exists();											///< Does console window exist ?
			 static DLL_FUNCTION void			SetWindowTitle( const char * title );				///< Set the window title

			///< Remove a given command

			 static DLL_FUNCTION void RemoveCommand( const char * name );

			// Add commands: read only

			 static DLL_FUNCTION void AddCommand( const char * name , void			( * func )( void	) );
			 static DLL_FUNCTION void AddCommand( const char * name , int			( * func )( void	) );
			 static DLL_FUNCTION void AddCommand( const char * name , bool			( * func )( void	) );
			 static DLL_FUNCTION void AddCommand( const char * name , float			( * func )( void	) );
			 static DLL_FUNCTION void AddCommand( const char * name , const char *	( * func )( void	) );

			// Add commands: write only

			 static DLL_FUNCTION void AddCommand( const char * name , void ( * func )( int arg				) );
			 static DLL_FUNCTION void AddCommand( const char * name , void ( * func )( bool arg				) );
			 static DLL_FUNCTION void AddCommand( const char * name , void ( * func )( float arg			) );
			 static DLL_FUNCTION void AddCommand( const char * name , void ( * func )( const char * arg		) );

			// Add commands: read or write. argument may not be given (except in case of string) , hence the extra bool. must always return value however!

			 static DLL_FUNCTION void AddCommand( const char * name , int			( * func )( int arg				, bool argGiven ) );
			 static DLL_FUNCTION void AddCommand( const char * name , bool			( * func )( bool arg			, bool argGiven ) );
			 static DLL_FUNCTION void AddCommand( const char * name , float			( * func )( float arg			, bool argGiven ) );
			 static DLL_FUNCTION void AddCommand( const char * name , const char *	( * func )( const char * arg					) );
};

#endif