
#pragma once
#ifndef ABLPROFILER_HPP
#define ABLPROFILER_HPP

#pragma warning (push)
#include <stlport\map>
#include <stlport\string>
#pragma warning (pop)



namespace ABL
{
	class Profiler
	{
	  public:
		Profiler();
		~Profiler();

		void SetActive(bool active);
		bool GetActive() const;

		void NotifyFunctionCalled(double time,
								  const char* function_name,
								  const char* module_name);

		static Profiler* Instance();

	  private:
		struct CallInfo
		{
		    CallInfo();
			double total_time;
			int total_calls;
		};

		bool m_Active;

		typedef std::map<std::string,CallInfo> call_info_map;

		call_info_map m_PerFunctionTiming;
		call_info_map m_PerModuleTiming;

		void AddTimeToCallInfoMap(double time, const char* name, call_info_map& m);
		void UpdateCallInfoMap(call_info_map& m);
		void SpewIt() const;

		static Profiler* m_Instance;
	};
};


#endif // ABLPROFILER_HPP