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

	begin      : 2015/04/28
	copyright  : (C) 2013 Solbox Inc.
	author     : Development Team
	email      : storage.sd@solbox.com
	version    : 3.5.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 __DAEMON_CONFIGS_H__
#define __DAEMON_CONFIGS_H__

#include <string>
#include <vector>

using namespace std;


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 *	GetConfigFile()			{ return m_szConfigFile.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 CDeamonConfig : public CCommonConfig
{
public:
	static bool Init( string szProgramName, string szFilename );
	static void Exit();
	static CDeamonConfig* GetInstance();

	inline	const char *				GetLogServer()			{return m_szLogServer.c_str(); }
	inline	int							GetLogServerPort()		{return m_nLogServerPort; }
	inline	int							GetAppLogPeriod()		{return m_nAppLogPeriod; }
	inline	std::vector<std::string>	GetSearchingDirList()	{return m_vecSearchingDirList; }
	
private:
	static CDeamonConfig* m_pInstance;

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

	void PrintValue();
	 
protected:
	CDeamonConfig(string szFilename, string szProgramName);
	virtual ~CDeamonConfig();

protected:


private:
	string m_szLogServer;
	int m_nLogServerPort;
	int m_nAppLogPeriod;
	
	std::vector< std::string > m_vecSearchingDirList;
};

#endif // __RC_MNGD_CONFIG_H__
