
#ifndef DB_MANAGER_MYSQL_H_
#define DB_MANAGER_MYSQL_H_

#include <set>
#include <map>

#include <mysql++/mysql++.h>

#include "SynsetClassSet.h"


namespace smartcomparator
{
	namespace simfunctions
	{

class DBManagerMySQL {
public:
	enum Language {
		POLISH 	= 2,
		ENGLISH = 6
	};

	struct ConnectionInfo {
		std::string 	user;
		std::string 	password;
		std::string 	dbname;
		std::string 	hostaddr;
		unsigned int 	port;
		Language		language;
	};

private:
	typedef mysqlpp::Connection 			Connection;
	typedef boost::shared_ptr<Connection> 	ConnectionPtrS;


private:
	Connection		mConnection;
	ConnectionInfo 	mConnectionInfo;


public:
	DBManagerMySQL();
	virtual ~DBManagerMySQL();

	bool connect( ConnectionInfo const& pConnectionInfo );
	void disconnect();

	SynsetClassSetPtrS loadSynsetClassesFromMySQL();


private:
	LexicalUnitByIdMapPtrS loadLUConnectedWithSynsets();

	void parseSynset(
		LexicalUnitByIdMapPtrS& 	pLexicalUnitsMap,
		mysqlpp::StoreQueryResult& 	pResult,
		SynsetByIdMapPtrS&			pSynsetMapToFill );

	SynsetByIdMapPtrS loadHyperonymSynsets( LexicalUnitByIdMapPtrS& pLexicalUnitsMap );
	SynsetByIdMapPtrS loadHyponymSynsets( LexicalUnitByIdMapPtrS& pLexicalUnitsMap );

	SynsetRelationSetPtrS loadSynsetsRelations();

};

	}
}
#endif /* DB_MANAGER_MYSQL_H_ */
