3 //=============================================================================
7 * @author Jeff Parsons <parsons@cs.wust.edu>
9 //=============================================================================
11 #ifndef TAO_ABSTRACTBASE_H
12 #define TAO_ABSTRACTBASE_H
14 #include /**/ "ace/pre.h"
16 #include "tao/Valuetype/valuetype_export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "tao/Valuetype/Value_CORBA_methods.h"
23 #include "tao/Object_Argument_T.h"
24 #include "tao/Arg_Traits_T.h"
25 #include "tao/Objref_VarOut_T.h"
26 #include "tao/Object.h" /* For CORBA::Object_var */
27 #include "tao/Pseudo_VarOut_T.h"
30 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
33 class TAO_Abstract_ServantBase
;
38 typedef AbstractBase
* AbstractBase_ptr
;
40 typedef TAO_Pseudo_Var_T
<AbstractBase
> AbstractBase_var
;
41 typedef TAO_Pseudo_Out_T
<AbstractBase
> AbstractBase_out
;
46 * @brief Abstract base class for Interfaces and Valuetypes
48 * Allows the determination of whether an object has been passed by
49 * reference or by value to be deferred until runtime.
51 class TAO_Valuetype_Export AbstractBase
56 * This constructor is only meant to be called by the
57 * corresponding CDR stream extraction operator or during
58 * narrowing. Refcount of stub p is increased here.
60 AbstractBase (TAO_Stub
*p
,
62 TAO_Abstract_ServantBase
*);
64 typedef CORBA::AbstractBase_ptr _ptr_type
;
65 typedef CORBA::AbstractBase_var _var_type
;
66 typedef CORBA::AbstractBase_out _out_type
;
68 static CORBA::AbstractBase_ptr
_narrow (CORBA::AbstractBase_ptr obj
);
69 static CORBA::AbstractBase_ptr
_duplicate (CORBA::AbstractBase_ptr obj
);
70 static CORBA::AbstractBase_ptr
_nil ();
72 /// Used in the implementation of CORBA::Any
73 static void _tao_any_destructor (void*);
75 /// Spec required conversion operations
76 CORBA::Object_ptr
_to_object ();
77 CORBA::ValueBase
*_to_value ();
79 virtual CORBA::Boolean
_is_a (const char *type_id
);
80 virtual const char* _interface_repository_id () const;
82 /// TAO specific operations
84 virtual const char* _tao_obv_repository_id () const;
85 virtual CORBA::Boolean
_tao_marshal_v (TAO_OutputCDR
&) const;
86 virtual CORBA::Boolean
_tao_unmarshal_v (TAO_InputCDR
&);
87 virtual CORBA::Boolean
_tao_match_formal_type (ptrdiff_t) const;
89 #if defined (GEN_OSTREAM_OPS)
91 /// Used by optionally generated ostream operators for interface
92 /// to output the actual repo id for debugging.
93 static std::ostream
& _tao_stream (std::ostream
&strm
,
94 const AbstractBase_ptr _tao_objref
);
95 virtual std::ostream
& _tao_stream_v (std::ostream
&strm
) const;
97 #endif /* GEN_OSTREAM_OPS */
99 /// Memory management operations
100 virtual void _add_ref ();
101 virtual void _remove_ref ();
103 CORBA::Boolean
_is_objref () const;
105 /// Return the stub object
106 TAO_Stub
*_stubobj () const;
109 CORBA::Boolean
_is_collocated () const;
110 TAO_Abstract_ServantBase
*_servant () const;
112 /// Return the equivalent object reference.
114 * The object is not refcounted. The caller should not put this in
115 * a var or some such thing. The memory is owned by @c this
118 CORBA::Object_ptr
equivalent_objref ();
120 /// Wrapper for _remove_ref(), naming convention for
122 void _decr_refcount ();
126 AbstractBase (const AbstractBase
&);
128 virtual ~AbstractBase () = default;
131 CORBA::Boolean is_objref_
;
134 AbstractBase
& operator= (const AbstractBase
&);
136 virtual CORBA::ValueBase
*_tao_to_value ();
138 CORBA::Object_ptr
create_object (TAO_Stub
*stub
);
141 /// Number of outstanding references to this object.
142 std::atomic
<uint32_t> refcount_
;
144 CORBA::Boolean is_collocated_
;
145 TAO_Abstract_ServantBase
*servant_
;
147 /// Our equivalent CORBA::Object version
148 /// @todo We may at some point of time should probably cache a
149 /// version of CORBA::ValueBase
150 CORBA::Object_var equivalent_obj_
;
153 extern TAO_Valuetype_Export TypeCode_ptr
const _tc_AbstractBase
;
156 TAO_Valuetype_Export
CORBA::Boolean
157 operator<< (TAO_OutputCDR
&, const CORBA::AbstractBase_ptr
);
159 TAO_Valuetype_Export
CORBA::Boolean
160 operator>> (TAO_InputCDR
&, CORBA::AbstractBase_ptr
&);
162 #if defined (GEN_OSTREAM_OPS)
164 TAO_Valuetype_Export
std::ostream
&
165 operator<< (std::ostream
&, CORBA::AbstractBase_ptr
);
167 #endif /* GEN_OSTREAM_OPS */
169 /// Used in generated code if CORBA::AbstractBase is an argument or return type.
173 class TAO_Valuetype_Export Arg_Traits
<CORBA::AbstractBase
>
174 : public Object_Arg_Traits_T
<
175 CORBA::AbstractBase_ptr
,
176 CORBA::AbstractBase_var
,
177 CORBA::AbstractBase_out
,
178 TAO::Objref_Traits
<CORBA::AbstractBase
>,
179 TAO::Any_Insert_Policy_Stream
185 TAO_END_VERSIONED_NAMESPACE_DECL
187 #if defined (__ACE_INLINE__)
188 # include "tao/Valuetype/AbstractBase.inl"
189 #endif /* __ACE_INLINE__) */
191 #include /**/ "ace/post.h"
193 #endif /* TAO_ABSTRACTBASE_H */