📄 nlevent.h
字号:
/**
* 事件类定义
* @file NLEvent.h
* @date 14-Jul-2005
* @author 胡春雨
* @version 1.0.0: 初始版本
*/
#ifndef _NL_EVENT_H
#define _NL_EVENT_H
#include <memory>
#include "nlkit/NLTime.h"
#include "nlkit/NLLogLevel.h"
namespace nlkit
{
class EventAdornHandle
{
public :
virtual const char* message() = 0;
};
/**
* 事件类
*/
class NLEvent
{
public:
/**
* 构造函数
* @param ll: 日志级别
* @param message: 信息
* @param filename: 文件名
* @param line: 行数
* @return 无
*/
NLEvent(NLLogLevel ll, const std::string& message,
const char* filename, int line, EventAdornHandle* adornHandle);
/**
* 构造函数
* @param rhs: 事件
* @return 无
*/
NLEvent(const NLEvent& rhs)
: m_message(rhs.getMessage()),
m_ll(rhs.getNLLogLevel()),
m_timestamp(rhs.getTimestamp()),
m_file(rhs.getFile()),
m_line(rhs.getLine()),
m_pAdornHandle(rhs.getAdornHandle())
{
}
/**
* 虚拟析构函数
* @param 无
* @return 无
*/
virtual ~NLEvent();
/**
* 取信息
* @param 无
* @return const string&: 信息引用
*/
virtual const std::string& getMessage() const;
/**
* 克隆事件
* @param 无
* @return auto_ptr<NLEvent>: 指向事件的智能指针
*/
virtual std::auto_ptr<NLEvent> clone() const;
/**
* 取日志级别
* @param 无
* @return NLLogLevel: 日志级别
*/
NLLogLevel getNLLogLevel() const { return m_ll; }
/**
* 取时间戳
* @param 无
* @return const NLTime&: 时间引用
*/
const NLTime& getTimestamp() const { return m_timestamp; }
/**
* 取文件名
* @param 无
* @return const string&: 文件名引用
*/
const std::string& getFile() const { return m_file; }
/**
* 取行数
* @param 无
* @return int: 行数
*/
int getLine() const { return m_line; }
EventAdornHandle* getAdornHandle() const {return m_pAdornHandle;}
NLEvent& operator=(const NLEvent& rhs);
protected:
std::string m_message; /**< 消息 */
private:
NLLogLevel m_ll; /**< 日志级别 */
NLTime m_timestamp; /**< 时间戳 */
std::string m_file; /**< 文件名 */
int m_line; /**< 行数 */
EventAdornHandle* m_pAdornHandle;
};
}
#endif // !_NL_EVENT_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -