#include "server_config.h"


ServerConfig* ServerConfig::_conf = NULL;

ServerConfig::ServerConfig()
{
	_bIsLoad = false;
}
ServerConfig::~ServerConfig()
{}

void ServerConfig::LoadConfig(AbstractConfiguration &config)
{
	if ( false == _bIsLoad )
	{
		_settings._port = config.getInt("port");
		_settings._max_thread = config.getInt("max_threads");
		_settings._max_queue = config.getInt("max_queued");
		_settings._thread_idle_time = config.getInt("thread_idle_time");
		_settings._log_path = config.getString("log_path");
		_settings._redisServerIp = config.getString("redis_server_ip");
		_settings._redisAuth = config.getString("redis_auth");
		_settings._redisNeedAuth = config.getInt("redis_need_auth");
		_settings._redisServerPort = config.getInt("redis_server_port");
		_settings._redisConTimeOut = config.getInt("redis_con_timeout");
		_settings._connRetryTimes = config.getInt("redis_connect_retry_times");
		_settings._iMaxThreadNum = config.getInt("instance_max_threads_num");
		_settings._iDefThreadNum = config.getInt("instance_default_threads_num");
		_settings._iServerFlag = config.getInt("server_flag");

		_bIsLoad = true;
	}
}
LocalSettings ServerConfig::getLocalSettings()
{
	return _settings;
}
ServerConfig* ServerConfig::getInstance()
{
	if ( NULL == _conf )
		_conf = new ServerConfig();
	return _conf;
}
