/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2015 Raytrix GmbH. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "RxCore.h"
#include "RxString.h"

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// namespace: Rx
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace Rx
{
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>
	/// 	Holds information about a certain code location. These information are:
	///
	/// 	- The source code file name
	/// 	- The name of the function
	/// 	- The line in the source code file.
	/// </summary>
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	class RXCORE_API CCodeLocation
	{
	public:

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Default constructor.
		/// </summary>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		CCodeLocation()
			: m_iLine(0)
		{
		}

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Constructor.
		/// </summary>
		///
		/// <param name="pcFile">	  The source code file name. </param>
		/// <param name="pcFunction"> The name of the function. </param>
		/// <param name="iLine">	  The line in the source code file. </param>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		CCodeLocation(const char* pcFile, const char* pcFunction, int iLine)
			: m_sxFile(pcFile), m_sxFunction(pcFunction), m_iLine(iLine)
		{
		}

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Gets the source code file name.
		/// </summary>
		///
		/// <returns> The source code file name. </returns>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		const CRxString& GetFile() const
		{
			return m_sxFile;
		}

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Gets the name of the function.
		/// </summary>
		///
		/// <returns> The name of the function. </returns>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		const CRxString& GetFunction() const
		{
			return m_sxFunction;
		}

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Gets the line in the source code file.
		/// </summary>
		///
		/// <returns> The line in the source code file. </returns>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		const int& GetLine() const
		{
			return m_iLine;
		}

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Convert this CCodeLocation into a string representation.
		/// </summary>
		///
		/// <returns> This CCodeLocation as a CRxString. </returns>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		CRxString ToString() const
		{
			return m_sxFile + " - " + m_sxFunction + " [" + m_iLine + "]";
		}

	private:

		/// The source code file name
		CRxString m_sxFile;
		/// The name of the function
		CRxString m_sxFunction;
		/// The line in the source code file
		int m_iLine;
	};
}
