/***************************************************************************
                   Config Class Header ( Config.h )
                -----------------------------------------

	begin      : 2013/02/13
	copyright  : (C) 2013 Solbox Inc.
	author     : Development 1 Team
					- 2013/02/14 - 1st dadamin
	email      : dev1@solbox.com
	version    : 3.2.0

	CopyRight(C) 2005 Solbox Inc. All Rights reserved.
	Redistribution and use in source and binary forms, with or with out
	modification, are not permitted in outside of Solbox Inc.
***************************************************************************/
#ifndef __RC_MNGD_CONFIG_H__
#define __RC_MNGD_CONFIG_H__

class CServiceInfo;

class CDatabaseInfo
{
public:
	CDatabaseInfo() : m_nRcdbPort(0) {}
	~CDatabaseInfo() {}

public:
	string	m_szRcdbIp;
	int		m_nRcdbPort;
	string	m_szRcdbName;
	string	m_szRcdbAcct;
	string	m_szRcdbAcctPw;

};

class CCommonConfig
{
public:
	CCommonConfig( string szFilename, string szProgramName );
	virtual ~CCommonConfig();
	
	bool LoadConf();
	bool CheckValue();

	void PrintValue();

	inline	const char * GetErrMessage()	{ return m_szErrMessage.c_str(); }

	inline	const char * GetAppLogRoot()	{ return m_szAppLogRoot.c_str(); }
	inline	int			GetAppLogLevel()	{ return m_nLogLevel; }
	inline	const char * GetRCDomain()		{ return m_szRCDomain.c_str(); }
	inline CDatabaseInfo GetDBInfo()		{ return m_cDatabaseInfo; } 
	inline int GetDBPoolCnt()				{ return m_DBPoolCnt; }
	inline const char* GetRCID()			{ return m_szRcid.c_str(); }

protected:
	string	m_szConfigFile;
	string	m_szProgramName;

	string	m_szErrMessage;

	// RCDB
	CDatabaseInfo m_cDatabaseInfo;
	int			m_DBPoolCnt;

	// RC
	string	m_szRcid;
	string	m_szRCDomain;

	// log
	string	m_szAppLogRoot;
	int		m_nLogLevel;
	
private:

};

class CMyConfig : public CCommonConfig
{
public:
	static bool Init( string szProgramName, string szFilename );
	static void Exit();
	static CMyConfig* GetInstance();

private:
	static CMyConfig* m_pInstance;

public:
	bool LoadConf();
	bool CheckValue();

	void PrintValue();

	inline list<CServiceInfo>& GetServiceList() { return m_ServiceList; }
	inline int		GetFHSControlTCP() { return m_nFHSCtlTCP; }	
	inline const char * GetSSLCertFile() { return m_szCertFile.c_str(); }
	inline const char * GetSSLPrivateFile() { return m_szPrivateFile.c_str(); }

protected:
	CMyConfig( string szFilename, string szProgramName );
	virtual ~CMyConfig();

protected:

	// SSL key
	string				m_szCertFile;
	string				m_szPrivateFile;

	// FHS control port	
	int					m_nFHSCtlTCP;

	// Service List
	list<CServiceInfo>	m_ServiceList;
	

private:

};

#endif // __RC_MNGD_CONFIG_H__
