#ifndef _TCL_GUID_H_
#define _TCL_GUID_H_

#include <string>

using namespace std;



/**
 * \brief Generates unique identifiers
 * 
 * Contains static int counter, which is increased by one whenever new
 * instance is created
 *
 * \date 01-11-2006
 *
 * \author Ondrej Svejdar
 *
 * \todo 
 *
 * \bug 
 *
 */
class TclGuid
{
	static unsigned int idGenerator;
	string id;
public:
	
	/**
	 * \brief Return id
	 * \return unique identifier
	 */
	const string& getId() const
	{
		return id;
	}
	
	/**
	 * \brief Create new instance with unique id
	 */
	TclGuid()
	{
		TclGuid::idGenerator++;
		char buf[60];
		sprintf(buf,"guid%x",idGenerator);
		id=buf;
	}

	/**
	 * \brief Comparator
	 * \param guid reference to TclGuid 
	 * \return true if ids are equal
	 */
	TclGuid& operator=(const TclGuid& guid)
	{
		this->id=guid.id;
		return *this;
	}

	/**
	 * Create new unique identifier with specific value, potentionaly unsafe,
	 * use only if you absolutly know what you do.
	 *
	 * \param id specific value
	 * \return reference to newly created TkGuid
	 */
	static TclGuid& forceGuid(const string& id)
	{
		TclGuid* guid=new TclGuid();
		guid->id=id;

		return *guid;
	}
};

#endif/*_TCL_GUID_H_*/

