From 913824e5e462f44dda679324c416776b05cecabb Mon Sep 17 00:00:00 2001 From: schmidt Date: Fri, 8 Dec 2000 16:48:57 +0000 Subject: ChangeLogTag:Fri Dec 8 10:34:32 2000 Douglas C. Schmidt --- ChangeLog | 11 +++ ChangeLogs/ChangeLog-02a | 11 +++ ChangeLogs/ChangeLog-03a | 11 +++ THANKS | 1 + ace/Auto_Ptr.h | 149 --------------------------------------- ace/Auto_Ptr.i | 164 ------------------------------------------- ace/Makefile | 1 + ace/QtReactor.h | 2 +- ace/Refcounted_Auto_Ptr.h | 174 ++++++++++++++++++++++++++++++++++++++++++++++ ace/Refcounted_Auto_Ptr.i | 170 ++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 380 insertions(+), 314 deletions(-) create mode 100644 ace/Refcounted_Auto_Ptr.h create mode 100644 ace/Refcounted_Auto_Ptr.i diff --git a/ChangeLog b/ChangeLog index acdcb45ac07..f48b59e7d3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Fri Dec 8 10:34:32 2000 Douglas C. Schmidt + + * ace/Makefile: Added Refcounted_Auto_Ptr to the list of template + files. + + * ace/Auto_Ptr.{h,i}: + * ace/Refcounted_Auto_Ptr.{h,i}: Moved the new + ACE_Refcounted_Auto_Ptr into a separate file to reduce + unnecessarily coupling in ACE. Thanks to Darrell Brunsch for + pointing this out. + Fri Dec 8 09:27:01 2000 Chad Elliott * include/makeinclude/platform_chorus4.x_g++.GNU: diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a index acdcb45ac07..f48b59e7d3c 100644 --- a/ChangeLogs/ChangeLog-02a +++ b/ChangeLogs/ChangeLog-02a @@ -1,3 +1,14 @@ +Fri Dec 8 10:34:32 2000 Douglas C. Schmidt + + * ace/Makefile: Added Refcounted_Auto_Ptr to the list of template + files. + + * ace/Auto_Ptr.{h,i}: + * ace/Refcounted_Auto_Ptr.{h,i}: Moved the new + ACE_Refcounted_Auto_Ptr into a separate file to reduce + unnecessarily coupling in ACE. Thanks to Darrell Brunsch for + pointing this out. + Fri Dec 8 09:27:01 2000 Chad Elliott * include/makeinclude/platform_chorus4.x_g++.GNU: diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index acdcb45ac07..f48b59e7d3c 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,14 @@ +Fri Dec 8 10:34:32 2000 Douglas C. Schmidt + + * ace/Makefile: Added Refcounted_Auto_Ptr to the list of template + files. + + * ace/Auto_Ptr.{h,i}: + * ace/Refcounted_Auto_Ptr.{h,i}: Moved the new + ACE_Refcounted_Auto_Ptr into a separate file to reduce + unnecessarily coupling in ACE. Thanks to Darrell Brunsch for + pointing this out. + Fri Dec 8 09:27:01 2000 Chad Elliott * include/makeinclude/platform_chorus4.x_g++.GNU: diff --git a/THANKS b/THANKS index b0e0a2f02b9..7a6a5336b22 100644 --- a/THANKS +++ b/THANKS @@ -1094,6 +1094,7 @@ Decamps Alain Jon Loeliger Ricardo Chan Sarabjeet Duhra +Sathish Tiptur Michael Rushton I would particularly like to thank Paul Stephenson, who worked with me diff --git a/ace/Auto_Ptr.h b/ace/Auto_Ptr.h index 32ceb251c03..aa7e0eec35d 100644 --- a/ace/Auto_Ptr.h +++ b/ace/Auto_Ptr.h @@ -8,13 +8,11 @@ * * @author Doug Schmidt * @author Irfan Pyarali - * @author John Tucker * @author Jack Reeves * @author Dr. Harald M. Mueller */ //============================================================================= - #ifndef ACE_AUTO_PTR_H #define ACE_AUTO_PTR_H #include "ace/pre.h" @@ -158,153 +156,6 @@ public: } while (0) # endif /* ACE_AUTO_PTR_LACKS_RESET */ -// Forward decl. -template class ACE_Refcounted_Auto_Ptr_Rep; -template class ACE_Refcounted_Auto_Ptr; - -/** - * @class ACE_Refcounted_Auto_Ptr - * - * @brief This class implements support for a reference counted auto_ptr. - * Assigning or copying instances of an ACE_Refcounted_Auto_Ptr - * will automatically increment the reference count. When the last - * instance that references a ACE_Refcounted_Auto_Ptr instance is - * destroyed or overwritten, it will invoke delete on its underlying - * pointer. - */ -template -class ACE_Refcounted_Auto_Ptr -{ -public: - - // = Initialization and termination methods. - - /// Constructor that initializes an to - /// point to the result immediately. - ACE_Refcounted_Auto_Ptr (X *p = 0); - - /// Copy constructor binds and to the same - /// . An - /// is created if necessary. - ACE_Refcounted_Auto_Ptr (const ACE_Refcounted_Auto_Ptr &r); - - /// Destructor. - ~ACE_Refcounted_Auto_Ptr (void); - - /// Assignment operator that binds and to the same - /// . An - /// is created if necessary. - void operator = (const ACE_Refcounted_Auto_Ptr &r); - - /// Equality operator that returns 1 if both - /// ACE_Refcounted_Auto_Ptr objects point to the same - /// ACE_Refcounted_Auto_Ptr_Rep object. Attention: It - /// also returns 1 if both objects have just been instantiated and - /// not used yet. - int operator == (const ACE_Refcounted_Auto_Ptr &r) const; - - /// Inequality operator, which is the opposite of equality. - int operator != (const ACE_Refcounted_Auto_Ptr &r) const; - - /// Redirection operator - X *operator-> (void) const; - - // = Accessor methods. - - X &operator *() const; - - /// Sets the pointer value to 0 and returns its old value. - X *release (void); - - /// Invokes delete on the previous pointer value and then sets the - /// pointer value to the specified value. - void reset (X *p = 0); - - /// Get the pointer value. - X *get (void); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - -private: - /// the ACE_Refcounted_Auto_Ptr_Rep - typedef ACE_Refcounted_Auto_Ptr_Rep AUTO_REFCOUNTED_PTR_REP; - - /// Protect operations on the . - AUTO_REFCOUNTED_PTR_REP *rep_; -}; - -/** - * @class ACE_Refcounted_Auto_Ptr_Rep - * - * @brief An ACE_Refcounted_Auto_Ptr_Rep object - * incapsulates a pointer to an object of type X. It is pointed to by - * ACE_Refcounted_Auto_Ptr object[s] and only accessible - * through them. - */ -template -class ACE_Refcounted_Auto_Ptr_Rep -{ -private: - friend class ACE_Refcounted_Auto_Ptr; - - /// Sets the pointer value to 0 and returns its old value. - X *release (void); - - /// Invokes delete on the previous pointer value and then - /// sets the pointer value to the specified value. - void reset (X *p = 0); - - /// Get the pointer value. - X *get (void); - - /// Declare the dynamic allocation hooks. - ACE_ALLOC_HOOK_DECLARE; - - // = Encapsulate reference count and object lifetime of instances. - // These methods must go after the others to work around a bug with - // Borland's C++ Builder... - - /// Create a ACE_Refcounted_Auto_Ptr_Rep and initialize - /// the reference count. - static ACE_Refcounted_Auto_Ptr_Rep *create (X *p); - - /// Increase the reference count and return argument. Uses the - /// attribute "ace_lock_" to synchronize reference count updating. - /// - /// Precondition (rep != 0). - static ACE_Refcounted_Auto_Ptr_Rep *attach (ACE_Refcounted_Auto_Ptr_Rep *&rep); - - /// Decreases the reference count and and deletes rep if there are no - /// more references to rep. - /// - /// Precondition (rep != 0) - static void detach (ACE_Refcounted_Auto_Ptr_Rep *&rep); - - /// Decreases the rep's reference count and and deletes rep if there - /// are no more references to rep. Then assigns new_rep to rep. - /// - /// Precondition (rep != 0 && new_rep != 0) - static void assign (ACE_Refcounted_Auto_Ptr_Rep *&rep, - ACE_Refcounted_Auto_Ptr_Rep *new_rep); - - /// Pointer to the result. - ACE_Auto_Basic_Ptr ptr_; - - /// Reference count. - int ref_count_; - - // = Mutex variable to protect the . - - /// Synchronization variable for the MT_SAFE . - ACE_LOCK lock_; - -private: - // = Constructor and destructor private. - ACE_Refcounted_Auto_Ptr_Rep (X *p = 0); - ~ACE_Refcounted_Auto_Ptr_Rep (void); -}; - #if defined (__ACE_INLINE__) #include "ace/Auto_Ptr.i" #endif /* __ACE_INLINE__ */ diff --git a/ace/Auto_Ptr.i b/ace/Auto_Ptr.i index 85f54bfc834..2dca307b97a 100644 --- a/ace/Auto_Ptr.i +++ b/ace/Auto_Ptr.i @@ -3,8 +3,6 @@ // Auto_Ptr.i -#include "Synch_T.h" - template ACE_INLINE ACE_Auto_Basic_Ptr::ACE_Auto_Basic_Ptr (ACE_Auto_Basic_Ptr &rhs) : p_ (rhs.release ()) @@ -144,165 +142,3 @@ ACE_Auto_Array_Ptr::operator->() const return this->get (); } -template ACE_INLINE ACE_Refcounted_Auto_Ptr_Rep * -ACE_Refcounted_Auto_Ptr_Rep::create (X *p) -{ - // Yes set ref count to zero. - return new ACE_Refcounted_Auto_Ptr_Rep (p); -} - -template ACE_INLINE ACE_Refcounted_Auto_Ptr_Rep * -ACE_Refcounted_Auto_Ptr_Rep::attach (ACE_Refcounted_Auto_Ptr_Rep*& rep) -{ - ACE_ASSERT (rep != 0); - - ACE_GUARD_RETURN (ACE_LOCK, guard, rep->lock_, rep); - - ++rep->ref_count_; - - return rep; -} - -template ACE_INLINE void -ACE_Refcounted_Auto_Ptr_Rep::detach (ACE_Refcounted_Auto_Ptr_Rep*& rep) -{ - ACE_ASSERT (rep != 0); - - ACE_GUARD (ACE_LOCK, guard, rep->lock_); - - if (rep->ref_count_-- == 0) - // We do not need the lock when deleting the representation. - // There should be no side effects from deleting rep and we don - // not want to release a deleted mutex. - delete rep; -} - -template ACE_INLINE void -ACE_Refcounted_Auto_Ptr_Rep::assign (ACE_Refcounted_Auto_Ptr_Rep*& rep, ACE_Refcounted_Auto_Ptr_Rep* new_rep) -{ - ACE_ASSERT (rep != 0); - ACE_ASSERT (new_rep != 0); - - ACE_GUARD (ACE_LOCK, guard, rep->lock_); - - ACE_Refcounted_Auto_Ptr_Rep *old = rep; - rep = new_rep; - - // detached old last for exception safety - if(old->ref_count_-- == 0) - // We do not need the lock when deleting the representation. - // There should be no side effects from deleting rep and we don - // not want to release a deleted mutex. - delete old; -} - -template ACE_INLINE -ACE_Refcounted_Auto_Ptr_Rep::ACE_Refcounted_Auto_Ptr_Rep (X *p) - : ptr_ (p), - ref_count_ (0) -{ -} - -template ACE_INLINE -ACE_Refcounted_Auto_Ptr_Rep::~ACE_Refcounted_Auto_Ptr_Rep (void) -{ -} - -template ACE_INLINE X * -ACE_Refcounted_Auto_Ptr_Rep::release (void) -{ - ACE_GUARD_RETURN (ACE_LOCK, guard, this->lock_, 0); - - return this->ptr_.release (); -} - -template ACE_INLINE void -ACE_Refcounted_Auto_Ptr_Rep::reset (X *p) -{ - ACE_GUARD (ACE_LOCK, guard, this->lock_); - - this->ptr_.reset (p); -} - -template X * -ACE_Refcounted_Auto_Ptr_Rep::get (void) -{ - ACE_GUARD_RETURN (ACE_LOCK, guard, this->lock_, 0); - - return this->ptr_.get (); -} - -template -ACE_Refcounted_Auto_Ptr::ACE_Refcounted_Auto_Ptr (X *p) - : rep_ (AUTO_REFCOUNTED_PTR_REP::create (p)) -{ -} - -template -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 -ACE_Refcounted_Auto_Ptr::~ACE_Refcounted_Auto_Ptr (void) -{ - AUTO_REFCOUNTED_PTR_REP::detach (rep_); -} - -template int -ACE_Refcounted_Auto_Ptr::operator== (const ACE_Refcounted_Auto_Ptr &r) const -{ - return r.rep_ == this->rep_; -} - -template int -ACE_Refcounted_Auto_Ptr::operator!= (const ACE_Refcounted_Auto_Ptr &r) const -{ - return r.rep_ != this->rep_; -} - -template X * -ACE_Refcounted_Auto_Ptr::operator-> (void) const -{ - return this->rep_->get(); -} - -template ACE_INLINE X & -ACE_Refcounted_Auto_Ptr::operator *() const -{ - return *this->rep_->get (); -} - -template X* -ACE_Refcounted_Auto_Ptr::get (void) -{ - // We return the ACE_Future_rep. - return this->rep_->get (); -} - -template ACE_INLINE X * -ACE_Refcounted_Auto_Ptr::release (void) -{ - return this->rep_->release (); -} - -template ACE_INLINE void -ACE_Refcounted_Auto_Ptr::reset (X *p) -{ - this->rep_->reset (p); -} - -template void -ACE_Refcounted_Auto_Ptr::operator = (const ACE_Refcounted_Auto_Ptr &rhs) -{ - // assignment: - // - // bind to the same as . - - // This will work if &r == this, by first increasing the ref count - ACE_Refcounted_Auto_Ptr &r = (ACE_Refcounted_Auto_Ptr &) rhs; - AUTO_REFCOUNTED_PTR_REP::assign (this->rep_, - AUTO_REFCOUNTED_PTR_REP::attach (r.rep_)); -} - diff --git a/ace/Makefile b/ace/Makefile index 7b3f817e844..76a2d99ab39 100644 --- a/ace/Makefile +++ b/ace/Makefile @@ -265,6 +265,7 @@ TEMPLATE_FILES = \ Message_Queue_T \ Module \ Pair_T \ + Refcounted_Auto_Ptr \ RB_Tree \ Select_Reactor_T \ Singleton \ diff --git a/ace/QtReactor.h b/ace/QtReactor.h index 2944a3b7069..7be109e6b4f 100644 --- a/ace/QtReactor.h +++ b/ace/QtReactor.h @@ -36,7 +36,7 @@ * * @brief An object-oriented event demultiplexor and event handler * dispatcher that uses the Qt Library. This class declaration - * also uses the extnsion facilities provided by the Qt. So, + * also uses the extension facilities provided by the Qt. So, * readers of the class declaration should not be upset with * the appearence of the Keywords like Q_OBJECT, private slots * etc. They are specific to Qt which uses these as a call back diff --git a/ace/Refcounted_Auto_Ptr.h b/ace/Refcounted_Auto_Ptr.h new file mode 100644 index 00000000000..a935dd38e20 --- /dev/null +++ b/ace/Refcounted_Auto_Ptr.h @@ -0,0 +1,174 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Refcounted_Auto_Ptr.h + * + * $Id$ + * + * @author John Tucker + */ +//============================================================================= + + +#ifndef ACE_REFCOUNTED_AUTO_PTR_H +#define ACE_REFCOUNTED_AUTO_PTR_H +#include "ace/pre.h" + +#include "ace/OS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +// Forward decl. +template class ACE_Refcounted_Auto_Ptr_Rep; +template class ACE_Refcounted_Auto_Ptr; + +/** + * @class ACE_Refcounted_Auto_Ptr + * + * @brief This class implements support for a reference counted auto_ptr. + * Assigning or copying instances of an ACE_Refcounted_Auto_Ptr + * will automatically increment the reference count. When the last + * instance that references a ACE_Refcounted_Auto_Ptr instance is + * destroyed or overwritten, it will invoke delete on its underlying + * pointer. + */ +template +class ACE_Refcounted_Auto_Ptr +{ +public: + + // = Initialization and termination methods. + + /// Constructor that initializes an to + /// point to the result immediately. + ACE_Refcounted_Auto_Ptr (X *p = 0); + + /// Copy constructor binds and to the same + /// . An + /// is created if necessary. + ACE_Refcounted_Auto_Ptr (const ACE_Refcounted_Auto_Ptr &r); + + /// Destructor. + ~ACE_Refcounted_Auto_Ptr (void); + + /// Assignment operator that binds and to the same + /// . An + /// is created if necessary. + void operator = (const ACE_Refcounted_Auto_Ptr &r); + + /// Equality operator that returns 1 if both + /// ACE_Refcounted_Auto_Ptr objects point to the same + /// ACE_Refcounted_Auto_Ptr_Rep object. Attention: It + /// also returns 1 if both objects have just been instantiated and + /// not used yet. + int operator == (const ACE_Refcounted_Auto_Ptr &r) const; + + /// Inequality operator, which is the opposite of equality. + int operator != (const ACE_Refcounted_Auto_Ptr &r) const; + + /// Redirection operator + X *operator-> (void) const; + + // = Accessor methods. + + X &operator *() const; + + /// Sets the pointer value to 0 and returns its old value. + X *release (void); + + /// Invokes delete on the previous pointer value and then sets the + /// pointer value to the specified value. + void reset (X *p = 0); + + /// Get the pointer value. + X *get (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + +private: + /// the ACE_Refcounted_Auto_Ptr_Rep + typedef ACE_Refcounted_Auto_Ptr_Rep AUTO_REFCOUNTED_PTR_REP; + + /// Protect operations on the . + AUTO_REFCOUNTED_PTR_REP *rep_; +}; + +/** + * @class ACE_Refcounted_Auto_Ptr_Rep + * + * @brief An ACE_Refcounted_Auto_Ptr_Rep object + * incapsulates a pointer to an object of type X. It is pointed to by + * ACE_Refcounted_Auto_Ptr object[s] and only accessible + * through them. + */ +template +class ACE_Refcounted_Auto_Ptr_Rep +{ +private: + friend class ACE_Refcounted_Auto_Ptr; + + /// Sets the pointer value to 0 and returns its old value. + X *release (void); + + /// Invokes delete on the previous pointer value and then + /// sets the pointer value to the specified value. + void reset (X *p = 0); + + /// Get the pointer value. + X *get (void); + + /// Declare the dynamic allocation hooks. + ACE_ALLOC_HOOK_DECLARE; + + // = Encapsulate reference count and object lifetime of instances. + // These methods must go after the others to work around a bug with + // Borland's C++ Builder... + + /// Create a ACE_Refcounted_Auto_Ptr_Rep and initialize + /// the reference count. + static ACE_Refcounted_Auto_Ptr_Rep *create (X *p); + + /// Increase the reference count and return argument. Uses the + /// attribute "ace_lock_" to synchronize reference count updating. + /// + /// Precondition (rep != 0). + static ACE_Refcounted_Auto_Ptr_Rep *attach (ACE_Refcounted_Auto_Ptr_Rep *&rep); + + /// Decreases the reference count and and deletes rep if there are no + /// more references to rep. + /// + /// Precondition (rep != 0) + static void detach (ACE_Refcounted_Auto_Ptr_Rep *&rep); + + /// Decreases the rep's reference count and and deletes rep if there + /// are no more references to rep. Then assigns new_rep to rep. + /// + /// Precondition (rep != 0 && new_rep != 0) + static void assign (ACE_Refcounted_Auto_Ptr_Rep *&rep, + ACE_Refcounted_Auto_Ptr_Rep *new_rep); + + /// Pointer to the result. + ACE_Auto_Basic_Ptr ptr_; + + /// Reference count. + int ref_count_; + + // = Mutex variable to protect the . + + /// Synchronization variable for the MT_SAFE . + ACE_LOCK lock_; + +private: + // = Constructor and destructor private. + ACE_Refcounted_Auto_Ptr_Rep (X *p = 0); + ~ACE_Refcounted_Auto_Ptr_Rep (void); +}; + +#include "ace/Refcounted_Auto_Ptr.i" + +#include "ace/post.h" +#endif /* ACE_AUTO_PTR_H */ diff --git a/ace/Refcounted_Auto_Ptr.i b/ace/Refcounted_Auto_Ptr.i new file mode 100644 index 00000000000..a712d373175 --- /dev/null +++ b/ace/Refcounted_Auto_Ptr.i @@ -0,0 +1,170 @@ +/* -*- C++ -*- */ +// $Id$ + +// Refcounted_Auto_Ptr.i + +#include "Synch_T.h" + +template inline ACE_Refcounted_Auto_Ptr_Rep * +ACE_Refcounted_Auto_Ptr_Rep::create (X *p) +{ + // Yes set ref count to zero. + return new ACE_Refcounted_Auto_Ptr_Rep (p); +} + +template inline ACE_Refcounted_Auto_Ptr_Rep * +ACE_Refcounted_Auto_Ptr_Rep::attach (ACE_Refcounted_Auto_Ptr_Rep*& rep) +{ + ACE_ASSERT (rep != 0); + + ACE_GUARD_RETURN (ACE_LOCK, guard, rep->lock_, rep); + + ++rep->ref_count_; + + return rep; +} + +template inline void +ACE_Refcounted_Auto_Ptr_Rep::detach (ACE_Refcounted_Auto_Ptr_Rep*& rep) +{ + ACE_ASSERT (rep != 0); + + ACE_GUARD (ACE_LOCK, guard, rep->lock_); + + if (rep->ref_count_-- == 0) + // We do not need the lock when deleting the representation. + // There should be no side effects from deleting rep and we don + // not want to release a deleted mutex. + delete rep; +} + +template inline void +ACE_Refcounted_Auto_Ptr_Rep::assign (ACE_Refcounted_Auto_Ptr_Rep*& rep, + ACE_Refcounted_Auto_Ptr_Rep* new_rep) +{ + ACE_ASSERT (rep != 0); + ACE_ASSERT (new_rep != 0); + + ACE_GUARD (ACE_LOCK, guard, rep->lock_); + + ACE_Refcounted_Auto_Ptr_Rep *old = rep; + rep = new_rep; + + // detached old last for exception safety + if(old->ref_count_-- == 0) + // We do not need the lock when deleting the representation. + // There should be no side effects from deleting rep and we don + // not want to release a deleted mutex. + delete old; +} + +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 (void) +{ +} + +template inline X * +ACE_Refcounted_Auto_Ptr_Rep::release (void) +{ + ACE_GUARD_RETURN (ACE_LOCK, guard, this->lock_, 0); + + return this->ptr_.release (); +} + +template inline void +ACE_Refcounted_Auto_Ptr_Rep::reset (X *p) +{ + ACE_GUARD (ACE_LOCK, guard, this->lock_); + + this->ptr_.reset (p); +} + +template inline X * +ACE_Refcounted_Auto_Ptr_Rep::get (void) +{ + ACE_GUARD_RETURN (ACE_LOCK, guard, this->lock_, 0); + + 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 +ACE_Refcounted_Auto_Ptr::~ACE_Refcounted_Auto_Ptr (void) +{ + AUTO_REFCOUNTED_PTR_REP::detach (rep_); +} + +template inline int +ACE_Refcounted_Auto_Ptr::operator== (const ACE_Refcounted_Auto_Ptr &r) const +{ + return r.rep_ == this->rep_; +} + +template inline int +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-> (void) const +{ + return this->rep_->get(); +} + +template inline X & +ACE_Refcounted_Auto_Ptr::operator *() const +{ + return *this->rep_->get (); +} + +template inline X* +ACE_Refcounted_Auto_Ptr::get (void) +{ + // We return the ACE_Future_rep. + return this->rep_->get (); +} + +template inline X * +ACE_Refcounted_Auto_Ptr::release (void) +{ + return this->rep_->release (); +} + +template inline void +ACE_Refcounted_Auto_Ptr::reset (X *p) +{ + this->rep_->reset (p); +} + +template inline void +ACE_Refcounted_Auto_Ptr::operator = (const ACE_Refcounted_Auto_Ptr &rhs) +{ + // assignment: + // + // bind to the same as . + + // This will work if &r == this, by first increasing the ref count + ACE_Refcounted_Auto_Ptr &r = (ACE_Refcounted_Auto_Ptr &) rhs; + AUTO_REFCOUNTED_PTR_REP::assign (this->rep_, + AUTO_REFCOUNTED_PTR_REP::attach (r.rep_)); +} + -- cgit v1.2.1