diff options
Diffstat (limited to 'cpp/include/IceUtil/Handle.h')
-rw-r--r-- | cpp/include/IceUtil/Handle.h | 184 |
1 files changed, 92 insertions, 92 deletions
diff --git a/cpp/include/IceUtil/Handle.h b/cpp/include/IceUtil/Handle.h index c20616ec21f..0f48e2ee71b 100644 --- a/cpp/include/IceUtil/Handle.h +++ b/cpp/include/IceUtil/Handle.h @@ -29,13 +29,13 @@ public: T* get() const { - return _ptr; + return _ptr; } T* operator->() const { - if(!_ptr) - { + if(!_ptr) + { // // We don't throw directly NullHandleException here to // keep the code size of this method to a minimun (the @@ -43,16 +43,16 @@ public: // than just a function call). This maximises the chances // of inlining by compiler optimization. // - throwNullHandleException(__FILE__, __LINE__); - } + throwNullHandleException(__FILE__, __LINE__); + } - return _ptr; + return _ptr; } T& operator*() const { - if(!_ptr) - { + if(!_ptr) + { // // We don't throw directly NullHandleException here to // keep the code size of this method to a minimun (the @@ -60,20 +60,20 @@ public: // than just a function call). This maximises the chances // of inlining by compiler optimization. // - throwNullHandleException(__FILE__, __LINE__); - } + throwNullHandleException(__FILE__, __LINE__); + } - return *_ptr; + return *_ptr; } operator bool() const { - return _ptr ? true : false; + return _ptr ? true : false; } void swap(HandleBase& other) { - std::swap(_ptr, other._ptr); + std::swap(_ptr, other._ptr); } T* _ptr; @@ -96,12 +96,12 @@ inline bool operator==(const HandleBase<T>& lhs, const HandleBase<U>& rhs) U* r = rhs.get(); if(l && r) { - return *l == *r; + return *l == *r; } else { - return !l && !r; - } + return !l && !r; + } } template<typename T, typename U> @@ -111,12 +111,12 @@ inline bool operator!=(const HandleBase<T>& lhs, const HandleBase<U>& rhs) U* r = rhs.get(); if(l && r) { - return *l != *r; + return *l != *r; } else { - return l || r; - } + return l || r; + } } template<typename T, typename U> @@ -126,11 +126,11 @@ inline bool operator<(const HandleBase<T>& lhs, const HandleBase<U>& rhs) U* r = rhs.get(); if(l && r) { - return *l < *r; + return *l < *r; } else { - return !l && r; + return !l && r; } } @@ -141,111 +141,111 @@ public: Handle(T* p = 0) { - this->_ptr = p; + this->_ptr = p; - if(this->_ptr) - { - this->_ptr->__incRef(); - } + if(this->_ptr) + { + this->_ptr->__incRef(); + } } template<typename Y> Handle(const Handle<Y>& r) { - this->_ptr = r._ptr; + this->_ptr = r._ptr; - if(this->_ptr) - { - this->_ptr->__incRef(); - } + if(this->_ptr) + { + this->_ptr->__incRef(); + } } Handle(const Handle& r) { - this->_ptr = r._ptr; + this->_ptr = r._ptr; - if(this->_ptr) - { - this->_ptr->__incRef(); - } + if(this->_ptr) + { + this->_ptr->__incRef(); + } } ~Handle() { - if(this->_ptr) - { - this->_ptr->__decRef(); - } + if(this->_ptr) + { + this->_ptr->__decRef(); + } } Handle& operator=(T* p) { - if(this->_ptr != p) - { - if(p) - { - p->__incRef(); - } - - T* ptr = this->_ptr; - this->_ptr = p; - - if(ptr) - { - ptr->__decRef(); - } - } - return *this; + if(this->_ptr != p) + { + if(p) + { + p->__incRef(); + } + + T* ptr = this->_ptr; + this->_ptr = p; + + if(ptr) + { + ptr->__decRef(); + } + } + return *this; } template<typename Y> Handle& operator=(const Handle<Y>& r) { - if(this->_ptr != r._ptr) - { - if(r._ptr) - { - r._ptr->__incRef(); - } - - T* ptr = this->_ptr; - this->_ptr = r._ptr; - - if(ptr) - { - ptr->__decRef(); - } - } - return *this; + if(this->_ptr != r._ptr) + { + if(r._ptr) + { + r._ptr->__incRef(); + } + + T* ptr = this->_ptr; + this->_ptr = r._ptr; + + if(ptr) + { + ptr->__decRef(); + } + } + return *this; } Handle& operator=(const Handle& r) { - if(this->_ptr != r._ptr) - { - if(r._ptr) - { - r._ptr->__incRef(); - } - - T* ptr = this->_ptr; - this->_ptr = r._ptr; - - if(ptr) - { - ptr->__decRef(); - } - } - return *this; + if(this->_ptr != r._ptr) + { + if(r._ptr) + { + r._ptr->__incRef(); + } + + T* ptr = this->_ptr; + this->_ptr = r._ptr; + + if(ptr) + { + ptr->__decRef(); + } + } + return *this; } template<class Y> static Handle dynamicCast(const HandleBase<Y>& r) { #ifdef __BCPLUSPLUS__ - return Handle<T>(dynamic_cast<T*>(r._ptr)); + return Handle<T>(dynamic_cast<T*>(r._ptr)); #else - return Handle(dynamic_cast<T*>(r._ptr)); + return Handle(dynamic_cast<T*>(r._ptr)); #endif } @@ -253,9 +253,9 @@ public: static Handle dynamicCast(Y* p) { #ifdef __BCPLUSPLUS__ - return Handle<T>(dynamic_cast<T*>(p)); + return Handle<T>(dynamic_cast<T*>(p)); #else - return Handle(dynamic_cast<T*>(p)); + return Handle(dynamic_cast<T*>(p)); #endif } }; |