#ifndef TDE_WIDGETS_UILOGGER_H
#define TDE_WIDGETS_UILOGGER_H

#include "common.h"
#include "opaque.h"

// -- TDE NAMESPACE ----------------------------------------------------

namespace TDE {

// -- Widgets NAMESPACE ------------------------------------------------

namespace Widgets {


class UILogger;

typedef SHARED_PTR<UILogger> UILoggerPtr;


// -- UILogger ---------------------------------------------------------

/*!
 * \class UILogger
 * \brief Monoid class that logs variable value changes obtained through widget interactions.
 *
 * \see WidgetInfo
 * \see Andrei Alexandrescu, "Modern C++ Design"
 */
class UILogger
{
public:
	~UILogger();

    static SHARED_PTR<UILogger> Instance();

	static bool Log(WidgetInfo& winfo, const std::string& what, const std::string& previousValue, const std::string& newValue)
		{ return Instance()->log(winfo, what, previousValue, newValue); }


    bool enable(bool enable = true)        { m_enable = enable; }
    bool enabled() const                   { return m_enable; }

	bool log(WidgetInfo& winfo, const std::string& what, const std::string& previousValue, const std::string& newValue);

private:
	UILogger();							// private
	UILogger(const UILogger& other);	// disabled

	static void CleanUp();

	bool m_enable;

	static SHARED_PTR<UILogger> m_instance;
};


} /* end of namespace Widgets */

} /* end of namespace TDE */

#endif /* TDE_WIDGETS_UILOGGER_H */
