锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲中文字幕久久精品无码APP,亚洲国产成人久久综合一区77 ,青青草国产精品久久http://www.shnenglu.com/yy2008/archive/2008/11/13/66837.html絀哄績(jī)鑿?/dc:creator>絀哄績(jī)鑿?/author>Thu, 13 Nov 2008 09:37:00 GMThttp://www.shnenglu.com/yy2008/archive/2008/11/13/66837.htmlhttp://www.shnenglu.com/yy2008/comments/66837.htmlhttp://www.shnenglu.com/yy2008/archive/2008/11/13/66837.html#Feedback3http://www.shnenglu.com/yy2008/comments/commentRss/66837.htmlhttp://www.shnenglu.com/yy2008/services/trackbacks/66837.html
#ifndef __SharedPtr_H__
#define __SharedPtr_H__
#include "OgrePrerequisites.h"
namespace Ogre {
    template<class T> class SharedPtr {
    protected:
        T* pRep;           
        unsigned int* pUseCount; //鐪嬪埌榪欓噷錛屽簲璇ヨ兘鐭ラ亾錛孲haredPtr鏄氳繃寮曠敤璁℃暟鏉ョ鐞唒Rep鐨勫鍛?nbsp;     
    public:
        OGRE_AUTO_SHARED_MUTEX            
        SharedPtr() : pRep(0), pUseCount(0)
        {
            OGRE_SET_AUTO_SHARED_MUTEX_NULL
        }錛忥紡鍏佽鏈変竴涓┖鐨凷haredPtr,涓嶆寚鍚戜換浣曠殑瀵硅薄銆?br>
        template< class Y>
        explicit SharedPtr(Y* rep) : pRep(rep), pUseCount(new unsigned int(1))
        {
            OGRE_SET_AUTO_SHARED_MUTEX_NULL
            OGRE_NEW_AUTO_SHARED_MUTEX
        }//榪欎釜鍐欐硶鏄疢ember Templates錛屽緢鏈夌敤錛岃繖鏍峰氨鍏佽鐢ㄤ竴涓猋瀵硅薄鐨勬寚閽堟潵鍒濆鍖栦竴涓猄haredPtr<T>
                 //涓嬮潰榪樿兘鐪嬪埌寰堝榪欐牱鐨凪ember Templates
                 //瑕佹槸浠ュ墠娌¤榪囩殑浜猴紝鎺ㄨ崘鐪嬩竴涓婥++ Templates鐨勭5绔犮佺3鑺?br>                 //try this:   vector<int> intvec;
                 //       vector<float> floatvec;
                 //       floatvec = intvec ???????
                 //鎻愪竴涓嬶紝鎵鏈夌殑鍒濆鍖栧嚱鏁伴兘娌℃湁媯(gè)鏌ep鏄惁闈炵┖錛屾墍浠haredPtr鎺ュ彈涓涓狽ull鎸囬拡
                 //瀹夊叏媯(gè)鏌ュ湪姣忔璋冪敤鐨勬椂鍊?br>                 //榪欓噷榪樹(shù)嬌鐢ㄤ簡(jiǎn)鍏抽敭瀛梕xplicit錛岀姝簡(jiǎn)闅愬紡杞崲

        SharedPtr(const SharedPtr& r)
            : pRep(0), pUseCount(0)
        {
            OGRE_SET_AUTO_SHARED_MUTEX_NULL
            OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
            {
                OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
                OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
                pRep = r.pRep; //娉ㄦ剰涓嬩笌鍚庨潰鐨勪笉鍚?br>                pUseCount = r.pUseCount;
                // Handle zero pointer gracefully to manage STL containers
                if(pUseCount)
                {
                    ++(*pUseCount); 
                }
            }
        }

        SharedPtr& operator=(const SharedPtr& r) {
            if (pRep == r.pRep)
                return *this;
            SharedPtr<T> tmp(r);
            swap(tmp);
            return *this;
        }//榪欓噷鐨勫啓娉曟湁鐐規(guī)剰鎬濓紝鏈潵鍦╬Rep鎸囧悜r.pRep涔嬪墠瀵筽Rep鍋氫竴嬈elease錛?br>                 //浣嗘槸榪欓噷娌$湅鍒幫紝鍏跺疄鏄氳繃tmp榪欎釜灞閮ㄥ彉閲忕殑鑷姩瑙f瀽瀹炵幇鐨勩?br>        template< class Y>
        SharedPtr(const SharedPtr<Y>& r)
            : pRep(0), pUseCount(0)
        {
            OGRE_SET_AUTO_SHARED_MUTEX_NULL
            OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
            {
                OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
                OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
                pRep = r.getPointer(); //榪欓噷鐢ㄧ殑鏄嚱鏁幫紝鍜屼笂闈㈤偅涓殑鍖哄埆錛燂紵
                pUseCount = r.useCountPointer();
                // Handle zero pointer gracefully to manage STL containers
                if(pUseCount)
                {
                    ++(*pUseCount);
                }
            }
        }
        template< class Y>
        SharedPtr& operator=(const SharedPtr<Y>& r) {
            if (pRep == r.pRep)
                return *this;
            SharedPtr<T> tmp(r);
            swap(tmp);
            return *this;
        }
        virtual ~SharedPtr() {
            release();
        }
        inline T& operator*() const { assert(pRep); return *pRep; }
        inline T* operator->() const { assert(pRep); return pRep; }
                //鍦ㄧ敤鐨勬椂鍊欐鏌Rep鐨勫悎娉曟?br>        inline T* get() const { return pRep; }
        void bind(T* rep) {
            assert(!pRep && !pUseCount);
            OGRE_NEW_AUTO_SHARED_MUTEX
            OGRE_LOCK_AUTO_SHARED_MUTEX
            pUseCount = new unsigned int(1);
            pRep = rep;
        }
        inline bool unique() const { OGRE_LOCK_AUTO_SHARED_MUTEX assert(pUseCount); return *pUseCount == 1; }
        inline unsigned int useCount() const { OGRE_LOCK_AUTO_SHARED_MUTEX assert(pUseCount); return *pUseCount; }
        inline unsigned int* useCountPointer() const { return pUseCount; }
        inline T* getPointer() const { return pRep; }
        inline bool isNull(void) const { return pRep == 0; }
        inline void setNull(void) {
            if (pRep)
            {
                // can't scope lock mutex before release incase deleted
                release();
                pRep = 0;
                pUseCount = 0;
            }
        }

    protected:

        inline void release(void)
        {
            bool destroyThis = false;
            OGRE_MUTEX_CONDITIONAL(OGRE_AUTO_MUTEX_NAME)
            {
                OGRE_LOCK_AUTO_SHARED_MUTEX
                if (pUseCount)
                {
                    if (--(*pUseCount) == 0)
                    {
                        destroyThis = true;
                    }
                }
            }
            if (destroyThis)
                destroy();

            OGRE_SET_AUTO_SHARED_MUTEX_NULL
        }

        virtual void destroy(void)
        {
            delete pRep;
            delete pUseCount;
            OGRE_DELETE_AUTO_SHARED_MUTEX
        }

        virtual void swap(SharedPtr<T> &other)
        {
            std::swap(pRep, other.pRep);
            std::swap(pUseCount, other.pUseCount);
#if OGRE_THREAD_SUPPORT
            std::swap(OGRE_AUTO_MUTEX_NAME, other.OGRE_AUTO_MUTEX_NAME);
#endif
        }
    };

