// -*- C++ -*- #include "ace/Guard_T.h" #include "ace/Log_Category.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL template inline long ACE_Refcounted_Auto_Ptr_Rep::count () const { return this->ref_count_.value(); } template inline long ACE_Refcounted_Auto_Ptr::count () const { return this->rep_->count (); } template inline bool ACE_Refcounted_Auto_Ptr::null () const { return (this->rep_ == 0 || this->rep_->get () == 0); } template inline ACE_Refcounted_Auto_Ptr_Rep * ACE_Refcounted_Auto_Ptr_Rep::internal_create (X *p) { ACE_Refcounted_Auto_Ptr_Rep *temp = 0; ACE_NEW_RETURN (temp, (ACE_Refcounted_Auto_Ptr_Rep) (p), 0); return temp; } template inline ACE_Refcounted_Auto_Ptr_Rep * ACE_Refcounted_Auto_Ptr_Rep::create (X *p) { // Yes set ref count to zero. ACE_Refcounted_Auto_Ptr_Rep *temp = internal_create (p); if (!temp) throw std::bad_alloc (); return temp; } template inline ACE_Refcounted_Auto_Ptr_Rep * ACE_Refcounted_Auto_Ptr_Rep::attach (ACE_Refcounted_Auto_Ptr_Rep*& rep) { if (rep == 0) return 0; ++rep->ref_count_; return rep; } template inline void ACE_Refcounted_Auto_Ptr_Rep::detach (ACE_Refcounted_Auto_Ptr_Rep*& rep) { if (rep == 0) return; if (rep->ref_count_-- == 0) delete rep; } template inline ACE_Refcounted_Auto_Ptr_Rep::ACE_Refcounted_Auto_Ptr_Rep (X *p) : ptr_ (p), ref_count_ (0) { } template inline ACE_Refcounted_Auto_Ptr_Rep::~ACE_Refcounted_Auto_Ptr_Rep () { } template inline X * ACE_Refcounted_Auto_Ptr_Rep::get () const { return this->ptr_.get (); } template inline ACE_Refcounted_Auto_Ptr::ACE_Refcounted_Auto_Ptr (X *p) : rep_ (AUTO_REFCOUNTED_PTR_REP::create (p)) { } template inline ACE_Refcounted_Auto_Ptr::ACE_Refcounted_Auto_Ptr (const ACE_Refcounted_Auto_Ptr &r) : rep_ (AUTO_REFCOUNTED_PTR_REP::attach (((ACE_Refcounted_Auto_Ptr &) r).rep_)) { } template inline bool ACE_Refcounted_Auto_Ptr::operator== (const ACE_Refcounted_Auto_Ptr &r) const { return r.rep_ == this->rep_; } template inline bool ACE_Refcounted_Auto_Ptr::operator!= (const ACE_Refcounted_Auto_Ptr &r) const { return r.rep_ != this->rep_; } template inline X * ACE_Refcounted_Auto_Ptr::operator-> () const { return this->rep_->get(); } template inline X & ACE_Refcounted_Auto_Ptr::operator *() const { return *this->rep_->get (); } template inline bool ACE_Refcounted_Auto_Ptr::operator !() const { return this->rep_->get () == 0; } template inline ACE_Refcounted_Auto_Ptr::operator unspecified_bool_type () const { return this->rep_->get () != 0 ? unspecified_bool : 0; } template inline X* ACE_Refcounted_Auto_Ptr::get () const { // We return the ACE_Future_rep. return this->rep_->get (); } template inline X * ACE_Refcounted_Auto_Ptr::release () { X *p = this->get (); AUTO_REFCOUNTED_PTR_REP::detach (this->rep_); this->rep_ = 0; return p; } template inline void ACE_Refcounted_Auto_Ptr::reset (X *p) { // Avoid deleting the underlying auto_ptr if assigning the same actual // pointer value. if (this->get () == p) return; AUTO_REFCOUNTED_PTR_REP *old_rep = this->rep_; if ((this->rep_ = AUTO_REFCOUNTED_PTR_REP::create (p)) != 0) AUTO_REFCOUNTED_PTR_REP::detach (old_rep); else this->rep_ = old_rep; return; } template inline void ACE_Refcounted_Auto_Ptr::operator = (const ACE_Refcounted_Auto_Ptr &rhs) { // bind to the same as . AUTO_REFCOUNTED_PTR_REP *old_rep = this->rep_; if (rhs.rep_ != 0) { this->rep_ = AUTO_REFCOUNTED_PTR_REP::attach (const_cast& > (rhs).rep_); if (this->rep_ != 0) AUTO_REFCOUNTED_PTR_REP::detach (old_rep); } else // Assign a 0 rep to this { AUTO_REFCOUNTED_PTR_REP::detach (old_rep); this->rep_ = 0; } } ACE_END_VERSIONED_NAMESPACE_DECL