#ifndef Datenbank_H
#define Datenbank_H

#include <sql.h>
#include <Text.h>
#include <InitDatei.h>

using namespace Framework;
using namespace sql;

namespace Admin_Recht
{
	const int MSStarten = 0x00000001;
	const int MSBeenden = 0x00000002;
}

class MSDatenbank
{
private:
	Datenbank *datenbank;
	CRITICAL_SECTION ths;
	int ref;

public:
	// Konstruktor
	MSDatenbank( InitDatei *zDat );
	// Detruktor
	~MSDatenbank();
	// nicht constant
	void lock();
	void unlock();
	int istAdministrator( const char *name, const char *passwort );
	bool adminHatRecht( int id, int recht );
	unsigned int getNextClientId();
	Text *getKlientKey( int cId );
	bool proveRegisteredClient( unsigned int num );
	int *unregisterClient( unsigned int num );
	int suchPatchServer( unsigned int client );
	unsigned char *getPatchServerPortIp( int num );
	int suchRegisterServer( unsigned int client );
	unsigned char *getRegisterServerPortIp( int num );
	int suchLoginServer( unsigned int client );
	unsigned char *getLoginServerPortIp( int num );
	int suchInformationServer( unsigned int client );
	unsigned char *getInformationServerPortIp( int num );
	int suchChatServer( unsigned int client );
	unsigned char *getChatServerPortIp( int num );
	int suchAnmeldungServer( unsigned int client );
	unsigned char *getAnmeldungServerPortIp( int num );
	int suchErhaltungServer( unsigned int client );
	unsigned char *getErhaltungServerPortIp( int num );
	int suchShopServer( unsigned int client );
	unsigned char *getShopServerPortIp( int num );
	int suchNewsServer( unsigned int client );
	unsigned char *getNewsServerPortIp( int num );
	int logoutKlient( int klientId, Array< int > *ret );
	bool getSpielServerPortIp( int spielErstelltId, unsigned short *port, Text *ip );
	int getSpielerAusGruppe( int gruppeId, Array< int > *accountId );
	int kickSpielerAusGruppe( int gruppeId, int accountId );
	bool getChatServerPortIp( int accountId, unsigned short *port, Text *ip );
	int getGruppeAdmin( int gruppeId );
	int getSpielerAusChatroom( int chatroomId, Array< int > *accountId );
	int getChatroomAdmin( int chatroomId );
	int clientistEingeloggt( int clientId );
	bool getPatchServer( int client, Text *ip, int *port );
	bool getRegisterServer( int client, Text *ip, int *port );
	bool getLoginServer( int client, Text *ip, int *port );
	bool getInformationServer( int client, Text *ip, int *port );
	bool getChatServer( int client, Text *ip, int *port );
	bool getAnmeldungServer( int client, Text *ip, int *port );
	bool getSpielServer( int client, Text *ip, int *port );
	bool getShopServer( int client, Text *ip, int *port );
	bool getNewsServer( int client, Text *ip, int *port );
    bool getHistorieServer( int client, Text *ip, int *port );
    bool getKartenServer( int client, Text *ip, int *port );
    bool getEditorServer( int client, Text *ip, int *port );
	// Reference Counting
	MSDatenbank *getThis();
	MSDatenbank *release();
};

#endif