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

	begin      : 2013/09/16
	copyright  : (C) 2005 Solbox Inc.
	author     : Development 1 Team
					- 2013/09/16
	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.
***************************************************************************/
#include "cc_tsd.h"

#ifndef __CC_TSD_CONFIG_H__
#define __CC_TSD_CONFIG_H__

void StringSplit(string str, string delim, vector<string> &results, bool bUseEmpty /*= false*/);

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; }

protected:
	string	m_szConfigFile;
	string	m_szProgramName;

	string	m_szErrMessage;
	
	// 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();

	inline int	GetTCPListenPort() { return m_nListenPort; }
	inline string	GetDBIP() { return m_szDBIP; }
	inline int	GetDBPort() { return m_nDBPort; }
	inline string	GetDBName() { return m_szDBName; }
	inline string	GetDBAccount() { return m_szDBAccount; }
	inline string	GetDBPwd() { return m_szDBPwd; }
	inline bool	GetLoginInfo() { return m_bLoginInfo; }

	void PrintValue();

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

protected:	
	int				m_nListenPort;
	string			m_szDBIP;
	int				m_nDBPort;
	string			m_szDBName;
	string			m_szDBAccount;
	string			m_szDBPwd;
	bool			m_bLoginInfo;
	string			m_szLoginInfo;

private:

};

#endif // __CC_STATD_CONFIG_H__
