Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tao / Object_Reference_Sequence_Element_T.h
blob5f1830bd9557ac8868a0461477b20b2839c986c4
1 #ifndef guard_object_reference_sequence_element_hpp
2 #define guard_object_reference_sequence_element_hpp
3 /**
4 * @file
6 * @brief Implement the type returned by operator[] in object_reference
7 * sequences.
9 * @author Carlos O'Ryan
11 #include "tao/Basic_Types.h"
13 #include <algorithm>
15 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
17 namespace TAO
19 namespace details
21 template<typename obj_ref_traits>
22 class object_reference_sequence_element
24 public:
25 typedef typename obj_ref_traits::object_type object_reference_type;
26 typedef object_reference_type * value_type;
27 typedef object_reference_type const * const_value_type;
28 typedef typename obj_ref_traits::object_type_var object_reference_var;
30 private:
31 inline object_reference_sequence_element<obj_ref_traits> & pseudo_copy_swap(
32 object_reference_var & rhs)
34 if (release())
36 obj_ref_traits::release(*element_);
38 *element_ = rhs._retn();
39 return *this;
42 public:
43 object_reference_sequence_element(
44 value_type & e, CORBA::Boolean release)
45 : element_(&e)
46 , release_(release)
50 object_reference_sequence_element(
51 object_reference_sequence_element const & rhs)
52 : element_(rhs.element_)
53 , release_(rhs.release_)
57 ~object_reference_sequence_element()
61 object_reference_sequence_element & operator=(
62 object_reference_var const & rhs)
64 object_reference_var tmp(rhs);
65 return pseudo_copy_swap(tmp);
68 object_reference_sequence_element & operator=(
69 object_reference_sequence_element const & rhs)
71 object_reference_var tmp(obj_ref_traits::duplicate(*rhs.element_));
72 return pseudo_copy_swap(tmp);
75 object_reference_sequence_element & operator=(value_type rhs)
77 object_reference_var tmp(rhs);
78 return pseudo_copy_swap(tmp);
81 inline operator value_type()
83 return *this->element_;
86 inline operator const_value_type() const
88 return *this->element_;
91 inline object_reference_type *in () const {
92 return *this->element_;
95 inline object_reference_type *&inout () const {
96 return *this->element_;
99 inline value_type operator->()
101 return *this->element_;
104 inline value_type operator->() const
106 return *this->element_;
109 void swap(object_reference_sequence_element & rhs)
111 std::swap(this->element_, rhs.element_);
112 std::swap(this->release_, rhs.release_);
115 inline CORBA::Boolean release() const
117 return this->release_;
120 private:
121 // This function is not implemented
122 object_reference_sequence_element();
124 private:
125 value_type * element_;
126 CORBA::Boolean release_;
128 } // namespace details
129 } // namespace CORBA
131 TAO_END_VERSIONED_NAMESPACE_DECL
133 #endif // guard_object_reference_sequence_element_hpp