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

📄 warsmartpointer.h

📁 ftpserver very good sample
💻 H
字号:
/** @name A one line description of the class. * * #include "WarSmartPointer.h" <BR> * -llib  * * A 'smart pointer' is a special type of pointer * that is created in a normal fashion, using {\bfnew}, * but released with a function. The idea is that * there might be several references to a pointer, * and no real {\itowner} that is responsible for * killing the object. A smart pointer keeps a * reference counter to the objects that uses it, * and kills utself when the reference counter is * zero. When the object is created the initial * counter is 0. Each object that needs to reference the * pointer calls Attac() to increase the reference count, and * Detach() when done.  * * Note: The initial reference counter value is 0.  * WarPtrWrapper(WarSmartPointer *) calls Attach(). * * * The smart pointer's built-in methods are thread-safe. * * @see WarPtrWrapper */#ifndef WAR_SMART_POINTER_H#define WAR_SMART_POINTER_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_CRITICAL_SECTION_H#   include "WarCriticalSection.h"#endif#ifndef WAR_WIN32_REGISTRY_H#   include "WarWin32Registry.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 WarSmartPointer {public:    // LIFECYCLE        /**    * Default constructor.    *     * The initial reference counter is 0, so     * the object must either be attached to a     * \Ref{WarPtrWrapper} list, or Attach() must    * be called.    */    WarSmartPointer(void);            // OPERATORS        // OPERATIONS    /**      * Increments the reference counter     */    virtual void Attach();    /**     * Cecrements the reference pointer, and     * deletes the object when the reference      * counter is zero     *     * Use Detach() in stead of delete     */    virtual void Detach();    /**     * The static method      * Initialize() must be called before the smart     * pointers can be used.     */    static void Initialize();    // ACCESS    // INQUIRY    inline int GetReferenceCount() const    {        return mRefCnt;    }    protected:   /**    * Destructor.     *    * Use \Ref{Detach()} in stead    */    virtual ~WarSmartPointer(void);    static WarCriticalSection *mspLock;    private:#ifdef _DEBUG    static int msPtrCnt;#endif    int mRefCnt; // Initial 0};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif  /* _WAR_SMART_POINTER_H_ */

⌨️ 快捷键说明

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