summaryrefslogtreecommitdiff
path: root/ACE/TAO/tao/Valuetype/Value_VarOut_T.cpp
blob: feb061920c7c39b4d144ccaeb97191c3fbe96c3c (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// $Id$

#ifndef TAO_VALUE_VAROUT_T_CPP
#define TAO_VALUE_VAROUT_T_CPP

#include "tao/Valuetype/Value_VarOut_T.h"
#include "tao/Valuetype/Value_CORBA_methods.h"

#include <algorithm>  /* For std::swap<>() */

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

template <typename T>
TAO_Value_Var_T<T>::TAO_Value_Var_T (void)
  : ptr_ (0)
{}

template <typename T>
TAO_Value_Var_T<T>::TAO_Value_Var_T (T * p)
  : ptr_ (p)
{}

template <typename T>
TAO_Value_Var_T<T>::TAO_Value_Var_T (const T * p)
  : ptr_ (const_cast<T *> (p))
{}

template <typename T>
TAO_Value_Var_T<T>::TAO_Value_Var_T (const TAO_Value_Var_T<T> & p)
  : TAO_Base_var ()
{
  TAO::Value_Traits<T>::add_ref (p.ptr ());
  this->ptr_ = p.ptr ();
}

template <typename T>
TAO_Value_Var_T<T>::~TAO_Value_Var_T (void)
{
  TAO::Value_Traits<T>::remove_ref (this->ptr_);
}

template <typename T>
TAO_Value_Var_T<T> &
TAO_Value_Var_T<T>::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_Value_Var_T<T> tmp (p);
      std::swap (this->ptr_, tmp.ptr_);
    }

  return *this;
}

template <typename T>
TAO_Value_Var_T<T> &
TAO_Value_Var_T<T>::operator= (const TAO_Value_Var_T<T> & p)
{
  TAO_Value_Var_T<T> tmp (p);
  std::swap (this->ptr_, tmp.ptr_);

  return *this;
}

template <typename T>
TAO_Value_Var_T<T>::operator const T * () const
{
  return this->ptr_;
}

template <typename T>
TAO_Value_Var_T<T>::operator T *& ()
{
  return this->ptr_;
}

template <typename T>
T *
TAO_Value_Var_T<T>::operator-> (void) const
{
  return this->ptr_;
}

template <typename T>
T *
TAO_Value_Var_T<T>::in (void) const
{
  return this->ptr_;
}

template <typename T>
T *&
TAO_Value_Var_T<T>::inout (void)
{
  return this->ptr_;
}

template <typename T>
T *&
TAO_Value_Var_T<T>::out (void)
{
  TAO::Value_Traits<T>::remove_ref (this->ptr_);
  this->ptr_ = 0;
  return this->ptr_;
}

template <typename T>
T *
TAO_Value_Var_T<T>::_retn (void)
{
  T * tmp = this->ptr_;
  this->ptr_ = 0;
  return tmp;
}

template <typename T>
T *
TAO_Value_Var_T<T>::ptr (void) const
{
  return this->ptr_;
}

// *************************************************************

template <typename T>
TAO_Value_Out_T<T>::TAO_Value_Out_T (T *& p)
  : ptr_ (p)
{
  this->ptr_ = 0;
}

template <typename T>
TAO_Value_Out_T<T>::TAO_Value_Out_T (TAO_Value_Var_T<T> & p)
  : ptr_ (p.out ())
{
  TAO::Value_Traits<T>::remove_ref (this->ptr_);
  this->ptr_ = 0;
}

template <typename T>
TAO_Value_Out_T<T>::TAO_Value_Out_T (const TAO_Value_Out_T<T> & p)
  : ptr_ (const_cast<TAO_Value_Out_T<T> &> (p).ptr_)
{}

template <typename T>
TAO_Value_Out_T<T> &
TAO_Value_Out_T<T>::operator= (const TAO_Value_Out_T<T> & p)
{
  this->ptr_ = const_cast<TAO_Value_Out_T<T> &> (p).ptr_;
  return *this;
}

template <typename T>
TAO_Value_Out_T<T> &
TAO_Value_Out_T<T>::operator= (T * p)
{
  this->ptr_ = p;
  return *this;
}

template <typename T>
TAO_Value_Out_T<T>::operator T *& ()
{
  return this->ptr_;
}

template <typename T>
T *&
TAO_Value_Out_T<T>::ptr (void)
{
  return this->ptr_;
}

template <typename T>
T *
TAO_Value_Out_T<T>::operator-> (void)
{
  return this->ptr_;
}

TAO_END_VERSIONED_NAMESPACE_DECL

#endif /* TAO_VALUE_VAROUT_T_CPP */