00001
00002
00003
00004
00005 #include "ace/Guard_T.h"
00006 #include "ace/Log_Msg.h"
00007
00008 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00009
00010 template <class X> ACE_INLINE
00011 ACE_Intrusive_Auto_Ptr<X>::ACE_Intrusive_Auto_Ptr (X *p, bool addref)
00012 : rep_ (p)
00013 {
00014 if (rep_ != 0 && addref)
00015 X::intrusive_add_ref (rep_);
00016 }
00017
00018 template <class X> ACE_INLINE
00019 ACE_Intrusive_Auto_Ptr<X>::ACE_Intrusive_Auto_Ptr (const ACE_Intrusive_Auto_Ptr<X> &r)
00020 : rep_ (r.rep_)
00021 {
00022 if (rep_ != 0)
00023 X::intrusive_add_ref (rep_);
00024 }
00025
00026 template <class X> ACE_INLINE X *
00027 ACE_Intrusive_Auto_Ptr<X>::operator-> (void) const
00028 {
00029 return this->rep_;
00030 }
00031
00032 template<class X> ACE_INLINE X &
00033 ACE_Intrusive_Auto_Ptr<X>::operator *() const
00034 {
00035 return *this->rep_;
00036 }
00037
00038 template <class X> ACE_INLINE X*
00039 ACE_Intrusive_Auto_Ptr<X>::get (void) const
00040 {
00041
00042 return this->rep_;
00043 }
00044
00045 template<class X> ACE_INLINE X *
00046 ACE_Intrusive_Auto_Ptr<X>::release (void)
00047 {
00048 X *p = this->rep_;
00049 if (this->rep_ != 0)
00050 X::intrusive_remove_ref (this->rep_);
00051
00052 this->rep_ = 0;
00053 return p;
00054 }
00055
00056 template<class X> ACE_INLINE void
00057 ACE_Intrusive_Auto_Ptr<X>::reset (X *p)
00058 {
00059
00060
00061 if (this->rep_ == p)
00062 return;
00063
00064 X *old_rep = this->rep_;
00065 this->rep_ = p;
00066
00067 if (this->rep_ != 0)
00068 X::intrusive_add_ref (this->rep_);
00069
00070 if (old_rep != 0)
00071 X::intrusive_remove_ref (old_rep);
00072
00073 return;
00074 }
00075
00076 template <class X> ACE_INLINE void
00077 ACE_Intrusive_Auto_Ptr<X>::operator = (const ACE_Intrusive_Auto_Ptr<X> &rhs)
00078 {
00079
00080 if (this->rep_ == rhs.rep_)
00081 return;
00082
00083
00084 if (rhs.rep_ == 0)
00085 {
00086 X::intrusive_remove_ref (rhs.rep_);
00087 this->rep_ = 0;
00088 return;
00089 }
00090
00091
00092 X *old_rep = this->rep_;
00093 this->rep_ = rhs.rep_;
00094 X::intrusive_add_ref (this->rep_);
00095 X::intrusive_remove_ref (old_rep);
00096 }
00097
00098
00099 template<class X> template <class U> ACE_INLINE
00100 ACE_Intrusive_Auto_Ptr<X>::ACE_Intrusive_Auto_Ptr (const ACE_Intrusive_Auto_Ptr<U> & rhs)
00101 {
00102
00103
00104 this->rep_ = rhs.operator-> ();
00105 X::intrusive_add_ref(this->rep_);
00106 }
00107
00108
00109
00110
00111
00112
00113
00114
00115 template<class T, class U> ACE_INLINE bool operator==(ACE_Intrusive_Auto_Ptr<T> const & a, ACE_Intrusive_Auto_Ptr<U> const & b)
00116 {
00117 return a.get() == b.get();
00118 }
00119
00120
00121 template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> const & a, ACE_Intrusive_Auto_Ptr<U> const & b)
00122 {
00123 return a.get() != b.get();
00124 }
00125
00126 template<class T, class U> ACE_INLINE bool operator==(ACE_Intrusive_Auto_Ptr<T> const & a, U * b)
00127 {
00128 return a.get() == b;
00129 }
00130
00131 template<class T, class U> ACE_INLINE bool operator!=(ACE_Intrusive_Auto_Ptr<T> & a, U * b)
00132 {
00133 return a.get() != b;
00134 }
00135
00136 template<class T, class U> ACE_INLINE bool operator==(T * a, ACE_Intrusive_Auto_Ptr<U> const & b)
00137 {
00138 return a == b.get();
00139 }
00140
00141 template<class T, class U> ACE_INLINE bool operator!=(T * a, ACE_Intrusive_Auto_Ptr<U> const & b)
00142 {
00143 return a != b.get();
00144 }
00145
00146
00147 ACE_END_VERSIONED_NAMESPACE_DECL