/* ====================================================================
 * 파    일 :	sqlAccount.h
 * 목    적 :	
 * 작 성 자 :	곽철중
 * 작 성 일 :	07/01/12
 * 주의사항 :	
 * =================================================================== */
#ifndef __SQL_ACCOUNT_H__
#define __SQL_ACCOUNT_H__

//#ifndef WINVER
//#define WINVER          0x0500
//#endif
//
//#ifndef _WIN32_WINNT
//#define _WIN32_WINNT    0x0500
//#endif

#pragma once

#include "sqlpool.h"
#include "sqlaccountstmt.h"
#include "iocontextpool.h"

#ifndef __SQL_REQUEST_ACCOUNT_TYPE__
#define __SQL_REQUEST_ACCOUNT_TYPE__

enum SQL_REQUEST_ACCOUNT_TYPE
{
	// DEFAULT_SQL_ACCOUNT
	SQL_REQUEST_ACCOUNT_TEST = 0x1000,	// DEFAULT_SQL_ACCOUNT(0x1000) - defined gamesrv.h file
	SQL_REQUEST_ACCOUNT_SHUTDOWN,		// Shutdown Account Database

	SQL_GAME_PROCESS_CHANNEL_CHECK,
	SQL_GAME_PROCESS_MEMBER_CHECK,
	SQL_GAME_PROCESS_MEMBER_LOGOUT,
	SQL_GAME_PROCESS_COMEIN_GAME,
	SQL_GAME_PROCESS_GAMEIN_COMPLETE,
	SQL_GAME_PROCESS_GAMEOUT_COMPLETE,
	SQL_GAME_PROCESS_GOTO_INSTANT_DUNGEON,
	SQL_GAME_PROCESS_RETURN_TO_MAP,

	// 접속정보
	SQL_GAME_PROCESS_WHISPER_MEMBER_SELECT,
	SQL_GAME_PROCESS_NOTE_MEMBER_SELECT,

	// MAX
	MAX_SQL_ACCOUNT
};

#endif // __SQL_REQUEST_ACCOUNT_TYPE__


class cSQLAccount :
	public cSQLPool
{
private:
	cIoContextPool*   mIoContextPool;

protected:
// Page Pool 관리 메소드.
	PerSQLConnection* AllocSQLConnection ( void );

private:
// LOG 관련 메소드.
	bool              PostServerEvent    ( LPCTSTR format, ... );

public:
// 클래스 생성 및 공용 메소드.
	cSQLAccount(void);

	bool              Initialize         ( char* dsn, char* uid, char* pwd, unsigned int numWorkerThreads=2, unsigned int bufferLength=65535 );
	void              Shutdown           ( void );

	void              GetIoContextPool   ( SIZE_T& quotaPagedPoolUsage, SIZE_T& quotaNonPagedPoolUsage, SIZE_T& workingSetSize );

	PerIoContext*     Get                ( );
	void              Release            ( PerIoContext* perIoContext );

	DWORD             WorkerThread       ( void );

public:
// 클래스 파괴 메소드.
	virtual ~cSQLAccount(void);
};

#endif // __SQL_ACCOUNT_H__