23 #ifndef __SharedPtrImpl_hh__
24 #define __SharedPtrImpl_hh__
26 #include <Base/Debug/Exception.hh>
27 #include <Base/Common/Constraints.hh>
40 {
return (t.Data_)?(t.Data_->Ptr):(0); }
47 {
return (t.Data_)?(t.Data_->Ptr):(0); }
54 {
return (t.Data_)?(t.Data_->Counter):(0u); }
59 template <
class T,
class U>
69 template <
class T,
class U>
143 BIASERR(
"Trying to reference a null pointer");
145 BEXCEPTION(
"Trying to reference a null pointer");
147 BIASASSERT(Data_->Ptr);
148 return *(Data_->Ptr);
155 BIASERR(
"Trying to access a null pointer");
157 BEXCEPTION(
"Trying to access a null pointer");
159 BIASASSERT(Data_->Ptr);
179 if (Data_ == 0)
return 0;
192 return (
Get(*
this) ==
Get(rs));
199 return (
Get(*
this) !=
Get(rs));
210 return (
Get(*
this) <
Get(rs));
216 return (
Get(*
this) <=
Get(rs));
222 return (
Get(*
this) >
Get(rs));
228 return (
Get(*
this) >=
Get(rs));
239 T *tmp =
dynamic_cast<T *
>(
Get(rs));
253 T *tmp =
const_cast<T *
>(
Get(rs));
269 std::ostream& operator<<(std::ostream& os, const SharedPtr<T>& t)
282 void operator delete(
void *) {};
289 BIASASSERT(Data_->Ptr);
296 void SharedPtr<T>::Decrement_()
299 BIASASSERT(Data_->Counter>0);
300 BIASASSERT(Data_->Ptr);
302 if (Data_->Counter==0){
320 #endif // __SharedPtrImpl_hh__
bool operator<=(const SharedPtr< U > &rs) const
T * Get(SharedPtr< T > &t)
compile time check if B is (grand)father of T Found it in Bjarne Stroustrup's FAQ: http://public...
bool operator<(const SharedPtr< U > &rs) const
ordering
bool operator!=(const SharedPtr< U > &rs) const
pointer with reference count and automatic deletion
bool operator!() const
enable the expression "if (!ptr)"
bool operator==(const SharedPtr< U > &rs) const
comparisons
T * Get(SharedPtr< T > &t)
access function to the raw pointer
SharedPtr< T > & operator=(const SharedPtr< T > &sp)
SharedPtr< T > DynamicCast(const SharedPtr< U > &src)
DynamicCast function.
SharedPtr< T > ConstCast(const SharedPtr< U > &src)
DynamicCast function.
SharedPtr< T > ConstCast(const SharedPtr< U > &rs)
eqivalent to *this = const_cast<SharedPtr<T> >(rs)
SharedPtr< T > DynamicCast(const SharedPtr< U > &rs)
eqivalent to *this = dynamic_cast<SharedPtr<T> >(rs)
bool operator>=(const SharedPtr< U > &rs) const
bool operator>(const SharedPtr< U > &rs) const
T *const Get(const SharedPtr< T > &t)
access function to the raw pointer
unsigned RefCount(const SharedPtr< T > &t)
access function to the reference count
pool ptr to the data and the reference count