summaryrefslogtreecommitdiff
path: root/TAO/tao/PortableServer/Servant_var.cpp
blob: e5fca921aaa571b5d30e1dadd468580b5e2cee92 (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
// $Id$

#ifndef TAO_PORTABLESERVER_SERVANT_VAR_CPP
#define TAO_PORTABLESERVER_SERVANT_VAR_CPP

#include "tao/PortableServer/Servant_var.h"

#if !defined (__ACE_INLINE__)
# include "tao/PortableServer/Servant_var.inl"
#endif /* __ACE_INLINE__ */

#include "tao/Exception.h"
#include "tao/Environment.h"
#include "ace/CORBA_macros.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

template <class T>
T *
PortableServer::Servant_var<T>::_duplicate (T * p)
{
  ACE_DECLARE_NEW_CORBA_ENV;
  ACE_TRY
    {
      if (p != 0)
        {
          p->_add_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
          ACE_TRY_CHECK;
        }
    }
  ACE_CATCHALL
    {
      ACE_RE_THROW;
    }
  ACE_ENDTRY;
  ACE_CHECK_RETURN (0);

  return p;
}

template <class T>
PortableServer::Servant_var<T>::~Servant_var (void)  /* throw () */
{
  // Unfortunately, there is no throw spec on _remove_ref, so we
  // can't assume that it will not throw.  If it does, then we are in
  // trouble.  In any event, we can't let the exception escape our
  // destructor.
  ACE_TRY_NEW_ENV
    {
      if (this->ptr_ != 0)
        {
          this->ptr_->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER);
          ACE_TRY_CHECK;
        }
    }
  ACE_CATCHALL
    {
      // Forget the exception..
    }
  ACE_ENDTRY;
}

TAO_END_VERSIONED_NAMESPACE_DECL

#endif  /* TAO_PORTABLESERVER_SERVANT_VAR_CPP */