yate学习--yateclass.h--class YATE_API DebugEnabler


    请声明转载出:

    DebugEnabler,这个类用于保存和修改调试级别,也就是日志的打印级别:

/**
 * Holds a local debugging level that can be modified separately from the
 *  global debugging
 * 保留本地的调试级别,这个级别能被个别的全局调试修改
 * @short A holder for a debug level
 * @short  保存一个调试级别
 */
class YATE_API DebugEnabler
{
public:
    /**
     * Constructor
     * 构造函数
     * @param level The initial local debug level
     * @参数level,本地调试级别初始值
     * @param enabled Enable debugging on this object
     * @参数enabled,在该对象上启动调试
     */
    inline DebugEnabler(int level = P2PEngine::debugLevel(), bool enabled = true)
	: m_level(DebugFail), m_enabled(enabled), m_chain(0), m_name(0)
	{ debugLevel(level); }

    inline ~DebugEnabler()
	{ m_name = 0; m_chain = 0; }

    /**
     * Retrieve the current local debug level
     * 重新获得当前本地的调试级别
     * @return The current local debug level
     * @返回当前本地调试级别
     */
    inline int debugLevel() const
	{ return m_chain ? m_chain->debugLevel() : m_level; }

    /**
     * Set the current local debug level.
     * 设置当前本地的调试级别
     * @param level The desired debug level
     * @参数level,被要求的调试级别
     * @return The new debug level (may be different)
     * @返回新的调试级别(可能不同)
     */
    int debugLevel(int level);

    /**
     * Retrieve the current debug activation status
     * 见过当前调试的激活状态
     * @return True if local debugging is enabled
     * @返回true,如果本地调试启用
     */
    inline bool debugEnabled() const
	{ return m_chain ? m_chain->debugEnabled() : m_enabled; }

    /**
     * Set the current debug activation status
     * 设置当前调试激活状态
     * @param enable The new debug activation status, true to enable
     * @参数enable,新的调试激活状态,true 为启用
     */
    inline void debugEnabled(bool enable)
	{ m_enabled = enable; m_chain = 0; }

    /**
     * Get the current debug name
     * 获得当下调试名
     * @return Name of the debug activation if set or NULL
     * @返回调试名,如果设置了激活调试名,或者NULL
     */
    inline const char* debugName() const
	{ return m_name; }

    /**
     * Check if debugging output should be generated
     * 检查是否应该生成调试输出
     * @param level The debug level we are testing
     * @参数level,我们正在测试调试水平
     * @return True if messages should be output, false otherwise
     * @返回true,如果消息应该被输出,否则为false
     */
    bool debugAt(int level) const;

    /**
     * Check if this enabler is chained to another one
     * 检查这个使能者是否被另外一个锁住
     * @return True if local debugging is chained to other enabler
     * @返回true,如果本地的调试信息被另外一个使能者锁住
     */
    inline bool debugChained() const
	{ return m_chain != 0; }

    /**
     * Chain this debug holder to a parent or detach from existing one
     * 束缚调试所有者的父对象,或者从现有的分离
     * @param chain Pointer to parent debug level, NULL to detach
     * @参数chain,父对象指针的调试级别,NULL 为分离
     */
    inline void debugChain(const DebugEnabler* chain = 0)
	{ m_chain = (chain != this) ? chain : 0; }

    /**
     * Copy debug settings from another object or from engine globals
     * 从别的对象或者是从全局引擎拷贝调试设置
     * @param original Pointer to a DebugEnabler to copy settings from
     * @参数original,要拷贝DebugEnabler对象的指针
     */
    void debugCopy(const DebugEnabler* original = 0);

protected:
    /**
     * Set the current debug name
     * 设置当前调试名字
     * @param name Static debug name or NULL
     * @参数name,静态的调试名或者NULL
     */
    inline void debugName(const char* name)
	{ m_name = name; }

private:
    int m_level;
    bool m_enabled;
    const DebugEnabler* m_chain;
    const char* m_name;
};


你可能感兴趣的:(yate学习--yateclass.h--class YATE_API DebugEnabler)