2 #include "tao/AnyTypeCode/AnyTypeCode_methods.h"
3 #include "tao/Valuetype/AbstractBase.h"
5 #include "tao/DynamicAny/DynCommon.h"
7 #include "tao/DynamicAny/DynAnyFactory.h"
8 #include "tao/DynamicAny/DynAny_i.h"
9 #include "tao/DynamicAny/DynArray_i.h"
10 #include "tao/DynamicAny/DynEnum_i.h"
11 #include "tao/DynamicAny/DynSequence_i.h"
12 #include "tao/DynamicAny/DynStruct_i.h"
13 #include "tao/DynamicAny/DynUnion_i.h"
14 #include "tao/DynamicAny/DynAnyUtils_T.h"
16 #include "tao/AnyTypeCode/Any_Unknown_IDL_Type.h"
17 #include "tao/AnyTypeCode/AnyTypeCode_methods.h"
21 #include "ace/OS_NS_wchar.h"
22 #include "ace/OS_NS_string.h"
24 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
26 TAO_DynCommon::TAO_DynCommon (CORBA::Boolean allow_truncation
)
27 : ref_to_component_ (false)
28 , container_is_destroying_ (false)
29 , has_components_ (false)
31 , current_position_ (-1)
32 , component_count_ (0)
33 , allow_truncation_ (allow_truncation
)
37 TAO_DynCommon::~TAO_DynCommon (void)
42 TAO_DynCommon::type (void)
46 throw ::CORBA::OBJECT_NOT_EXIST ();
49 return CORBA::TypeCode::_duplicate (this->type_
.in ());
53 TAO_DynCommon::assign (DynamicAny::DynAny_ptr dyn_any
)
57 throw ::CORBA::OBJECT_NOT_EXIST ();
60 CORBA::TypeCode_var tc
= dyn_any
->type ();
62 CORBA::Boolean
const equivalent
= this->type_
.in ()->equivalent (tc
.in ());
66 CORBA::Any_var any
= dyn_any
->to_any ();
68 this->from_any (any
.in ());
72 throw DynamicAny::DynAny::TypeMismatch ();
77 TAO_DynCommon::insert_boolean (CORBA::Boolean value
)
79 TAO::DynAnyBasicTypeUtils
<CORBA::Boolean
>::insert_value (value
, this);
83 TAO_DynCommon::insert_octet (CORBA::Octet value
)
85 TAO::DynAnyBasicTypeUtils
<CORBA::Octet
>::insert_value (value
, this);
89 TAO_DynCommon::insert_char (CORBA::Char value
)
91 TAO::DynAnyBasicTypeUtils
<CORBA::Char
>::insert_value (value
, this);
95 TAO_DynCommon::insert_short (CORBA::Short value
)
97 TAO::DynAnyBasicTypeUtils
<CORBA::Short
>::insert_value (value
, this);
101 TAO_DynCommon::insert_ushort (CORBA::UShort value
)
103 TAO::DynAnyBasicTypeUtils
<CORBA::UShort
>::insert_value (value
, this);
107 TAO_DynCommon::insert_long (CORBA::Long value
)
109 TAO::DynAnyBasicTypeUtils
<CORBA::Long
>::insert_value (value
, this);
113 TAO_DynCommon::insert_ulong (CORBA::ULong value
)
115 TAO::DynAnyBasicTypeUtils
<CORBA::ULong
>::insert_value (value
, this);
119 TAO_DynCommon::insert_float (CORBA::Float value
)
121 TAO::DynAnyBasicTypeUtils
<CORBA::Float
>::insert_value (value
, this);
125 TAO_DynCommon::insert_double (CORBA::Double value
)
127 TAO::DynAnyBasicTypeUtils
<CORBA::Double
>::insert_value (value
, this);
131 TAO_DynCommon::insert_string (const char * value
)
133 if (this->destroyed_
)
135 throw ::CORBA::OBJECT_NOT_EXIST ();
138 if (this->has_components_
)
140 DynamicAny::DynAny_var cc
=
141 this->check_component ();
143 cc
->insert_string (value
);
147 CORBA::TypeCode_var unaliased_tc
=
148 TAO_DynAnyFactory::strip_alias (this->type_
.in ());
150 CORBA::TCKind
const kind
=
151 unaliased_tc
->kind ();
153 if (kind
!= CORBA::tk_string
)
155 throw DynamicAny::DynAny::TypeMismatch ();
158 CORBA::ULong
const bound
=
159 unaliased_tc
->length ();
161 if (bound
> 0 && bound
< ACE_OS::strlen (value
))
163 throw DynamicAny::DynAny::InvalidValue ();
166 this->any_
<<= CORBA::Any::from_string (const_cast<char *> (value
),
172 TAO_DynCommon::insert_reference (CORBA::Object_ptr value
)
174 if (this->destroyed_
)
176 throw ::CORBA::OBJECT_NOT_EXIST ();
179 if (this->has_components_
)
181 DynamicAny::DynAny_var cc
=
182 this->check_component ();
184 cc
->insert_reference (value
);
188 CORBA::Boolean good_type
= true;
189 CORBA::TCKind
const kind
=
190 TAO_DynAnyFactory::unalias (this->type_
.in ());
192 if (kind
!= CORBA::tk_objref
)
196 else if (!CORBA::is_nil (value
))
198 const char *value_id
= value
->_interface_repository_id ();
200 if (ACE_OS::strcmp (value_id
, "IDL:omg.org/CORBA/Object:1.0") != 0)
205 if (ACE_OS::strcmp (value_id
, my_id
) != 0)
207 good_type
= value
->_is_a (my_id
);
216 if (CORBA::is_nil (value
))
218 // Empty type hint, no profile.
220 cdr
.write_char ('\0');
225 if (!value
->marshal (cdr
))
227 throw DynamicAny::DynAny::InvalidValue ();
231 TAO_InputCDR
in (cdr
);
232 TAO::Unknown_IDL_Type
*unk
= 0;
234 TAO::Unknown_IDL_Type (this->type_
.in (),
236 this->any_
.replace (unk
);
240 throw DynamicAny::DynAny::TypeMismatch ();
246 TAO_DynCommon::insert_typecode (CORBA::TypeCode_ptr value
)
248 TAO::DynAnyBasicTypeUtils
<CORBA::TypeCode_ptr
>::insert_value (value
, this);
252 TAO_DynCommon::insert_longlong (CORBA::LongLong value
)
254 TAO::DynAnyBasicTypeUtils
<CORBA::LongLong
>::insert_value (value
, this);
258 TAO_DynCommon::insert_ulonglong (CORBA::ULongLong value
)
260 TAO::DynAnyBasicTypeUtils
<CORBA::ULongLong
>::insert_value (value
, this);
264 TAO_DynCommon::insert_longdouble (CORBA::LongDouble value
)
266 TAO::DynAnyBasicTypeUtils
<CORBA::LongDouble
>::insert_value (value
,
271 TAO_DynCommon::insert_wchar (CORBA::WChar value
)
273 TAO::DynAnyBasicTypeUtils
<CORBA::WChar
>::insert_value (value
,
278 TAO_DynCommon::insert_wstring (const CORBA::WChar
* value
)
280 if (this->destroyed_
)
282 throw ::CORBA::OBJECT_NOT_EXIST ();
285 if (this->has_components_
)
287 DynamicAny::DynAny_var cc
=
288 this->check_component ();
290 cc
->insert_wstring (value
);
294 CORBA::TypeCode_var unaliased_tc
=
295 this->check_type_and_unalias (CORBA::_tc_wstring
);
297 CORBA::ULong
const bound
= unaliased_tc
->length ();
299 if (bound
> 0 && bound
< ACE_OS::wslen (value
))
301 throw DynamicAny::DynAny::InvalidValue ();
304 this->any_
<<= CORBA::Any::from_wstring (const_cast<CORBA::WChar
*> (value
),
310 TAO_DynCommon::insert_any (const CORBA::Any
&value
)
312 TAO::DynAnyBasicTypeUtils
<CORBA::Any
>::insert_value (value
,
316 // @@@ (JP) TODO - optimize - this version was intended by the OMG to
317 // have fewer Any/DynAny conversions than insert_any, not more.
319 TAO_DynCommon::insert_dyn_any (DynamicAny::DynAny_ptr value
)
321 if (this->destroyed_
)
323 throw ::CORBA::OBJECT_NOT_EXIST ();
326 CORBA::Any_var any
= value
->to_any ();
328 this->insert_any (any
.in ());
332 TAO_DynCommon::insert_val (CORBA::ValueBase
*value
)
334 if (this->destroyed_
)
336 throw ::CORBA::OBJECT_NOT_EXIST ();
339 if (this->has_components_
)
341 DynamicAny::DynAny_var cc
=
342 this->check_component (true);
344 cc
->insert_val (value
);
349 TAO_DynAnyFactory::unalias (this->type_
.in ());
351 if (kind
!= CORBA::tk_value
)
353 throw DynamicAny::DynAny::TypeMismatch ();
356 // If the arg is 0 we can't do this kind of type checking,
357 // and the call to _tao_marshal() below will handle the
358 // null value correctly.
361 const char *value_id
= value
->_tao_obv_repository_id ();
365 // Valuetypes, unlike interfaces, don't have a virtual
366 // method to check for a more derived type when the
367 // repo ids don't match. Valuetypes have only
368 // a static _downcast() method, which can't be used
369 // here, so if the repo ids don't match, we're hosed.
370 if (ACE_OS::strcmp (value_id
, my_id
) != 0)
372 throw DynamicAny::DynAny::TypeMismatch ();
376 // This will handle null values correctly, or otherwise
377 // make a virtual call to marshal the state.
379 CORBA::Boolean
const good_insert
=
380 CORBA::ValueBase::_tao_marshal (out
, value
);
384 throw DynamicAny::DynAny::InvalidValue ();
387 TAO_InputCDR
in (out
);
388 TAO::Unknown_IDL_Type
*unk
= 0;
390 TAO::Unknown_IDL_Type (this->type_
.in (), in
));
391 this->any_
.replace (unk
);
395 // ****************************************************************
398 TAO_DynCommon::get_boolean (void)
400 return TAO::DynAnyBasicTypeUtils
<CORBA::Boolean
>::get_value (this);
404 TAO_DynCommon::get_octet (void)
406 return TAO::DynAnyBasicTypeUtils
<CORBA::Octet
>::get_value (this);
410 TAO_DynCommon::get_char (void)
412 return TAO::DynAnyBasicTypeUtils
<CORBA::Char
>::get_value (this);
416 TAO_DynCommon::get_short (void)
418 return TAO::DynAnyBasicTypeUtils
<CORBA::Short
>::get_value (this);
422 TAO_DynCommon::get_ushort (void)
424 return TAO::DynAnyBasicTypeUtils
<CORBA::UShort
>::get_value (this);
428 TAO_DynCommon::get_long (void)
430 return TAO::DynAnyBasicTypeUtils
<CORBA::Long
>::get_value (this);
434 TAO_DynCommon::get_ulong (void)
436 return TAO::DynAnyBasicTypeUtils
<CORBA::ULong
>::get_value (this);
440 TAO_DynCommon::get_float (void)
442 return TAO::DynAnyBasicTypeUtils
<CORBA::Float
>::get_value (this);
446 TAO_DynCommon::get_double (void)
448 return TAO::DynAnyBasicTypeUtils
<CORBA::Double
>::get_value (this);
452 TAO_DynCommon::get_string (void)
454 if (this->destroyed_
)
456 throw ::CORBA::OBJECT_NOT_EXIST ();
459 if (this->has_components_
)
461 DynamicAny::DynAny_var cc
=
462 this->check_component ();
464 return cc
->get_string ();
468 CORBA::TypeCode_var unaliased_tc
=
469 TAO_DynAnyFactory::strip_alias (this->type_
.in ());
472 unaliased_tc
->kind ();
474 if (kind
!= CORBA::tk_string
)
476 throw DynamicAny::DynAny::TypeMismatch ();
481 CORBA::ULong
const bound
=
482 unaliased_tc
->length ();
484 // We will have caught a type mismatch above, so if this fails,
485 // it must be for some other reason.
486 if ((this->any_
>>= CORBA::Any::to_string (retval
, bound
)) == 0)
488 throw DynamicAny::DynAny::InvalidValue ();
491 return CORBA::string_dup (retval
);
496 TAO_DynCommon::get_reference (void)
498 if (this->destroyed_
)
500 throw ::CORBA::OBJECT_NOT_EXIST ();
503 if (this->has_components_
)
505 DynamicAny::DynAny_var cc
=
506 this->check_component ();
508 return cc
->get_reference ();
512 CORBA::Object_var retval
;
514 if ((this->any_
>>= CORBA::Any::to_object (retval
.inout ())) == 0)
516 throw DynamicAny::DynAny::TypeMismatch ();
519 return retval
._retn ();
524 TAO_DynCommon::get_typecode (void)
526 if (this->destroyed_
)
528 throw ::CORBA::OBJECT_NOT_EXIST ();
531 if (this->has_components_
)
533 DynamicAny::DynAny_var cc
= this->check_component ();
535 return cc
->get_typecode ();
539 CORBA::TypeCode_ptr retval
;
541 if ((this->any_
>>= retval
) == 0)
543 throw DynamicAny::DynAny::TypeMismatch ();
546 return CORBA::TypeCode::_duplicate (retval
);
551 TAO_DynCommon::get_longlong (void)
553 return TAO::DynAnyBasicTypeUtils
<CORBA::LongLong
>::get_value (this);
557 TAO_DynCommon::get_ulonglong (void)
559 return TAO::DynAnyBasicTypeUtils
<CORBA::ULongLong
>::get_value (this);
563 TAO_DynCommon::get_longdouble (void)
565 return TAO::DynAnyBasicTypeUtils
<CORBA::LongDouble
>::get_value (this);
569 TAO_DynCommon::get_wchar (void)
571 if (this->destroyed_
)
573 throw ::CORBA::OBJECT_NOT_EXIST ();
576 if (this->has_components_
)
578 DynamicAny::DynAny_var cc
= this->check_component ();
580 return cc
->get_wchar ();
586 if ((this->any_
>>= CORBA::Any::to_wchar (retval
)) == 0)
588 throw DynamicAny::DynAny::TypeMismatch ();
596 TAO_DynCommon::get_wstring (void)
598 if (this->destroyed_
)
600 throw ::CORBA::OBJECT_NOT_EXIST ();
603 if (this->has_components_
)
605 DynamicAny::DynAny_var cc
=
606 this->check_component ();
608 return cc
->get_wstring ();
612 // @@@ (JP) Someday try to find a way to avoid checking for
613 // type code equivalence twice without risking a throw of
615 CORBA::TypeCode_var unaliased_tc
=
616 this->check_type_and_unalias (CORBA::_tc_wstring
);
618 CORBA::WChar
*retval
= 0;
621 unaliased_tc
->length ();
623 (void) (this->any_
>>= CORBA::Any::to_wstring (retval
, bound
));
625 return CORBA::wstring_dup (retval
);
630 TAO_DynCommon::get_any (void)
632 if (this->destroyed_
)
634 throw ::CORBA::OBJECT_NOT_EXIST ();
637 if (this->has_components_
)
639 DynamicAny::DynAny_var cc
=
640 this->check_component ();
642 return cc
->get_any ();
646 const CORBA::Any
*tmp
= 0;
648 if ((this->any_
>>= tmp
) == 0)
650 throw DynamicAny::DynAny::TypeMismatch ();
653 CORBA::Any
*retval
= 0;
654 ACE_NEW_RETURN (retval
,
661 // @@@ (JP) TODO - optimize - this version was intended by the OMG to
662 // have fewer Any/DynAny conversions than get_any, not more.
663 DynamicAny::DynAny_ptr
664 TAO_DynCommon::get_dyn_any (void)
666 if (this->destroyed_
)
668 throw ::CORBA::OBJECT_NOT_EXIST ();
671 CORBA::Any_var any
= this->get_any ();
674 TAO::MakeDynAnyUtils::make_dyn_any_t
<const CORBA::Any
&> (
675 any
.in ()._tao_get_typecode (),
677 this->allow_truncation_
);
681 TAO_DynCommon::get_val (void)
683 if (this->destroyed_
)
685 throw ::CORBA::OBJECT_NOT_EXIST ();
688 if (this->has_components_
)
690 DynamicAny::DynAny_var cc
=
691 this->check_component (true);
693 return cc
->get_val ();
698 TAO_DynAnyFactory::unalias (this->type_
.in ());
700 if (kind
!= CORBA::tk_value
)
702 throw DynamicAny::DynAny::TypeMismatch ();
705 CORBA::ValueBase_var retval
;
706 TAO::Any_Impl
*any_impl
= this->any_
.impl ();
710 throw DynamicAny::DynAny::InvalidValue ();
713 // This should always be non-zero for dynamic anys.
714 TAO::Unknown_IDL_Type
*unk
=
715 dynamic_cast<TAO::Unknown_IDL_Type
*> (any_impl
);
717 // Demarshal from a copy so we can retain ownership of our contents.
718 TAO_InputCDR
for_reading (unk
->_tao_get_cdr ());
720 CORBA::Boolean good_extract
=
721 CORBA::ValueBase::_tao_unmarshal (for_reading
,
726 throw DynamicAny::DynAny::InvalidValue ();
729 return retval
._retn ();
733 // ****************************************************************
736 TAO_DynCommon::seek (CORBA::Long slot
)
738 if (this->destroyed_
)
740 throw ::CORBA::OBJECT_NOT_EXIST ();
743 if (this->has_components_
== 0)
745 ACE_UNUSED_ARG (slot
);
746 this->current_position_
= -1;
749 else if (slot
< 0 || slot
>= static_cast<CORBA::Long
> (this->component_count_
))
751 this->current_position_
= -1;
756 this->current_position_
= slot
;
762 TAO_DynCommon::rewind (void)
764 if (this->destroyed_
)
766 throw ::CORBA::OBJECT_NOT_EXIST ();
769 (void) this->seek (0);
773 TAO_DynCommon::next (void)
775 if (this->destroyed_
)
777 throw ::CORBA::OBJECT_NOT_EXIST ();
780 CORBA::Long component_count
= static_cast<CORBA::Long
> (this->component_count_
);
782 if (this->has_components_
== 0
783 || this->current_position_
+ 1 >= component_count
)
785 this->current_position_
= -1;
790 ++this->current_position_
;
795 DynamicAny::DynAny_ptr
796 TAO_DynCommon::copy (void)
798 if (this->destroyed_
)
800 throw ::CORBA::OBJECT_NOT_EXIST ();
803 CORBA::Any_var any
= this->to_any ();
805 DynamicAny::DynAny_ptr retval
=
806 TAO::MakeDynAnyUtils::make_dyn_any_t
<const CORBA::Any
&> (
807 any
.in ()._tao_get_typecode (),
809 this->allow_truncation_
);
815 TAO_DynCommon::component_count (void)
817 if (this->destroyed_
)
819 throw ::CORBA::OBJECT_NOT_EXIST ();
822 return this->component_count_
;
825 // ****************************************************************
828 TAO_DynCommon::insert_abstract (CORBA::AbstractBase_ptr value
)
830 if (this->destroyed_
)
832 throw ::CORBA::OBJECT_NOT_EXIST ();
835 if (this->has_components_
)
837 DynamicAny::DynAny_var cc
=
838 this->check_component ();
840 cc
->insert_abstract (value
);
844 CORBA::Boolean good_type
= true;
846 TAO_DynAnyFactory::unalias (this->type_
.in ());
848 if (kind
!= CORBA::tk_abstract_interface
)
852 else if (!CORBA::is_nil (value
))
854 const char *value_id
= value
->_interface_repository_id ();
856 ACE_OS::strcmp (value_id
, "IDL:omg.org/CORBA/AbstractBase:1.0");
863 if (ACE_OS::strcmp (value_id
, my_id
) != 0)
865 // If 'value' is an objref, this will be a virtual
866 // call. If not, it will just compare to the repo id
867 // above, which we already know won't match. We see
868 // in insert_val() (see comment there) that there
869 // is no way to check for derived valuetypes w/o
870 // type knowledge at compile time.
871 good_type
= value
->_is_a (my_id
);
880 // The CDR insertion operator for AbstractBase handles
881 // all cases - nil, objref and valuetype - polymorphically.
884 throw DynamicAny::DynAny::InvalidValue ();
887 TAO_InputCDR
in (out
);
888 TAO::Unknown_IDL_Type
*unk
= 0;
890 TAO::Unknown_IDL_Type (this->type_
.in (), in
));
891 this->any_
.replace (unk
);
895 throw DynamicAny::DynAny::TypeMismatch ();
900 CORBA::AbstractBase_ptr
901 TAO_DynCommon::get_abstract (void)
903 if (this->destroyed_
)
905 throw ::CORBA::OBJECT_NOT_EXIST ();
908 if (this->has_components_
)
910 DynamicAny::DynAny_var cc
=
911 this->check_component ();
913 return cc
->get_abstract ();
918 TAO_DynAnyFactory::unalias (this->type_
.in ());
920 if (kind
!= CORBA::tk_abstract_interface
)
922 throw DynamicAny::DynAny::TypeMismatch ();
925 CORBA::AbstractBase_var retval
;
926 TAO::Any_Impl
*any_impl
= this->any_
.impl ();
930 throw DynamicAny::DynAny::InvalidValue ();
933 // This should always be non-zero for dynamic anys.
934 TAO::Unknown_IDL_Type
*unk
=
935 dynamic_cast<TAO::Unknown_IDL_Type
*> (any_impl
);
937 // Make a copy to extract from so we retain ownership of contents.
938 TAO_InputCDR
for_reading (unk
->_tao_get_cdr ());
940 // The CDR extraction operator for AbstractBase handles
942 if (!(for_reading
>> retval
.inout ()))
944 throw DynamicAny::DynAny::InvalidValue ();
947 return retval
._retn ();
951 // ****************************************************************
954 TAO_DynCommon::insert_boolean_seq (const CORBA::BooleanSeq
&value
)
956 TAO::DynAnyBasicTypeUtils
<CORBA::BooleanSeq
>::insert_value (value
, this);
960 TAO_DynCommon::insert_octet_seq (const CORBA::OctetSeq
&value
)
962 TAO::DynAnyBasicTypeUtils
<CORBA::OctetSeq
>::insert_value (value
, this);
966 TAO_DynCommon::insert_char_seq (const CORBA::CharSeq
&value
)
968 TAO::DynAnyBasicTypeUtils
<CORBA::CharSeq
>::insert_value (value
, this);
972 TAO_DynCommon::insert_short_seq (const CORBA::ShortSeq
&value
)
974 TAO::DynAnyBasicTypeUtils
<CORBA::ShortSeq
>::insert_value (value
, this);
978 TAO_DynCommon::insert_ushort_seq (const CORBA::UShortSeq
&value
)
980 TAO::DynAnyBasicTypeUtils
<CORBA::UShortSeq
>::insert_value (value
, this);
984 TAO_DynCommon::insert_long_seq (const CORBA::LongSeq
&value
)
986 TAO::DynAnyBasicTypeUtils
<CORBA::LongSeq
>::insert_value (value
, this);
990 TAO_DynCommon::insert_ulong_seq (const CORBA::ULongSeq
&value
)
992 TAO::DynAnyBasicTypeUtils
<CORBA::ULongSeq
>::insert_value (value
, this);
996 TAO_DynCommon::insert_float_seq (const CORBA::FloatSeq
&value
)
998 TAO::DynAnyBasicTypeUtils
<CORBA::FloatSeq
>::insert_value (value
, this);
1002 TAO_DynCommon::insert_double_seq (const CORBA::DoubleSeq
&value
)
1004 TAO::DynAnyBasicTypeUtils
<CORBA::DoubleSeq
>::insert_value (value
, this);
1008 TAO_DynCommon::insert_longlong_seq (const CORBA::LongLongSeq
&value
)
1010 TAO::DynAnyBasicTypeUtils
<CORBA::LongLongSeq
>::insert_value (value
, this);
1014 TAO_DynCommon::insert_ulonglong_seq (const CORBA::ULongLongSeq
&value
)
1016 TAO::DynAnyBasicTypeUtils
<CORBA::ULongLongSeq
>::insert_value (value
, this);
1020 TAO_DynCommon::insert_longdouble_seq (const CORBA::LongDoubleSeq
&value
)
1022 TAO::DynAnyBasicTypeUtils
<CORBA::LongDoubleSeq
>::insert_value (value
, this);
1026 TAO_DynCommon::insert_wchar_seq (const CORBA::WCharSeq
&value
)
1028 TAO::DynAnyBasicTypeUtils
<CORBA::WCharSeq
>::insert_value (value
, this);
1031 // ****************************************************************
1034 TAO_DynCommon::get_boolean_seq (void)
1036 const CORBA::BooleanSeq
*owned
=
1037 TAO::DynAnyBasicTypeUtils
<CORBA::BooleanSeq
>::get_value (this);
1038 return new CORBA::BooleanSeq (*owned
);
1042 TAO_DynCommon::get_octet_seq (void)
1044 const CORBA::OctetSeq
*owned
=
1045 TAO::DynAnyBasicTypeUtils
<CORBA::OctetSeq
>::get_value (this);
1046 return new CORBA::OctetSeq (*owned
);
1050 TAO_DynCommon::get_char_seq (void)
1052 const CORBA::CharSeq
*owned
=
1053 TAO::DynAnyBasicTypeUtils
<CORBA::CharSeq
>::get_value (this);
1054 return new CORBA::CharSeq (*owned
);
1058 TAO_DynCommon::get_short_seq (void)
1060 const CORBA::ShortSeq
*owned
=
1061 TAO::DynAnyBasicTypeUtils
<CORBA::ShortSeq
>::get_value (this);
1062 return new CORBA::ShortSeq (*owned
);
1066 TAO_DynCommon::get_ushort_seq (void)
1068 const CORBA::UShortSeq
*owned
=
1069 TAO::DynAnyBasicTypeUtils
<CORBA::UShortSeq
>::get_value (this);
1070 return new CORBA::UShortSeq (*owned
);
1074 TAO_DynCommon::get_long_seq (void)
1076 const CORBA::LongSeq
*owned
=
1077 TAO::DynAnyBasicTypeUtils
<CORBA::LongSeq
>::get_value (this);
1078 return new CORBA::LongSeq (*owned
);
1082 TAO_DynCommon::get_ulong_seq (void)
1084 const CORBA::ULongSeq
*owned
=
1085 TAO::DynAnyBasicTypeUtils
<CORBA::ULongSeq
>::get_value (this);
1086 return new CORBA::ULongSeq (*owned
);
1090 TAO_DynCommon::get_float_seq (void)
1092 const CORBA::FloatSeq
*owned
=
1093 TAO::DynAnyBasicTypeUtils
<CORBA::FloatSeq
>::get_value (this);
1094 return new CORBA::FloatSeq (*owned
);
1098 TAO_DynCommon::get_double_seq (void)
1100 const CORBA::DoubleSeq
*owned
=
1101 TAO::DynAnyBasicTypeUtils
<CORBA::DoubleSeq
>::get_value (this);
1102 return new CORBA::DoubleSeq (*owned
);
1105 CORBA::LongLongSeq
*
1106 TAO_DynCommon::get_longlong_seq (void)
1108 const CORBA::LongLongSeq
*owned
=
1109 TAO::DynAnyBasicTypeUtils
<CORBA::LongLongSeq
>::get_value (this);
1110 return new CORBA::LongLongSeq (*owned
);
1113 CORBA::ULongLongSeq
*
1114 TAO_DynCommon::get_ulonglong_seq (void)
1116 const CORBA::ULongLongSeq
*owned
=
1117 TAO::DynAnyBasicTypeUtils
<CORBA::ULongLongSeq
>::get_value (this);
1118 return new CORBA::ULongLongSeq (*owned
);
1121 CORBA::LongDoubleSeq
*
1122 TAO_DynCommon::get_longdouble_seq (void)
1124 const CORBA::LongDoubleSeq
*owned
=
1125 TAO::DynAnyBasicTypeUtils
<CORBA::LongDoubleSeq
>::get_value (this);
1126 return new CORBA::LongDoubleSeq (*owned
);
1130 TAO_DynCommon::get_wchar_seq (void)
1132 const CORBA::WCharSeq
*owned
=
1133 TAO::DynAnyBasicTypeUtils
<CORBA::WCharSeq
>::get_value (this);
1134 return new CORBA::WCharSeq (*owned
);
1137 // ****************************************************************
1140 TAO_DynCommon::set_flag (DynamicAny::DynAny_ptr component
,
1141 CORBA::Boolean destroying
)
1143 CORBA::TypeCode_var tc
= component
->type ();
1145 CORBA::TCKind tk
= TAO_DynAnyFactory::unalias (tc
.in ());
1149 case CORBA::tk_array
:
1150 TAO::DynAnyFlagUtils
<TAO_DynArray_i
>::set_flag_t (component
,
1153 case CORBA::tk_enum
:
1154 TAO::DynAnyFlagUtils
<TAO_DynEnum_i
>::set_flag_t (component
,
1157 case CORBA::tk_sequence
:
1158 if (TAO_DynCommon::is_basic_type_seq (tc
.in ()))
1160 TAO::DynAnyFlagUtils
<TAO_DynAny_i
>::set_flag_t (component
,
1165 TAO::DynAnyFlagUtils
<TAO_DynSequence_i
>::set_flag_t (component
,
1169 case CORBA::tk_struct
:
1170 TAO::DynAnyFlagUtils
<TAO_DynStruct_i
>::set_flag_t (component
,
1173 case CORBA::tk_union
:
1174 TAO::DynAnyFlagUtils
<TAO_DynUnion_i
>::set_flag_t (component
,
1177 case CORBA::tk_value
:
1178 TAO::DynAnyFlagUtils
<TAO_DynValue_i
>::set_flag_t (component
,
1181 case CORBA::tk_value_box
:
1182 TAO::DynAnyFlagUtils
<TAO_DynValueBox_i
>::set_flag_t (component
,
1185 case CORBA::tk_fixed
:
1186 throw ::CORBA::NO_IMPLEMENT ();
1188 TAO::DynAnyFlagUtils
<TAO_DynAny_i
>::set_flag_t (component
,
1194 DynamicAny::DynAny_ptr
1195 TAO_DynCommon::check_component (CORBA::Boolean isValueType
)
1197 if (this->current_position_
== -1)
1199 throw DynamicAny::DynAny::InvalidValue ();
1202 DynamicAny::DynAny_var cc
=
1203 this->current_component ();
1205 CORBA::TypeCode_var tc
= cc
->type ();
1207 // We are here because we are a component that is the target of
1208 // an insert_*() call on our container. It is
1209 // illegal to insert anything into a component that itself has
1211 switch (TAO_DynAnyFactory::unalias (tc
.in ()))
1213 case CORBA::tk_array
:
1214 case CORBA::tk_except
:
1215 case CORBA::tk_struct
:
1216 case CORBA::tk_union
:
1217 throw DynamicAny::DynAny::TypeMismatch ();
1219 case CORBA::tk_value
:
1222 throw DynamicAny::DynAny::TypeMismatch ();
1226 case CORBA::tk_sequence
:
1227 if (!TAO_DynCommon::is_basic_type_seq (tc
.in ()))
1229 throw DynamicAny::DynAny::TypeMismatch ();
1241 TAO_DynCommon::check_type (CORBA::TypeCode_ptr tc
)
1243 CORBA::Boolean
const equivalent
=
1244 this->type_
->equivalent (tc
);
1248 throw DynamicAny::DynAny::TypeMismatch ();
1253 TAO_DynCommon::is_basic_type_seq (CORBA::TypeCode_ptr tc
)
1255 return (tc
->equal (CORBA::_tc_BooleanSeq
)
1256 || tc
->equal (CORBA::_tc_OctetSeq
)
1257 || tc
->equal (CORBA::_tc_CharSeq
)
1258 || tc
->equal (CORBA::_tc_WCharSeq
)
1259 || tc
->equal (CORBA::_tc_ShortSeq
)
1260 || tc
->equal (CORBA::_tc_UShortSeq
)
1261 || tc
->equal (CORBA::_tc_LongSeq
)
1262 || tc
->equal (CORBA::_tc_ULongSeq
)
1263 || tc
->equal (CORBA::_tc_LongLongSeq
)
1264 || tc
->equal (CORBA::_tc_ULongLongSeq
)
1265 || tc
->equal (CORBA::_tc_FloatSeq
)
1266 || tc
->equal (CORBA::_tc_DoubleSeq
)
1267 || tc
->equal (CORBA::_tc_LongDoubleSeq
));
1271 TAO_DynCommon::has_components (void) const
1273 return this->has_components_
;
1277 TAO_DynCommon::destroyed (void) const
1279 return this->destroyed_
;
1283 TAO_DynCommon::the_any (void)
1289 TAO_DynCommon::container_is_destroying (CORBA::Boolean val
)
1291 this->container_is_destroying_
= val
;
1295 TAO_DynCommon::ref_to_component (CORBA::Boolean val
)
1297 this->ref_to_component_
= val
;
1301 TAO_DynCommon::check_type_and_unalias (CORBA::TypeCode_ptr tc
)
1303 this->check_type (tc
);
1305 return TAO_DynAnyFactory::strip_alias (tc
);
1308 TAO_END_VERSIONED_NAMESPACE_DECL