//
//	Copyright © 2005 Nemetschek North America 
//	All Rights Reserved.
//
// Created by Vladislav Stanev

#pragma once


namespace VWFC
{
	namespace Tools
	{
		class CTimingResultsDialog;
		// ---------------------------------------------------------------------------
		class VWTiming
		{
			friend class CTimingResultsDialog;
		protected:
			VWTiming();
			~VWTiming();

		public:
			static VWTiming*	GetInstance();

		public:
			static void			Initialize();
			static void			Deinitilalize();
			void				Start(const TXString& category, const TXString& context);
			void				End(const TXString& taskInfo);
			void				End(const TXString& taskInfo, size_t data1, const TXString& str1);
			void				End(const TXString& taskInfo, size_t data1, const TXString& str1, size_t data2, const TXString& str2);
			void				End(const TXString& taskInfo, size_t data1, const TXString& str1, size_t data2, const TXString& str2, size_t data3, const TXString& str3);
			void				ShowTimingResultDialog(const TXString& description);

		protected:
			// -----------------------------
			struct STimerStart {
				UInt32			startTime;
				TXString		category;
				TXString		context;
				STimerStart();
				~STimerStart();
			};
			typedef std::vector<STimerStart>		TTimersQueue;

			// -----------------------------
			struct SData {
				size_t			data;
				TXString		desc;
				SData();
				SData(size_t dt, const TXString& txt);
				~SData();
			};
			typedef std::vector<SData>				TDataArray;

			// -----------------------------
			struct STimerCollected {
				UInt32			timeEllapsed;
				TXString		context;
				TXString		taskInfo;
				TDataArray		arrData;
				STimerCollected();
				~STimerCollected();
			};
			typedef std::vector<STimerCollected>	TTimerCollectedArray;

			// -----------------------------
			struct STimerCategory {
				TXString				category;
				TTimerCollectedArray	arrTimerData;
				STimerCategory();
				~STimerCategory();
			};
			typedef std::vector<STimerCategory>		TTimerCategoriesArray;

		protected:
			UInt32				GetTimer();
			void				End(const TXString& taskInfo, STimerCollected& collected);

		private:
			static VWTiming*		spInstance;
			TTimersQueue			fTimerStartQueue;
			TTimerCategoriesArray	fTimerCategories;
		};
	}
}
