/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2013 Raytrix GmbH. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "Guid.h"

#ifndef RX_STATIC
    #ifdef RXINTEROP30_EXPORTS
		#define RXINTEROP30_API __declspec(dllexport)
    #else
		#define RXINTEROP30_API __declspec(dllimport)
    #endif
#else
	#define RXINTEROP30_API
#endif

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// namespace: Rx.Interop.Runtime30
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace Rx
{
	namespace Interop
	{
		namespace Runtime30
		{
			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			/// <summary>
			/// 	Interface for basic exception.
			/// </summary>
			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			class RXINTEROP30_API CIException
			{
			public:

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Default constructor.
				/// </summary>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				CIException();

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	copy Constructor.
				/// </summary>
				///
				/// <param name="xEx">	[in] The exception to copy. </param>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				CIException(Interop::Runtime30::CIException& xEx);

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Destructor.
				/// </summary>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual ~CIException();

			public:

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Convert this CRxExceptionEx into a string representation.
				/// </summary>
				///
				/// <returns>	This CRxExceptionEx as a string. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual const char* ToString() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the information string.
				/// </summary>
				///
				/// <returns>	The information string. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual const char* GetMessageText() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the function name.
				/// </summary>
				///
				/// <returns>	The function name. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual const char* GetFunction() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the file name.
				/// </summary>
				///
				/// <returns>	The file name. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual const char* GetFile() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the line.
				/// </summary>
				///
				/// <returns>	The line number. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual unsigned GetLine() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the name of this exception.
				/// </summary>
				///
				/// <returns>	The name of this exception. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual const char* GetName() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the unique identifier of the type of this exception.
				/// </summary>
				///
				/// <returns>	The type unique identifier. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual const Interop::Runtime30::CGuid& GetGUID() const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Query if this exception or one of its inner exceptions has the given GUID.
				/// </summary>
				///
				/// <param name="xGUID">	[in] The GUID of the exception to look for. </param>
				///
				/// <returns>	True if this exception or one of its inner exceptions has the given GUID, false if not. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual bool HasException(const Interop::Runtime30::CGuid& xGUID) const = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Gets the inner exception.
				/// </summary>
				///
				/// <returns>	Null if there is no inner exception, else the inner exception. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				CIException* GetInnerException() const;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Copy this exception to given target Destination.
				/// </summary>
				///
				/// <param name="ppTarget">	[in,out] If non-null, target for the. </param>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				void CopyToHeap(CIException** ppTarget);

			protected:

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Copies this exception. This has to be implemented in each exception type.
				/// </summary>
				///
				/// <returns>	A copy of this exception. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				virtual CIException* Copy() = 0;

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Returns the inner exception and yields responsibility.
				/// </summary>
				///
				/// <returns>	The inner exception. </returns>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				CIException* YieldInnerException();

				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				/// <summary>
				/// 	Sets an inner exception. Frees currently assigned inner exception.
				/// </summary>
				///
				/// <param name="xEx">	[in] The inner exception. </param>
				/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
				void SetInnerException(CIException& xEx);

			private:

				/// <summary>	The inner exception. </summary>
				Interop::Runtime30::CIException* m_pxInnerException;
			};
		}
	}

	/// <summary> Defines an alias representing the exception interface of RxRuntime 3.0. </summary>
	typedef Interop::Runtime30::CIException IException30;
}

#pragma make_public(Rx::Interop::Runtime30::CIException)
