summaryrefslogtreecommitdiff
path: root/TAO/tao/varout.cpp
blob: 12301958a2398d07f9060d6edd46ae99c4ad678a (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* -*- C++ -*- */
// $Id$

// ============================================================================
//
// = LIBRARY
//    TAO
//
// = FILENAME
//    varout.cpp
//
// = DESCRIPTION
//     Templates for _var and _out types
//
// = AUTHOR
//
//   Aniruddha Gokhale
//   Carlos O'Ryan
// ============================================================================

#if !defined (TAO_VAROUT_C)
#define TAO_VAROUT_C

#include "tao/varout.h"
#include "tao/Sequence.h"

#if !defined (__ACE_INLINE__)
#include "tao/varout.i"
#endif /* __ACE_INLINE__ */

ACE_RCSID(tao, varout, "$Id$")

template<class T, class T_var>
TAO_Object_Field_T<T,T_var>::
    TAO_Object_Field_T (const TAO_Object_Field_T<T,T_var>& rhs)
  :  TAO_Object_Field (rhs), // keep HP/aCC happy
     ptr_ (T::_duplicate (rhs.ptr_))
{
}

template<class T, class T_var>
TAO_Object_Field_T<T,T_var>::~TAO_Object_Field_T (void)
{
  CORBA::release (this->ptr_);
}

template<class T, class T_var> TAO_Object_Field_T<T,T_var> &
TAO_Object_Field_T<T,T_var>::operator= (T* object)
{
  CORBA::release (this->ptr_);
  this->ptr_ = object;
  return *this;
}

template<class T, class T_var> TAO_Object_Field_T<T,T_var> &
TAO_Object_Field_T<T,T_var>::
    operator= (const TAO_Object_Field_T<T,T_var> &rhs)
{
  if (this != &rhs)
    {
      CORBA::release (this->ptr_);
      this->ptr_ = T::_duplicate (rhs.ptr_);
    }
  return *this;
}

template<class T, class T_var>
TAO_Object_Field_T<T,T_var>::
    TAO_Object_Field_T (const TAO_Object_Manager<T,T_var> & rhs)
  : ptr_ (T::_duplicate (rhs.in ()))
{
}

template<class T, class T_var> TAO_Object_Field_T<T,T_var>&
TAO_Object_Field_T<T,T_var>::
    operator= (const TAO_Object_Manager<T,T_var> & rhs)
{
  T* tmp = T::_duplicate (rhs.in ());
  CORBA::release (this->ptr_);
  this->ptr_ = tmp;

  return *this;
}

template<class T, class T_var>
TAO_Object_Field_T<T,T_var>::
    TAO_Object_Field_T (const T_var & rhs)
  : ptr_ (T::_duplicate (rhs.in ()))
{
}

template<class T, class T_var> TAO_Object_Field_T<T,T_var>&
TAO_Object_Field_T<T,T_var>::
    operator= (const T_var & rhs)
{
  T* tmp = T::_duplicate (rhs.in ());
  CORBA::release (this->ptr_);
  this->ptr_ = tmp;

  return *this;
}

template<class T, class T_var> void
TAO_Object_Field_T<T,T_var>::_downcast (CORBA_Object* base_ptr,
                                        CORBA_Environment &ACE_TRY_ENV)
{
  CORBA::release (this->ptr_);
  this->ptr_ = 0;
  this->ptr_ = T::_narrow (base_ptr, ACE_TRY_ENV);
}

template<class T, class T_var> CORBA_Object*
TAO_Object_Field_T<T,T_var>::_upcast (void)
{
  return this->ptr_;
}

template<class T, class T_var> void
TAO_Object_Field_T<T,T_var>::_release (void)
{
  CORBA::release (this->ptr_);
  this->ptr_ = 0;
}

template<class T, class T_var> T* &
TAO_Object_Field_T<T,T_var>::out (void)
{
  CORBA::release (this->ptr_);
  this->ptr_ = 0;
  return this->ptr_;
}

#endif /* TAO_VAROUT_C */