/***************************************************************************
                Replicate Work Class
                -----------------------------------------
    begin      : 2012/10/14
    copyright  : (C) 2010 SolutionBox Inc.
    author     : Service 1 Team
    email      : svc1@solbox.com
    version    : 1.0

    CopyRight(C) 2010 SolutionBox Inc. All Rights reserved.
    Redistribution and use in source and binary forms, with or with out
    modification, are not permitted in outside of SolutionBox Inc.
***************************************************************************/

#ifndef __CATEGORIZE_THREAD__
#define __CATEGORIZE_THREAD__

#include <pthread.h>
#include <string>
#include "Logger.h"
#include "Data.h"
#include "DataQueue.h"
#include "ProcessStatus.h"
#include "Database.h"

/// @brief
class CCategorizeThread
{
public:
	/// @brief 생성자
	/// @param [in] pLogger 로깅을 위한 클래스.
	CCategorizeThread(CQueue<CFileInfo>* pQueueFileInfo
		, CQueue<CFileInfo>* pQueueDeleteJob
		, CQueue<CFileInfo>* pQueueCompleteJob);
	~CCategorizeThread();
	
	/// @brief Thread를 생성하고, 이를 시작한다.
	/// @param none
	/// @return 성공은 return true 실패는 return false
	bool Start();
	
	bool DbConnect();
	void DbClose();
	
	/// @brief ProcessStatus 내의 RCDB 관련 설정값을 이용해 DB Connection을 한다.
	/// @param None
	/// @return 성공하면 return true 실패하면 return false
	bool ThreadInit();

	bool Categorize();
	

// Attributes
private:
	DataBase* m_pPgSQL;
	
	CQueue<CFileInfo>* m_pQueueFileInfo;
	CQueue<CFileInfo>* m_pQueueDeleteJob;
	CQueue<CFileInfo>* m_pQueueCompleteJob;
	
	std::string m_szHost;
	int m_nPort;
	std::string m_szDBName;
	std::string m_szAcct;
	std::string m_szPasswd;
	
	bool m_bServiceTableSeparate;
	// 쓰레드 핸들
	pthread_t m_threadHandle;
	
	// 쓰레드 시작 루틴이다.
	static void* EntryPoint(void* arg);
	
	// 해당 함수의 내용은 수정하지 말것.
	void Execute();

};
#endif //__CATEGORIZE_THREAD__
