⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 warpluginsupport.h

📁 ftpserver very good sample
💻 H
字号:
/** Abstract base class for classes that support plugins. These  * classes can call plugin events handlere.*/#ifndef WAR_PLUGIN_SUPPORT_H#define WAR_PLUGIN_SUPPORT_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_EXCEPTION_H#   include "WarException.h"#endif#ifndef WAR_PLUGIN_ENGINE_H#   include "WarPluginEngine.h"#endif#ifndef WAR_PLUGIN_H#   include "WarPlugin.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarPluginBaseSupport{public:    typedef std::vector<war_plugin_list_t> plugins_vector_t;    // LIFECYCLE    WarPluginBaseSupport(const size_t numEvents,         const war_ccstr_t className)        : mPlugins(numEvents),        mClassName(className)    {        WarPluginEngine::GetEngine().RegisterPluginSupportClassInstance(this);    }    virtual ~WarPluginBaseSupport()    {         WarPluginEngine::GetEngine().UnregisterPluginSupportClassInstance(this);         mPlugins.erase(mPlugins.begin(), mPlugins.end());    }    // OPERATORS      bool operator == (war_ccstr_t className)    {        return strcmp(className, mClassName.c_str()) == 0;    }    // OPERATIONS    void AddPlugin(const int plgEvent,         war_plugin_ptr_t plgPtr)    {        VerifyIndex(plgEvent);        mPlugins[plgEvent].push_back(plgPtr);    }    void RemovePlugins(const int plgEvent)    {        VerifyIndex(plgEvent);                mPlugins[plgEvent].erase(mPlugins[plgEvent].begin(),            mPlugins[plgEvent].end());    }    // CALLBACK    // ACCESS    // INQUIRY    const std::string& GetClassName() const    {        return mClassName;    }protected:    inline void VerifyIndex(const size_t plgEvent)    {        if ((0 > plgEvent) || (mPlugins.size() <= plgEvent))            WarThrow(WarError(WAR_ERR_OUT_OF_RANGE), NULL);    }    friend class WarPluginEngine;    plugins_vector_t mPlugins;    std::string mClassName;};template <class classT>class WarPluginSupport : public WarPluginBaseSupport{public:    // LIFECYCLE        /**    * Default constructor.    */    WarPluginSupport(war_ccstr_t className)         throw(WarException)        : WarPluginBaseSupport(classT::PLUGIN_EVENT_INVALID,        className)    {    }          /**    * Destructor.    */    virtual ~WarPluginSupport()    {}        // OPERATORS      // OPERATIONS    inline war_plugin_list_t& GetPlugins(const int plgEvent)    {        VerifyIndex(plgEvent);        return mPlugins[plgEvent];    }    // CALLBACK    // ACCESS    // INQUIRY    protected:private:};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif  /* WAR_PLUGIN_SUPPORT_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -