3 //=============================================================================
7 * @author Jeff Parsons <parsons@cs.wustl.edu>
9 //=============================================================================
12 #ifndef TAO_DYNCOMMON_H
13 #define TAO_DYNCOMMON_H
14 #include /**/ "ace/pre.h"
16 #include "tao/DynamicAny/DynamicAny.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
25 * @class TAO_DynCommon
27 * Contains most of the functionality common to all the
28 * Dynamic Any implementation classes.
30 class TAO_DynamicAny_Export TAO_DynCommon
31 : public virtual DynamicAny::DynAny
35 TAO_DynCommon (CORBA::Boolean allow_truncation
);
38 virtual ~TAO_DynCommon ();
40 // = Some functions common to all Dynamic Any types.
42 virtual CORBA::TypeCode_ptr
type ();
44 virtual void assign (DynamicAny::DynAny_ptr dyn_any
);
46 virtual void insert_boolean (CORBA::Boolean value
);
48 virtual void insert_octet (CORBA::Octet value
);
50 virtual void insert_char (CORBA::Char value
);
51 virtual void insert_short (CORBA::Short value
);
52 virtual void insert_ushort (CORBA::UShort value
);
54 virtual void insert_long (CORBA::Long value
);
56 virtual void insert_ulong (CORBA::ULong value
);
58 virtual void insert_float (CORBA::Float value
);
60 virtual void insert_double (CORBA::Double value
);
62 virtual void insert_string (const char * value
);
64 virtual void insert_reference (CORBA::Object_ptr value
);
66 virtual void insert_typecode (CORBA::TypeCode_ptr value
);
68 virtual void insert_longlong (CORBA::LongLong value
);
70 virtual void insert_ulonglong (CORBA::ULongLong value
);
72 virtual void insert_longdouble (CORBA::LongDouble value
);
74 virtual void insert_wchar (CORBA::WChar value
);
76 virtual void insert_wstring (const CORBA::WChar
* value
);
78 virtual void insert_any (const CORBA::Any
& value
);
80 virtual void insert_dyn_any (DynamicAny::DynAny_ptr value
);
82 virtual void insert_val (CORBA::ValueBase
* value
);
84 virtual CORBA::Boolean
get_boolean ();
86 virtual CORBA::Octet
get_octet ();
88 virtual CORBA::Char
get_char ();
90 virtual CORBA::Short
get_short ();
92 virtual CORBA::UShort
get_ushort ();
94 virtual CORBA::Long
get_long ();
96 virtual CORBA::ULong
get_ulong ();
98 virtual CORBA::Float
get_float ();
100 virtual CORBA::Double
get_double ();
102 virtual char * get_string ();
104 virtual CORBA::Object_ptr
get_reference ();
106 virtual CORBA::TypeCode_ptr
get_typecode ();
108 virtual CORBA::LongLong
get_longlong ();
110 virtual CORBA::ULongLong
get_ulonglong ();
112 virtual CORBA::LongDouble
get_longdouble ();
114 virtual CORBA::WChar
get_wchar ();
116 virtual CORBA::WChar
* get_wstring ();
118 virtual CORBA::Any
* get_any ();
120 virtual DynamicAny::DynAny_ptr
get_dyn_any ();
122 virtual CORBA::ValueBase
* get_val ();
124 virtual CORBA::Boolean
seek (CORBA::Long index
);
126 virtual void rewind ();
128 virtual CORBA::Boolean
next ();
130 virtual DynamicAny::DynAny_ptr
copy ();
132 virtual CORBA::ULong
component_count ();
134 virtual void insert_abstract (CORBA::AbstractBase_ptr value
);
136 virtual CORBA::AbstractBase_ptr
get_abstract ();
138 virtual void insert_boolean_seq (const CORBA::BooleanSeq
& value
);
140 virtual void insert_octet_seq (const CORBA::OctetSeq
& value
);
142 virtual void insert_char_seq (const CORBA::CharSeq
& value
);
144 virtual void insert_short_seq (const CORBA::ShortSeq
& value
);
146 virtual void insert_ushort_seq (const CORBA::UShortSeq
& value
);
148 virtual void insert_long_seq (const CORBA::LongSeq
& value
);
150 virtual void insert_ulong_seq (const CORBA::ULongSeq
& value
);
152 virtual void insert_float_seq (const CORBA::FloatSeq
& value
);
154 virtual void insert_double_seq (const CORBA::DoubleSeq
& value
);
156 virtual void insert_longlong_seq (const CORBA::LongLongSeq
& value
);
158 virtual void insert_ulonglong_seq (const CORBA::ULongLongSeq
& value
);
160 virtual void insert_longdouble_seq (const CORBA::LongDoubleSeq
& value
);
162 virtual void insert_wchar_seq (const CORBA::WCharSeq
& value
);
164 virtual CORBA::BooleanSeq
* get_boolean_seq ();
166 virtual CORBA::OctetSeq
* get_octet_seq ();
168 virtual CORBA::CharSeq
* get_char_seq ();
170 virtual CORBA::ShortSeq
* get_short_seq ();
172 virtual CORBA::UShortSeq
* get_ushort_seq ();
174 virtual CORBA::LongSeq
* get_long_seq ();
176 virtual CORBA::ULongSeq
* get_ulong_seq ();
178 virtual CORBA::FloatSeq
* get_float_seq ();
180 virtual CORBA::DoubleSeq
* get_double_seq ();
182 virtual CORBA::LongLongSeq
* get_longlong_seq ();
184 virtual CORBA::ULongLongSeq
* get_ulonglong_seq ();
186 virtual CORBA::LongDoubleSeq
* get_longdouble_seq ();
188 virtual CORBA::WCharSeq
* get_wchar_seq ();
190 /// This sets one of two flags in this base class. CORBA 2.4.2
191 /// requires that destroy() do nothing if it is called on
192 /// the result of current_component(), the only non-deep-copying
193 /// method in the Dynamic Any API. If the boolean arg below is 0,
194 /// the call is from inside current_component(), and the flag
195 /// ref_to_component_ is set. If the boolean arg is 1, the call
196 /// is from inside destroy(), and the container_is_destroying_
197 /// flag is set, overriding the first flag in the component's
198 /// destroy() method.
199 void set_flag (DynamicAny::DynAny_ptr component
, CORBA::Boolean destroying
);
201 // Utility functions.
203 DynamicAny::DynAny_ptr
check_component (CORBA::Boolean isValueType
= false);
205 void check_type (CORBA::TypeCode_ptr tc
);
207 static bool is_basic_type_seq (CORBA::TypeCode_ptr tc
);
211 CORBA::Boolean
has_components () const;
212 CORBA::Boolean
destroyed () const;
213 CORBA::Any
&the_any ();
217 void container_is_destroying (CORBA::Boolean val
);
218 void ref_to_component (CORBA::Boolean val
);
221 /// Were we created by current_component()?
222 CORBA::Boolean ref_to_component_
;
224 /// Flag to let destroy() call by container override the flag above.
225 CORBA::Boolean container_is_destroying_
;
227 /// Do we contain other Dynamic Anys?
228 CORBA::Boolean has_components_
;
230 /// Has destroy() been called on us yet?
231 CORBA::Boolean destroyed_
;
233 /// Slot of the current component (if any).
234 CORBA::Long current_position_
;
236 /// Number of components, as defined by CORBA 2.4.2.
237 CORBA::ULong component_count_
;
239 /// Holder for our type code.
240 CORBA::TypeCode_var type_
;
242 /// Gets a value only for basic types, but used in insert_*
243 /// and get_*, defined in this base class.
246 /// Are we allowed to truncate any valuetypes in our hyarchy?
247 CORBA::Boolean allow_truncation_
;
250 // Utility functions used by insert_* and get_*.
251 CORBA::TypeCode_ptr
check_type_and_unalias (CORBA::TypeCode_ptr tc
);
254 TAO_END_VERSIONED_NAMESPACE_DECL
256 #include /**/ "ace/post.h"
257 #endif /* TAO_DYNCOMMON_H */