00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file VarOut_T.h 00006 * 00007 * $Id: VarOut_T.h 90386 2010-06-02 13:52:08Z vzykov $ 00008 * 00009 * @author Jeff Parsons 00010 */ 00011 //============================================================================= 00012 00013 #ifndef TAO_VAROUT_T_H 00014 #define TAO_VAROUT_T_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include /**/ "tao/Versioned_Namespace.h" 00019 00020 #include "ace/OS_Memory.h" 00021 00022 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00023 # pragma once 00024 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00025 00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 /** 00029 * @class TAO_Var_Base_T 00030 * 00031 * @brief Parametrized implementation of _var base class for structs, 00032 * unions and exceptions. 00033 * 00034 */ 00035 template<typename T> 00036 class TAO_Var_Base_T 00037 { 00038 public: 00039 TAO_Var_Base_T (void); 00040 TAO_Var_Base_T (T *); 00041 TAO_Var_Base_T (const TAO_Var_Base_T<T> &); 00042 00043 ~TAO_Var_Base_T (void); 00044 00045 T * operator-> (void); 00046 const T * operator-> (void) const; 00047 00048 typedef const T & _in_type; 00049 typedef T & _inout_type; 00050 00051 // Common mapping for fixed and variable size types. 00052 _in_type in (void) const; 00053 _inout_type inout (void); 00054 00055 // TAO extension. 00056 T * ptr (void) const; 00057 00058 protected: 00059 T * ptr_; 00060 }; 00061 00062 /** 00063 * @class TAO_Fixed_Var_T 00064 * 00065 * @brief Parametrized implementation of _var class for structs, unions, 00066 * and exceptions with members of fixed size. 00067 * 00068 */ 00069 template<typename T> 00070 class TAO_Fixed_Var_T : public TAO_Var_Base_T<T> 00071 { 00072 public: 00073 TAO_Fixed_Var_T (void); 00074 TAO_Fixed_Var_T (T *); 00075 TAO_Fixed_Var_T (const TAO_Fixed_Var_T<T> &); 00076 00077 // Fixed-size types only. 00078 TAO_Fixed_Var_T (const T &); 00079 00080 TAO_Fixed_Var_T & operator= (T *); 00081 TAO_Fixed_Var_T & operator= (const TAO_Fixed_Var_T<T> &); 00082 00083 // Fixed-size types only. 00084 TAO_Fixed_Var_T & operator= (const T &); 00085 00086 operator const T & () const; 00087 operator T & (); 00088 operator T & () const; 00089 00090 typedef T & _out_type; 00091 typedef T _retn_type; 00092 00093 // Mapping for fixed size types. 00094 _out_type out (void); 00095 _retn_type _retn (void); 00096 }; 00097 00098 /** 00099 * @class TAO_Var_Var_T 00100 * 00101 * @brief Parametrized implementation of _var class for structs, unions, 00102 * and exceptions with members of variable size. 00103 * 00104 */ 00105 template<typename T> 00106 class TAO_Var_Var_T : public TAO_Var_Base_T<T> 00107 { 00108 public: 00109 TAO_Var_Var_T (void); 00110 TAO_Var_Var_T (T *); 00111 TAO_Var_Var_T (const TAO_Var_Var_T<T> &); 00112 00113 TAO_Var_Var_T & operator= (T *); 00114 TAO_Var_Var_T & operator= (const TAO_Var_Var_T<T> &); 00115 00116 // Variable size types only. 00117 operator T *& (); 00118 00119 operator const T & () const; 00120 operator T & (); 00121 operator T & () const; 00122 00123 typedef T *& _out_type; 00124 typedef T * _retn_type; 00125 00126 // Mapping for variable size types. 00127 _out_type out (void); 00128 _retn_type _retn (void); 00129 }; 00130 00131 /** 00132 * @class TAO_Out_T 00133 * 00134 * @brief Parametrized implementation of _out class for structs, unions 00135 * and exceptions.. 00136 * 00137 */ 00138 template<typename T> 00139 class TAO_Out_T 00140 { 00141 public: 00142 typedef typename T::_var_type T_var; 00143 00144 TAO_Out_T (T *&); 00145 TAO_Out_T (T_var &); 00146 TAO_Out_T (const TAO_Out_T<T> &); 00147 00148 TAO_Out_T &operator= (const TAO_Out_T<T> &); 00149 TAO_Out_T &operator= (T *); 00150 00151 operator T *& (); 00152 T *& ptr (void); 00153 T * operator-> (void); 00154 00155 private: 00156 T *& ptr_; 00157 00158 /// Assignment from T_var not allowed. 00159 void operator= (const T_var &); 00160 }; 00161 00162 TAO_END_VERSIONED_NAMESPACE_DECL 00163 00164 #if defined (__ACE_INLINE__) 00165 #include "tao/VarOut_T.inl" 00166 #endif /* __ACE_INLINE__ */ 00167 00168 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00169 #include "tao/VarOut_T.cpp" 00170 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00171 00172 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) 00173 #pragma implementation ("VarOut_T.cpp") 00174 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00175 00176 #include /**/ "ace/post.h" 00177 00178 #endif /* TAO_VAROUT_T_H */