/***************************************************************************
                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 __MSG_QUEUE_POP_THREAD__
#define __MSG_QUEUE_POP_THREAD__

#include </usr/include/sys/signal.h>
#include <csignal>
#include <pthread.h>
#include <string>
#include <map>
#include <vector>
#include "Logger.h"
#include "FimngdData.h"
#include "IPCMsgQueue.h"
#include "TransferStatDataList.h"

/// @brief
class CMsgQueuePopThread
{
public:
	/// @brief 생성자
	CMsgQueuePopThread();
	~CMsgQueuePopThread();
	
	/// @brief Thread를 생성하고, 이를 시작한다.
	/// @param none
	/// @return 성공은 return true 실패는 return false
	bool Start();
	
	/// @brief ProcessStatus 내의 RCDB 관련 설정값을 이용해 DB Connection을 한다.
	/// @param sighandle 쓰레드에서 signal에 따라 정상 종료하도록 signal handle을 전달한다.
	/// @param objMsgQueue IPC Message Queue 객체
	/// @return 성공하면 return true 실패하면 return false
	bool ThreadInit(const sig_atomic_t *sighandle, std::vector<CIPCMsgQueue> &vecContentQueue, CTransferStatDataList *pTransfer = NULL);
	bool ThreadInit(const sig_atomic_t *sighandle, CIPCMsgQueue &cContentQueue, CTransferStatDataList *pTransfer = NULL);

// Attributes
private:
	// 쓰레드 핸들
	pthread_t m_threadHandle;
	
	const sig_atomic_t *m_sighandle;

	std::vector<CIPCMsgQueue> m_vecContentQueue;

	CTransferStatDataList * m_pTransfer;

	void Pop();
	
	// 쓰레드 시작 루틴이다.
	static void* EntryPoint(void* arg);
	
	// 해당 함수의 내용은 수정하지 말것.
	void Execute();
};
#endif //__MSG_QUEUE_POP_THREAD__
