/***************************************************************************
  Process Statuis Class 
  -----------------------------------------
begin      : 2011/11/14
copyright  : (C) 2005 SolutionBox Inc.
author     : Service 1 Team
email      : svc1@solbox.com
version    : 1.0

CopyRight(C) 2005 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 _RC_GCMD_PROCESS_STATUS_
#define _RC_GCMD_PROCESS_STATUS_

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <list>

#include "Data.h"


class CProcessStatus
{
// Attributes
private:
// Instance 
	static CProcessStatus* m_pInstance;


// common section configure values
    std::string					m_szProgramName;
    std::string                 m_szProgramVersion;
    
// for DB 
    std::string		m_szRcdbIp;
    int				m_nRcdbPort;
    std::string		m_szRcdbName;
    std::string		m_szRcdbAcct;
    std::string		m_szRcdbAcctPw;
	std::string		m_szAppLogRoot;
	
	std::string     m_szStartPeriod;
	
    unsigned int	m_nLogLevel;
    
    pthread_mutex_t m_mxPhysicalDeleteThreadCount;
    int				m_nPhysicalDeleteThreadCount;
    
    int				m_nDeletenMaxThreadCount;
        
    std::string GetVectorValues(std::vector<std::string> vecParam);


public:
    
	/// @brief constructor
	CProcessStatus();
	
	/// @brief destructor
	~CProcessStatus();
	
	/// @brief 싱글톤 객체 생성
	static void Init();
	
	/// @brief 싱글톤 객체 삭제
	static void Exit();
	
	/// @brief 싱글톤 객체를 얻는다.
	static CProcessStatus * GetInstance();
	
    /// @brief 각 항목의 값들을 로그파일에 기록한다.
    void LoggingConf();
    
    //---------------------------------------------------------------------
    // Configuration values START
    // common section configure values
	void SetProgramName(std::string szProgramName);
	void SetProgramVersion(std::string szProgramVersion);
	void SetLogLevel(unsigned int nLogLevel);
	void SetAppLogRoot(std::string szAppLogRoot);
    
    void SetRcdbIp(std::string vecRcdbIp);
    void SetRcdbPort(int nRcdbPort);
    void SetRcdbName(std::string szRcdbName);
    void SetRcdbAcct(std::string szRcdbAcct);
    void SetRcdbAcctPw(std::string szRcdbAcctPw);
    void SetMaxDeleteThread(int nDeletenMaxThreadCount);
    
    void SetPreserveList( std::list<CPreserve> listPreserve);
    
    void SetStartPeriod(std::string szStartPeriod);
    
    bool AddJobThreadCount();
    bool SubtractJobThreadCount();
   
// common section configure values
	std::string GetProgramName() {return m_szProgramName; }
	std::string GetProgramVersion() {return m_szProgramVersion; }
	std::string	GetAppLogRoot() {return m_szAppLogRoot; }
	unsigned int GetLogLevel() { return m_nLogLevel; }
	
    std::string GetRcdbIp() {return m_szRcdbIp; }
    int GetRcdbPort() {return m_nRcdbPort; }
    std::string GetRcdbName() {return m_szRcdbName; }
    std::string GetRcdbAcct() {return m_szRcdbAcct; }
    std::string GetRcdbAcctPw() {return m_szRcdbAcctPw; }
    
    std::string GetStartPeriod() {return m_szStartPeriod; }
    
    int GetMaxDeleteThread() {return m_nDeletenMaxThreadCount; }
    int GetDeleteThreadCount() {return m_nPhysicalDeleteThreadCount; }
	std::list<CPreserve> GetPreserveList() {return m_listPreserve; }
// Configuration values END
    //---------------------------------------------------------------------
    
private:
    int m_nWokerPid;
    
    std::list<CPreserve> m_listPreserve;

    
public:
    void SetWorkerPid(int nWokerPid);
    int GetWorkerPid(){return m_nWokerPid; }
};


#endif //_RC_GCMD_PROCESS_STATUS_

