acl/lib_acl_cpp/include/acl_cpp/master/master_base.hpp

128 lines
2.8 KiB
C++
Raw Normal View History

#pragma once
2017-06-02 14:47:24 +08:00
#include "../acl_cpp_define.hpp"
#include "../stdlib/noncopyable.hpp"
2017-06-02 14:47:24 +08:00
#include "master_conf.hpp"
#include <vector>
2014-11-19 00:25:21 +08:00
#ifndef ACL_CLIENT_ONLY
2014-11-19 00:25:21 +08:00
struct ACL_EVENT;
namespace acl
{
class server_socket;
2014-11-19 00:25:21 +08:00
class event_timer;
class string;
2014-11-19 00:25:21 +08:00
class ACL_CPP_API master_base : public noncopyable
2014-11-19 00:25:21 +08:00
{
public:
/**
* bool
2014-11-19 00:25:21 +08:00
* @param table {master_bool_tbl*}
*/
void set_cfg_bool(master_bool_tbl* table);
/**
* int
2014-11-19 00:25:21 +08:00
* @param table {master_int_tbl*}
*/
void set_cfg_int(master_int_tbl* table);
/**
* int64
2014-11-19 00:25:21 +08:00
* @param table {master_int64_tbl*}
*/
void set_cfg_int64(master_int64_tbl* table);
/**
*
2014-11-19 00:25:21 +08:00
* @param table {master_str_tbl*}
*/
void set_cfg_str(master_str_tbl* table);
/**
* acl_master daemon
2014-11-19 00:25:21 +08:00
* @return {bool}
*/
bool daemon_mode(void) const;
/////////////////////////////////////////////////////////////////////
/**
* 线 (
* proc_on_init)
* ( master_timer::destroy )
* @param timer {event_timer*}
* @return {bool}
2014-11-19 00:25:21 +08:00
*/
bool proc_set_timer(event_timer* timer);
/**
*
* @param timer {event_timer*} proc_set_timer
2014-11-19 00:25:21 +08:00
*/
void proc_del_timer(event_timer* timer);
protected:
bool daemon_mode_;
bool proc_inited_;
std::vector<server_socket*> servers_;
2014-11-19 00:25:21 +08:00
master_base();
virtual ~master_base();
/**
* 便
* @param ss {const server_socket&}
*/
virtual void proc_on_listen(server_socket& ss) { (void) ss; }
2014-11-19 00:25:21 +08:00
/**
*
* root
2014-11-19 00:25:21 +08:00
*/
virtual void proc_pre_jail() {}
/**
*
*
2014-11-19 00:25:21 +08:00
*/
virtual void proc_on_init() {}
/**
* 退
2014-11-19 00:25:21 +08:00
*/
virtual void proc_on_exit() {}
/**
* SIGHUP
*/
virtual bool proc_on_sighup(string&) { return true; }
// 配置对象
2014-11-19 00:25:21 +08:00
master_conf conf_;
protected:
// 子类必须调用本方法设置事件引擎句柄
2014-11-19 00:25:21 +08:00
void set_event(ACL_EVENT* event);
/**
*
* @return {ACL_EVENT*}
*/
ACL_EVENT* get_event(void) const
{
return event_;
}
2014-11-19 00:25:21 +08:00
private:
ACL_EVENT* event_;
};
} // namespace acl
#endif // ACL_CLIENT_ONLY