summaryrefslogtreecommitdiff
path: root/trunk/TAO/orbsvcs/orbsvcs/Notify/Refcountable_Guard_T.inl
blob: 4ab55e0b75f37f9745464562481b5b20adf74085 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// -*- C++ -*-
//
// $Id$

#include "ace/Log_Msg.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

template <class T> ACE_INLINE
TAO_Notify_Refcountable_Guard_T<T>::TAO_Notify_Refcountable_Guard_T (T *t)
  : t_ (t)
{
  if ( this->t_ != static_cast< T* >( 0 ) ) this->t_->_incr_refcnt();
}

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_ != static_cast< 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_ != static_cast< T* >( 0 ) ) this->t_->_decr_refcnt();
}

template <class T> ACE_INLINE
T*
TAO_Notify_Refcountable_Guard_T<T>::get (void) const
{
  return this->t_;
}

template <class T> ACE_INLINE
bool
TAO_Notify_Refcountable_Guard_T<T>::isSet (void) const
{
  return ( this->t_ != static_cast< T* >( 0 ) );
}


template <class T> ACE_INLINE
T*
TAO_Notify_Refcountable_Guard_T<T>::operator-> (void) const
{
  ACE_ASSERT ( this->t_ != static_cast< T* >( 0 ) );
  return this->t_;
}

template <class T> ACE_INLINE
T&
TAO_Notify_Refcountable_Guard_T<T>::operator* (void) const
{
  ACE_ASSERT ( this->t_ != static_cast< 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)
{
  reset( rhs.t_ );
  return *this;
}


template <class T> ACE_INLINE
void
TAO_Notify_Refcountable_Guard_T<T>::reset (T* t)
{
  if (this->t_ != t)
  {
    TAO_Notify_Refcountable_Guard_T<T> temp( t );
    swap( temp );
  }
}

template <class T> ACE_INLINE
void
TAO_Notify_Refcountable_Guard_T<T>::swap(
  TAO_Notify_Refcountable_Guard_T<T>& rhs )
{
  T* temp = this->t_;
  this->t_ = rhs.t_;
  rhs.t_ = temp;
}

TAO_END_VERSIONED_NAMESPACE_DECL