    template<class T, class U> inline bool operator==(SharedPtr<T> const& a, SharedPtr<U> const& b)
    {
        return a.get() == b.get();
    }

    template<class T, class U> inline bool operator!=(SharedPtr<T> const& a, SharedPtr<U> const& b)
    {
        return a.get() != b.get();
    }
}
#endif
鏈鍚庢湁娉ㄦ剰鍒幫細(xì)
    inline T* get() const { return pRep; }
    inline T* getPointer() const { return pRep; }
涓嶇煡閬撲負(fù)鍟ヨ榪欐牱錛屾湁涓涓笉灝辮浜?jiǎn)涔堛?br>鏇村鐨勭粏鑺傘佷嬌鐢ㄦ柟娉曟斁鍒頒笅嬈℃妸銆?br>

]]>
久久精品国产亚洲沈樵| 久久久久久极精品久久久 | 97超级碰碰碰碰久久久久| 久久99精品久久久久久秒播 | 国产激情久久久久久熟女老人| 99久久免费国产精品| 国产午夜福利精品久久| 久久九九久精品国产| 久久这里都是精品| 99久久精品午夜一区二区| 久久久精品久久久久久 | 亚洲中文久久精品无码ww16 | 久久综合丝袜日本网| 国产99久久久国产精品小说| 久久se这里只有精品| 国内精品九九久久精品| 青青热久久综合网伊人| 亚洲av日韩精品久久久久久a| 国产精品久久久久9999| 国产精品久久久香蕉| 久久免费国产精品一区二区| 久久人人爽人人爽人人av东京热| 亚洲国产精品久久久久网站| 久久亚洲私人国产精品| 国产A三级久久精品| 亚洲综合熟女久久久30p| 无码专区久久综合久中文字幕 | 久久精品人人做人人妻人人玩| 亚洲精品高清一二区久久| 天天爽天天爽天天片a久久网| 久久99精品久久久久子伦| 久久精品国产亚洲AV蜜臀色欲| 国色天香久久久久久久小说 | 久久精品亚洲一区二区三区浴池 | 国产V亚洲V天堂无码久久久| 国内精品久久久久影院优 | 久久免费视频网站| 久久精品成人欧美大片| 国产免费久久久久久无码| 久久久免费观成人影院| 久久夜色精品国产噜噜亚洲a|