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

	begin      : 2013/05/30
	copyright  : (C) 2013 Solbox Inc.
	author     : Development 1 Team
					- 2013/05/30 - 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 __SERVICE_H__
#define __SERVICE_H__

#include "WorkPool.h"
#include "DBManager.h"

namespace SERVICE_TYPE
{
	enum sType {
		UNSET		=  -1,
		FAIL_MON	=	0,
		TCP_SERVICE	=	1,
	};
}

class CService
{
public:
	CService() : m_done(false) {};
	virtual ~CService() {};
	
	virtual bool Create();
	virtual bool Start();
	virtual bool Stop();
protected:
	CWorkPool m_WokrPool;
	CDBManager m_DBManager;

	bool	m_done;
};

class CFailLogMon : public CService
{
public:
	CFailLogMon();
	virtual ~CFailLogMon();

	virtual bool Create();
	virtual bool Start();
	virtual bool Stop();

protected:
	bool FindLog();

	string m_fiallogpath;

};

class CTCPService : public CService
{
public:
	CTCPService();
	virtual ~CTCPService();

	virtual bool Create();
	virtual bool Start();
	virtual bool Stop();

protected:
	bool Accpet();

public:
	static bool MakeListenSocket();
	static void SetPort(int port);

protected:
	static int  m_port;
	static int	m_listenSocket;
	static bool	m_ipv6;	
};

// Abstract Factory returning a Service
class CServiceFactory 
{
public:
	CService* CreateSerivce(SERVICE_TYPE::sType t);
};

#endif // __SERVICE_H__
