// -*- C++ -*- // // $Id$ #include TAO_BEGIN_VERSIONED_NAMESPACE_DECL template ACE_INLINE T * TAO::Utils::Servant_Var::_duplicate (T * p) { if (p != 0) { p->_add_ref (); } return p; } template ACE_INLINE void TAO::Utils::Servant_Var::swap (Servant_Var & rhs) throw () { std::swap (this->ptr_, rhs.ptr_); } template ACE_INLINE TAO::Utils::Servant_Var::Servant_Var (T * p) : ptr_ (p) { } // If _add_ref throws, this object will not be completely constructed // so the destructor will not be called. template ACE_INLINE TAO::Utils::Servant_Var::Servant_Var (Servant_Var const & rhs) : ptr_ (Servant_Var::_duplicate(rhs.ptr_)) { } template ACE_INLINE TAO::Utils::Servant_Var & TAO::Utils::Servant_Var::operator= (Servant_Var const & rhs) { TAO::Utils::Servant_Var tmp (rhs); this->swap (tmp); return *this; } template ACE_INLINE typename TAO::Utils::Servant_Var & TAO::Utils::Servant_Var::operator= (T * p) { if (this->ptr_ != p) { // This constructor doesn't increase the reference count so we // we must check for self-assignment. Otherwise the reference // count would be prematurely decremented upon exiting this // scope. TAO::Utils::Servant_Var tmp (p); this->swap (tmp); } return *this; } template ACE_INLINE TAO::Utils::Servant_Var::~Servant_Var (void) throw () { if (ptr_ != 0) { ptr_->_remove_ref (); } } #if !defined(ACE_LACKS_MEMBER_TEMPLATES) template template ACE_INLINE TAO::Utils::Servant_Var::Servant_Var (Y * p) : ptr_ (p) { } template template ACE_INLINE TAO::Utils::Servant_Var::Servant_Var (Servant_Var const & rhs) : ptr_ (Servant_Var::_duplicate (rhs.in ())) { } template template ACE_INLINE typename TAO::Utils::Servant_Var & TAO::Utils::Servant_Var:: operator=(Servant_Var const & rhs) { TAO::Utils::Servant_Var tmp (rhs); this->swap (tmp); return *this; } template template ACE_INLINE typename TAO::Utils::Servant_Var & TAO::Utils::Servant_Var::operator= (Y * p) { if (this->ptr_ != p) { // This constructor doesn't increase the reference count so we // we must check for self-assignment. Otherwise the reference // count would be prematurely decremented upon exiting this // scope. TAO::Utils::Servant_Var tmp (p); this->swap (tmp); } return *this; } #endif /* ACE_LACKS_MEMBER_TEMPLATES */ template ACE_INLINE T const * TAO::Utils::Servant_Var::operator->() const { return ptr_; } template ACE_INLINE T * TAO::Utils::Servant_Var::operator->() { return ptr_; } template ACE_INLINE T const & TAO::Utils::Servant_Var::operator*() const { return *ptr_; } template ACE_INLINE T & TAO::Utils::Servant_Var::operator*() { return *ptr_; } template ACE_INLINE TAO::Utils::Servant_Var::operator void const * () const { return ptr_; } template ACE_INLINE T * TAO::Utils::Servant_Var::in (void) const { return ptr_; } template ACE_INLINE T *& TAO::Utils::Servant_Var::inout (void) { return ptr_; } template ACE_INLINE T *& TAO::Utils::Servant_Var::out (void) { TAO::Utils::Servant_Var tmp; this->swap (tmp); return ptr_; } template ACE_INLINE T * TAO::Utils::Servant_Var::_retn (void) { T * rval = ptr_; ptr_ = 0; return rval; } #ifndef ACE_LACKS_MEMBER_TEMPLATES template ACE_INLINE bool operator== (typename TAO::Utils::Servant_Var const & x, typename TAO::Utils::Servant_Var const & y) { return x.in () == y.in (); } template ACE_INLINE bool operator!= (typename TAO::Utils::Servant_Var const & x, typename TAO::Utils::Servant_Var const & y) { return x.in () != y.in (); } #endif /* ! ACE_LACKS_MEMBER_TEMPLATES */ TAO_END_VERSIONED_NAMESPACE_DECL