statisitcs.h 1.2 KB
#pragma once

#include <common.h>
#include "client_proto_head.h"

#undef  BIND_PROTO_CMD
#undef  BIND_PROTO_CMD_NO_CB
#define BIND_PROTO_CMD(__cmd_id__, fun_name, proto_name)\
	static const CMD_ID cli_##proto_name##_cmd = __cmd_id__
#define BIND_PROTO_CMD_NO_CB(__cmd_id__, fun_name, proto_name)
#include <statisitcs_cmd.h>
#undef  BIND_PROTO_CMD 
#undef  BIND_PROTO_CMD_NO_CB

#define STATISITCS_MSG_HANDLE_FUN_PAR el::lib_tcp_peer_info_t* fd_info, google::protobuf::Message* msg

DEF_MSG_HANDLE_FUN(statisitcs_t, STATISITCS)

class statisitcs_t
{
public:
	statisitcs_t();
	virtual ~statisitcs_t();

    int init();
private:
	void release();
	int init_msg_map();
    void release_msg_map();
//binding processing function
#undef  BIND_PROTO_CMD
#undef  BIND_PROTO_CMD_NO_CB

#define BIND_PROTO_CMD(__cmd_id__, fun_name, proto_name)\
	int fun_name(STATISITCS_MSG_HANDLE_FUN_PAR)
#define BIND_PROTO_CMD_NO_CB(__cmd_id__, fun_name, proto_name)\
	int fun_name(STATISITCS_MSG_HANDLE_FUN_PAR)

#include <statisitcs_cmd.h>

#undef  BIND_PROTO_CMD
#undef  BIND_PROTO_CMD_NO_CB
public:
	int on_recv(el::lib_tcp_peer_info_t* peer_fd_info, char* pdata, int len);
    STATISITCS_MSG_MAP_T msg_map;
};

extern statisitcs_t* g_statisitcs;