diff options
-rw-r--r-- | TAO/ChangeLog_pnotify | 6 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.h | 10 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl | 33 |
3 files changed, 48 insertions, 1 deletions
diff --git a/TAO/ChangeLog_pnotify b/TAO/ChangeLog_pnotify index 6583ba3a56d..b350b03ef87 100644 --- a/TAO/ChangeLog_pnotify +++ b/TAO/ChangeLog_pnotify @@ -1,3 +1,9 @@ +Wed Oct 20 11:38:11 2004 Dale Wilson <wilson_d@ociweb.com> + + * orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.h: + * orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl: + Add copy constructor and operator =. + Tue Oct 19 10:43:28 2004 Dale Wilson <wilson_d@ociweb.com> * orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_T.h: diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.h b/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.h index 1354378dc62..77d1e2a5db1 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.h @@ -33,6 +33,9 @@ public: /// Constuctor TAO_Notify_Refcountable_Guard_T (T* t = 0); + /// Copy constructor + TAO_Notify_Refcountable_Guard_T (const TAO_Notify_Refcountable_Guard_T<T> & rhs); + /// Destructor ~TAO_Notify_Refcountable_Guard_T (); @@ -44,6 +47,13 @@ public: T &operator *() const; + TAO_Notify_Refcountable_Guard_T<T> & operator = ( + const TAO_Notify_Refcountable_Guard_T<T> & rhs); + +private: + /// helper for exception safeness + /// @throws nothing + void swap (TAO_Notify_Refcountable_Guard_T & rhs); private: T* t_; }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl index 2dedf719c60..21f9b81ce7d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl @@ -11,6 +11,16 @@ TAO_Notify_Refcountable_Guard_T<T>::TAO_Notify_Refcountable_Guard_T (T *t) } template <class T> ACE_INLINE +TAO_Notify_Refcountable_Guard_T<T>::TAO_Notify_Refcountable_Guard_T (const TAO_Notify_Refcountable_Guard_T<T> &rhs) + : t_ (rhs.t_) +{ + if (this->t_ != 0) + { + this->t_->_incr_refcnt (); + } +} + +template <class T> ACE_INLINE TAO_Notify_Refcountable_Guard_T<T>::~TAO_Notify_Refcountable_Guard_T () { if (this->t_ != 0) @@ -32,9 +42,30 @@ TAO_Notify_Refcountable_Guard_T<T>::operator-> (void) const return this->t_; } -template <class T> ACE_INLINE T& +template <class T> ACE_INLINE +T& TAO_Notify_Refcountable_Guard_T<T>::operator *(void) const { ACE_ASSERT (this->t_ != 0); return *this->t_; } + +template <class T> ACE_INLINE +TAO_Notify_Refcountable_Guard_T<T> & +TAO_Notify_Refcountable_Guard_T<T>::operator = ( + const TAO_Notify_Refcountable_Guard_T<T> & rhs) +{ + // note exception safe assignment. see Sutter's "Exceptional C++" + swap (TAO_Notify_Refcountable_Guard_T<T> (rhs.t_)); + return *this; +} + + +template <class T> ACE_INLINE +void +TAO_Notify_Refcountable_Guard_T<T>::swap (TAO_Notify_Refcountable_Guard_T & rhs) +{ + T* pt = rhs.t_; + rhs.t_ = this->t_; + this->t_ = rhs.t_; +} |