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

#include <pthread.h>
#include <string>
#include <vector>
#include "Logger.h"
#include "Database.h"
#include "FimngdData.h"
#include "SharedMemAPR.h"
#include "SocketControl.h"

/// @brief
class CNetworkStatSendThread
{
public:
	/// @brief 생성자
	CNetworkStatSendThread();
	~CNetworkStatSendThread();
	
	/// @brief Thread를 생성하고, 이를 시작한다.
	/// @param none
	/// @return 성공은 return true 실패는 return false
	bool Start();
	
	/// @brief ProcessStatus 내의 RCDB 관련 설정값을 이용해 DB Connection을 한다.
	/// @param sighandle 쓰레드에서 signal에 따라 정상 종료하도록 signal handle을 전달한다.
	/// @param pshmemNetworStat 공유메모리 포인터
	/// @return 성공하면 return true 실패하면 return false
	bool ThreadInit(const sig_atomic_t *sighandle, CSharedMem* pshmemNetworStat);

	

// Attributes
private:
	// 쓰레드 핸들
	pthread_t m_threadHandle;
	
	CSocketControl m_objSocket;
	// rc_sscd host & port info
	std::string m_szHost;
	int m_nPort;

	const sig_atomic_t *m_sighandle;
	CSharedMem* m_pshmemNetworStat;

	std::vector<struct service_network_stat> m_vecNetworkStat;

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

	void GetNetworkStat();
	bool NetworkStatSend();
	void printNetworkStat(struct service_network_stat* pobjNetstat);
};
#endif //__NETWORK_STAT_SEND_THREAD__
