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"
25 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
27 TAO_DynCommon::TAO_DynCommon (CORBA::Boolean allow_truncation
)
28 : ref_to_component_ (false)
29 , container_is_destroying_ (false)
30 , has_components_ (false)
32 , current_position_ (-1)
33 , component_count_ (0)
34 , allow_truncation_ (allow_truncation
)
38 TAO_DynCommon::~TAO_DynCommon ()
43 TAO_DynCommon::type ()
47 throw ::CORBA::OBJECT_NOT_EXIST ();
50 return CORBA::TypeCode::_duplicate (this->type_
.in ());
54 TAO_DynCommon::assign (DynamicAny::DynAny_ptr dyn_any
)
58 throw ::CORBA::OBJECT_NOT_EXIST ();
61 CORBA::TypeCode_var tc
= dyn_any
->type ();
63 CORBA::Boolean
const equivalent
= this->type_
.in ()->equivalent (tc
.in ());
67 CORBA::Any_var any
= dyn_any
->to_any ();
69 this->from_any (any
.in ());
73 throw DynamicAny::DynAny::TypeMismatch ();
78 TAO_DynCommon::insert_boolean (CORBA::Boolean value
)
80 TAO::DynAnyBasicTypeUtils
<CORBA::Boolean
>::insert_value (value
, this);
84 TAO_DynCommon::insert_octet (CORBA::Octet value
)
86 TAO::DynAnyBasicTypeUtils
<CORBA::Octet
>::insert_value (value
, this);
90 TAO_DynCommon::insert_char (CORBA::Char value
)
92 TAO::DynAnyBasicTypeUtils
<CORBA::Char
>::insert_value (value
, this);
96 TAO_DynCommon::insert_short (CORBA::Short value
)
98 TAO::DynAnyBasicTypeUtils
<CORBA::Short
>::insert_value (value
, this);
102 TAO_DynCommon::insert_ushort (CORBA::UShort value
)
104 TAO::DynAnyBasicTypeUtils
<CORBA::UShort
>::insert_value (value
, this);
108 TAO_DynCommon::insert_long (CORBA::Long value
)
110 TAO::DynAnyBasicTypeUtils
<CORBA::Long
>::insert_value (value
, this);
114 TAO_DynCommon::insert_ulong (CORBA::ULong value
)
116 TAO::DynAnyBasicTypeUtils
<CORBA::ULong
>::insert_value (value
, this);
120 TAO_DynCommon::insert_float (CORBA::Float value
)
122 TAO::DynAnyBasicTypeUtils
<CORBA::Float
>::insert_value (value
, this);
126 TAO_DynCommon::insert_double (CORBA::Double value
)
128 TAO::DynAnyBasicTypeUtils
<CORBA::Double
>::insert_value (value
, this);
132 TAO_DynCommon::insert_string (const char * value
)
134 if (this->destroyed_
)
136 throw ::CORBA::OBJECT_NOT_EXIST ();
139 if (this->has_components_
)
141 DynamicAny::DynAny_var cc
=
142 this->check_component ();
144 cc
->insert_string (value
);
148 CORBA::TypeCode_var unaliased_tc
=
149 TAO_DynAnyFactory::strip_alias (this->type_
.in ());
151 CORBA::TCKind
const kind
=
152 unaliased_tc
->kind ();
154 if (kind
!= CORBA::tk_string
)
156 throw DynamicAny::DynAny::TypeMismatch ();
159 CORBA::ULong
const bound
=
160 unaliased_tc
->length ();
162 if (bound
> 0 && bound
< std::strlen (value
))
164 throw DynamicAny::DynAny::InvalidValue ();
167 this->any_
<<= CORBA::Any::from_string (const_cast<char *> (value
),
173 TAO_DynCommon::insert_reference (CORBA::Object_ptr value
)
175 if (this->destroyed_
)
177 throw ::CORBA::OBJECT_NOT_EXIST ();
180 if (this->has_components_
)
182 DynamicAny::DynAny_var cc
=
183 this->check_component ();
185 cc
->insert_reference (value
);
189 CORBA::Boolean good_type
= true;
190 CORBA::TCKind
const kind
=
191 TAO_DynAnyFactory::unalias (this->type_
.in ());
193 if (kind
!= CORBA::tk_objref
)
197 else if (!CORBA::is_nil (value
))
199 const char *value_id
= value
->_interface_repository_id ();
201 if (ACE_OS::strcmp (value_id
, "IDL:omg.org/CORBA/Object:1.0") != 0)
206 if (ACE_OS::strcmp (value_id
, my_id
) != 0)
208 good_type
= value
->_is_a (my_id
);
217 if (CORBA::is_nil (value
))
219 // Empty type hint, no profile.
221 cdr
.write_char ('\0');
226 if (!value
->marshal (cdr
))
228 throw DynamicAny::DynAny::InvalidValue ();
232 TAO_InputCDR
in (cdr
);
233 TAO::Unknown_IDL_Type
*unk
= 0;
235 TAO::Unknown_IDL_Type (this->type_
.in (),
237 this->any_
.replace (unk
);
241 throw DynamicAny::DynAny::TypeMismatch ();
247 TAO_DynCommon::insert_typecode (CORBA::TypeCode_ptr value
)
249 TAO::DynAnyBasicTypeUtils
<CORBA::TypeCode_ptr
>::insert_value (value
, this);
253 TAO_DynCommon::insert_longlong (CORBA::LongLong value
)
255 TAO::DynAnyBasicTypeUtils
<CORBA::LongLong
>::insert_value (value
, this);
259 TAO_DynCommon::insert_ulonglong (CORBA::ULongLong value
)
261 TAO::DynAnyBasicTypeUtils
<CORBA::ULongLong
>::insert_value (value
, this);
265 TAO_DynCommon::insert_longdouble (CORBA::LongDouble value
)
267 TAO::DynAnyBasicTypeUtils
<CORBA::LongDouble
>::insert_value (value
,
272 TAO_DynCommon::insert_wchar (CORBA::WChar value
)
274 TAO::DynAnyBasicTypeUtils
<CORBA::WChar
>::insert_value (value
,
279 TAO_DynCommon::insert_wstring (const CORBA::WChar
* value
)
281 if (this->destroyed_
)
283 throw ::CORBA::OBJECT_NOT_EXIST ();
286 if (this->has_components_
)
288 DynamicAny::DynAny_var cc
=
289 this->check_component ();
291 cc
->insert_wstring (value
);
295 CORBA::TypeCode_var unaliased_tc
=
296 this->check_type_and_unalias (CORBA::_tc_wstring
);
298 CORBA::ULong
const bound
= unaliased_tc
->length ();
300 if (bound
> 0 && bound
< ACE_OS::wslen (value
))
302 throw DynamicAny::DynAny::InvalidValue ();
305 this->any_
<<= CORBA::Any::from_wstring (const_cast<CORBA::WChar
*> (value
),
311 TAO_DynCommon::insert_any (const CORBA::Any
&value
)
313 TAO::DynAnyBasicTypeUtils
<CORBA::Any
>::insert_value (value
,
317 // @@@ (JP) TODO - optimize - this version was intended by the OMG to
318 // have fewer Any/DynAny conversions than insert_any, not more.
320 TAO_DynCommon::insert_dyn_any (DynamicAny::DynAny_ptr value
)
322 if (this->destroyed_
)
324 throw ::CORBA::OBJECT_NOT_EXIST ();
327 CORBA::Any_var any
= value
->to_any ();
329 this->insert_any (any
.in ());
333 TAO_DynCommon::insert_val (CORBA::ValueBase
*value
)
335 if (this->destroyed_
)
337 throw ::CORBA::OBJECT_NOT_EXIST ();
340 if (this->has_components_
)
342 DynamicAny::DynAny_var cc
=
343 this->check_component (true);
345 cc
->insert_val (value
);
350 TAO_DynAnyFactory::unalias (this->type_
.in ());
352 if (kind
!= CORBA::tk_value
)
354 throw DynamicAny::DynAny::TypeMismatch ();
357 // If the arg is 0 we can't do this kind of type checking,
358 // and the call to _tao_marshal() below will handle the
359 // null value correctly.
362 const char *value_id
= value
->_tao_obv_repository_id ();
366 // Valuetypes, unlike interfaces, don't have a virtual
367 // method to check for a more derived type when the
368 // repo ids don't match. Valuetypes have only
369 // a static _downcast() method, which can't be used
370 // here, so if the repo ids don't match, we're hosed.
371 if (ACE_OS::strcmp (value_id
, my_id
) != 0)
373 throw DynamicAny::DynAny::TypeMismatch ();
377 // This will handle null values correctly, or otherwise
378 // make a virtual call to marshal the state.
380 CORBA::Boolean
const good_insert
=
381 CORBA::ValueBase::_tao_marshal (out
, value
);
385 throw DynamicAny::DynAny::InvalidValue ();
388 TAO_InputCDR
in (out
);
389 TAO::Unknown_IDL_Type
*unk
= 0;
391 TAO::Unknown_IDL_Type (this->type_
.in (), in
));
392 this->any_
.replace (unk
);
396 // ****************************************************************
399 TAO_DynCommon::get_boolean ()
401 return TAO::DynAnyBasicTypeUtils
<CORBA::Boolean
>::get_value (this);
405 TAO_DynCommon::get_octet ()
407 return TAO::DynAnyBasicTypeUtils
<CORBA::Octet
>::get_value (this);
411 TAO_DynCommon::get_char ()
413 return TAO::DynAnyBasicTypeUtils
<CORBA::Char
>::get_value (this);
417 TAO_DynCommon::get_short ()
419 return TAO::DynAnyBasicTypeUtils
<CORBA::Short
>::get_value (this);
423 TAO_DynCommon::get_ushort ()
425 return TAO::DynAnyBasicTypeUtils
<CORBA::UShort
>::get_value (this);
429 TAO_DynCommon::get_long ()
431 return TAO::DynAnyBasicTypeUtils
<CORBA::Long
>::get_value (this);
435 TAO_DynCommon::get_ulong ()
437 return TAO::DynAnyBasicTypeUtils
<CORBA::ULong
>::get_value (this);
441 TAO_DynCommon::get_float ()
443 return TAO::DynAnyBasicTypeUtils
<CORBA::Float
>::get_value (this);
447 TAO_DynCommon::get_double ()
449 return TAO::DynAnyBasicTypeUtils
<CORBA::Double
>::get_value (this);
453 TAO_DynCommon::get_string ()
455 if (this->destroyed_
)
457 throw ::CORBA::OBJECT_NOT_EXIST ();
460 if (this->has_components_
)
462 DynamicAny::DynAny_var cc
=
463 this->check_component ();
465 return cc
->get_string ();
469 CORBA::TypeCode_var unaliased_tc
=
470 TAO_DynAnyFactory::strip_alias (this->type_
.in ());
473 unaliased_tc
->kind ();
475 if (kind
!= CORBA::tk_string
)
477 throw DynamicAny::DynAny::TypeMismatch ();
482 CORBA::ULong
const bound
=
483 unaliased_tc
->length ();
485 // We will have caught a type mismatch above, so if this fails,
486 // it must be for some other reason.
487 if ((this->any_
>>= CORBA::Any::to_string (retval
, bound
)) == 0)
489 throw DynamicAny::DynAny::InvalidValue ();
492 return CORBA::string_dup (retval
);
497 TAO_DynCommon::get_reference ()
499 if (this->destroyed_
)
501 throw ::CORBA::OBJECT_NOT_EXIST ();
504 if (this->has_components_
)
506 DynamicAny::DynAny_var cc
=
507 this->check_component ();
509 return cc
->get_reference ();
513 CORBA::Object_var retval
;
515 if ((this->any_
>>= CORBA::Any::to_object (retval
.inout ())) == 0)
517 throw DynamicAny::DynAny::TypeMismatch ();
520 return retval
._retn ();
525 TAO_DynCommon::get_typecode ()
527 if (this->destroyed_
)
529 throw ::CORBA::OBJECT_NOT_EXIST ();
532 if (this->has_components_
)
534 DynamicAny::DynAny_var cc
= this->check_component ();
536 return cc
->get_typecode ();
540 CORBA::TypeCode_ptr retval
;
542 if ((this->any_
>>= retval
) == 0)
544 throw DynamicAny::DynAny::TypeMismatch ();
547 return CORBA::TypeCode::_duplicate (retval
);
552 TAO_DynCommon::get_longlong ()
554 return TAO::DynAnyBasicTypeUtils
<CORBA::LongLong
>::get_value (this);
558 TAO_DynCommon::get_ulonglong ()
560 return TAO::DynAnyBasicTypeUtils
<CORBA::ULongLong
>::get_value (this);
564 TAO_DynCommon::get_longdouble ()
566 return TAO::DynAnyBasicTypeUtils
<CORBA::LongDouble
>::get_value (this);
570 TAO_DynCommon::get_wchar ()
572 if (this->destroyed_
)
574 throw ::CORBA::OBJECT_NOT_EXIST ();
577 if (this->has_components_
)
579 DynamicAny::DynAny_var cc
= this->check_component ();
581 return cc
->get_wchar ();
587 if ((this->any_
>>= CORBA::Any::to_wchar (retval
)) == 0)
589 throw DynamicAny::DynAny::TypeMismatch ();
597 TAO_DynCommon::get_wstring ()
599 if (this->destroyed_
)
601 throw ::CORBA::OBJECT_NOT_EXIST ();
604 if (this->has_components_
)
606 DynamicAny::DynAny_var cc
=
607 this->check_component ();
609 return cc
->get_wstring ();
613 // @@@ (JP) Someday try to find a way to avoid checking for
614 // type code equivalence twice without risking a throw of
616 CORBA::TypeCode_var unaliased_tc
=
617 this->check_type_and_unalias (CORBA::_tc_wstring
);
619 CORBA::WChar
*retval
= 0;
622 unaliased_tc
->length ();
624 (void) (this->any_
>>= CORBA::Any::to_wstring (retval
, bound
));
626 return CORBA::wstring_dup (retval
);
631 TAO_DynCommon::get_any ()
633 if (this->destroyed_
)
635 throw ::CORBA::OBJECT_NOT_EXIST ();
638 if (this->has_components_
)
640 DynamicAny::DynAny_var cc
=
641 this->check_component ();
643 return cc
->get_any ();
647 const CORBA::Any
*tmp
= 0;
649 if ((this->any_
>>= tmp
) == 0)
651 throw DynamicAny::DynAny::TypeMismatch ();
654 CORBA::Any
*retval
= 0;
655 ACE_NEW_RETURN (retval
,
662 // @@@ (JP) TODO - optimize - this version was intended by the OMG to
663 // have fewer Any/DynAny conversions than get_any, not more.
664 DynamicAny::DynAny_ptr
665 TAO_DynCommon::get_dyn_any ()
667 if (this->destroyed_
)
669 throw ::CORBA::OBJECT_NOT_EXIST ();
672 CORBA::Any_var any
= this->get_any ();
675 TAO::MakeDynAnyUtils::make_dyn_any_t
<const CORBA::Any
&> (
676 any
.in ()._tao_get_typecode (),
678 this->allow_truncation_
);
682 TAO_DynCommon::get_val ()
684 if (this->destroyed_
)
686 throw ::CORBA::OBJECT_NOT_EXIST ();
689 if (this->has_components_
)
691 DynamicAny::DynAny_var cc
=
692 this->check_component (true);
694 return cc
->get_val ();
699 TAO_DynAnyFactory::unalias (this->type_
.in ());
701 if (kind
!= CORBA::tk_value
)
703 throw DynamicAny::DynAny::TypeMismatch ();
706 CORBA::ValueBase_var retval
;
707 TAO::Any_Impl
*any_impl
= this->any_
.impl ();
711 throw DynamicAny::DynAny::InvalidValue ();
714 // This should always be non-zero for dynamic anys.
715 TAO::Unknown_IDL_Type
*unk
=
716 dynamic_cast<TAO::Unknown_IDL_Type
*> (any_impl
);
718 // Demarshal from a copy so we can retain ownership of our contents.
719 TAO_InputCDR
for_reading (unk
->_tao_get_cdr ());
721 CORBA::Boolean good_extract
=
722 CORBA::ValueBase::_tao_unmarshal (for_reading
,
727 throw DynamicAny::DynAny::InvalidValue ();
730 return retval
._retn ();
734 // ****************************************************************
737 TAO_DynCommon::seek (CORBA::Long slot
)
739 if (this->destroyed_
)
741 throw ::CORBA::OBJECT_NOT_EXIST ();
744 if (this->has_components_
== 0)
746 ACE_UNUSED_ARG (slot
);
747 this->current_position_
= -1;
750 else if (slot
< 0 || slot
>= static_cast<CORBA::Long
> (this->component_count_
))
752 this->current_position_
= -1;
757 this->current_position_
= slot
;
763 TAO_DynCommon::rewind ()
765 if (this->destroyed_
)
767 throw ::CORBA::OBJECT_NOT_EXIST ();
770 (void) this->seek (0);
774 TAO_DynCommon::next ()
776 if (this->destroyed_
)
778 throw ::CORBA::OBJECT_NOT_EXIST ();
781 CORBA::Long component_count
= static_cast<CORBA::Long
> (this->component_count_
);
783 if (this->has_components_
== 0
784 || this->current_position_
+ 1 >= component_count
)
786 this->current_position_
= -1;
791 ++this->current_position_
;
796 DynamicAny::DynAny_ptr
797 TAO_DynCommon::copy ()
799 if (this->destroyed_
)
801 throw ::CORBA::OBJECT_NOT_EXIST ();
804 CORBA::Any_var any
= this->to_any ();
806 DynamicAny::DynAny_ptr retval
=
807 TAO::MakeDynAnyUtils::make_dyn_any_t
<const CORBA::Any
&> (
808 any
.in ()._tao_get_typecode (),
810 this->allow_truncation_
);
816 TAO_DynCommon::component_count ()
818 if (this->destroyed_
)
820 throw ::CORBA::OBJECT_NOT_EXIST ();
823 return this->component_count_
;
826 // ****************************************************************
829 TAO_DynCommon::insert_abstract (CORBA::AbstractBase_ptr value
)
831 if (this->destroyed_
)
833 throw ::CORBA::OBJECT_NOT_EXIST ();
836 if (this->has_components_
)
838 DynamicAny::DynAny_var cc
=
839 this->check_component ();
841 cc
->insert_abstract (value
);
845 CORBA::Boolean good_type
= true;
847 TAO_DynAnyFactory::unalias (this->type_
.in ());
849 if (kind
!= CORBA::tk_abstract_interface
)
853 else if (!CORBA::is_nil (value
))
855 const char *value_id
= value
->_interface_repository_id ();
857 ACE_OS::strcmp (value_id
, "IDL:omg.org/CORBA/AbstractBase:1.0");
864 if (ACE_OS::strcmp (value_id
, my_id
) != 0)
866 // If 'value' is an objref, this will be a virtual
867 // call. If not, it will just compare to the repo id
868 // above, which we already know won't match. We see
869 // in insert_val() (see comment there) that there
870 // is no way to check for derived valuetypes w/o
871 // type knowledge at compile time.
872 good_type
= value
->_is_a (my_id
);
881 // The CDR insertion operator for AbstractBase handles
882 // all cases - nil, objref and valuetype - polymorphically.
885 throw DynamicAny::DynAny::InvalidValue ();
888 TAO_InputCDR
in (out
);
889 TAO::Unknown_IDL_Type
*unk
= 0;
891 TAO::Unknown_IDL_Type (this->type_
.in (), in
));
892 this->any_
.replace (unk
);
896 throw DynamicAny::DynAny::TypeMismatch ();
901 CORBA::AbstractBase_ptr
902 TAO_DynCommon::get_abstract ()
904 if (this->destroyed_
)
906 throw ::CORBA::OBJECT_NOT_EXIST ();
909 if (this->has_components_
)
911 DynamicAny::DynAny_var cc
=
912 this->check_component ();
914 return cc
->get_abstract ();
919 TAO_DynAnyFactory::unalias (this->type_
.in ());
921 if (kind
!= CORBA::tk_abstract_interface
)
923 throw DynamicAny::DynAny::TypeMismatch ();
926 CORBA::AbstractBase_var retval
;
927 TAO::Any_Impl
*any_impl
= this->any_
.impl ();
931 throw DynamicAny::DynAny::InvalidValue ();
934 // This should always be non-zero for dynamic anys.
935 TAO::Unknown_IDL_Type
*unk
=
936 dynamic_cast<TAO::Unknown_IDL_Type
*> (any_impl
);
938 // Make a copy to extract from so we retain ownership of contents.
939 TAO_InputCDR
for_reading (unk
->_tao_get_cdr ());
941 // The CDR extraction operator for AbstractBase handles
943 if (!(for_reading
>> retval
.inout ()))
945 throw DynamicAny::DynAny::InvalidValue ();
948 return retval
._retn ();
952 // ****************************************************************
955 TAO_DynCommon::insert_boolean_seq (const CORBA::BooleanSeq
&value
)
957 TAO::DynAnyBasicTypeUtils
<CORBA::BooleanSeq
>::insert_value (value
, this);
961 TAO_DynCommon::insert_octet_seq (const CORBA::OctetSeq
&value
)
963 TAO::DynAnyBasicTypeUtils
<CORBA::OctetSeq
>::insert_value (value
, this);
967 TAO_DynCommon::insert_char_seq (const CORBA::CharSeq
&value
)
969 TAO::DynAnyBasicTypeUtils
<CORBA::CharSeq
>::insert_value (value
, this);
973 TAO_DynCommon::insert_short_seq (const CORBA::ShortSeq
&value
)
975 TAO::DynAnyBasicTypeUtils
<CORBA::ShortSeq
>::insert_value (value
, this);
979 TAO_DynCommon::insert_ushort_seq (const CORBA::UShortSeq
&value
)
981 TAO::DynAnyBasicTypeUtils
<CORBA::UShortSeq
>::insert_value (value
, this);
985 TAO_DynCommon::insert_long_seq (const CORBA::LongSeq
&value
)
987 TAO::DynAnyBasicTypeUtils
<CORBA::LongSeq
>::insert_value (value
, this);
991 TAO_DynCommon::insert_ulong_seq (const CORBA::ULongSeq
&value
)
993 TAO::DynAnyBasicTypeUtils
<CORBA::ULongSeq
>::insert_value (value
, this);
997 TAO_DynCommon::insert_float_seq (const CORBA::FloatSeq
&value
)
999 TAO::DynAnyBasicTypeUtils
<CORBA::FloatSeq
>::insert_value (value
, this);
1003 TAO_DynCommon::insert_double_seq (const CORBA::DoubleSeq
&value
)
1005 TAO::DynAnyBasicTypeUtils
<CORBA::DoubleSeq
>::insert_value (value
, this);
1009 TAO_DynCommon::insert_longlong_seq (const CORBA::LongLongSeq
&value
)
1011 TAO::DynAnyBasicTypeUtils
<CORBA::LongLongSeq
>::insert_value (value
, this);
1015 TAO_DynCommon::insert_ulonglong_seq (const CORBA::ULongLongSeq
&value
)
1017 TAO::DynAnyBasicTypeUtils
<CORBA::ULongLongSeq
>::insert_value (value
, this);
1021 TAO_DynCommon::insert_longdouble_seq (const CORBA::LongDoubleSeq
&value
)
1023 TAO::DynAnyBasicTypeUtils
<CORBA::LongDoubleSeq
>::insert_value (value
, this);
1027 TAO_DynCommon::insert_wchar_seq (const CORBA::WCharSeq
&value
)
1029 TAO::DynAnyBasicTypeUtils
<CORBA::WCharSeq
>::insert_value (value
, this);
1032 // ****************************************************************
1035 TAO_DynCommon::get_boolean_seq ()
1037 const CORBA::BooleanSeq
*owned
=
1038 TAO::DynAnyBasicTypeUtils
<CORBA::BooleanSeq
>::get_value (this);
1039 return new CORBA::BooleanSeq (*owned
);
1043 TAO_DynCommon::get_octet_seq ()
1045 const CORBA::OctetSeq
*owned
=
1046 TAO::DynAnyBasicTypeUtils
<CORBA::OctetSeq
>::get_value (this);
1047 return new CORBA::OctetSeq (*owned
);
1051 TAO_DynCommon::get_char_seq ()
1053 const CORBA::CharSeq
*owned
=
1054 TAO::DynAnyBasicTypeUtils
<CORBA::CharSeq
>::get_value (this);
1055 return new CORBA::CharSeq (*owned
);
1059 TAO_DynCommon::get_short_seq ()
1061 const CORBA::ShortSeq
*owned
=
1062 TAO::DynAnyBasicTypeUtils
<CORBA::ShortSeq
>::get_value (this);
1063 return new CORBA::ShortSeq (*owned
);
1067 TAO_DynCommon::get_ushort_seq ()
1069 const CORBA::UShortSeq
*owned
=
1070 TAO::DynAnyBasicTypeUtils
<CORBA::UShortSeq
>::get_value (this);
1071 return new CORBA::UShortSeq (*owned
);
1075 TAO_DynCommon::get_long_seq ()
1077 const CORBA::LongSeq
*owned
=
1078 TAO::DynAnyBasicTypeUtils
<CORBA::LongSeq
>::get_value (this);
1079 return new CORBA::LongSeq (*owned
);
1083 TAO_DynCommon::get_ulong_seq ()
1085 const CORBA::ULongSeq
*owned
=
1086 TAO::DynAnyBasicTypeUtils
<CORBA::ULongSeq
>::get_value (this);
1087 return new CORBA::ULongSeq (*owned
);
1091 TAO_DynCommon::get_float_seq ()
1093 const CORBA::FloatSeq
*owned
=
1094 TAO::DynAnyBasicTypeUtils
<CORBA::FloatSeq
>::get_value (this);
1095 return new CORBA::FloatSeq (*owned
);
1099 TAO_DynCommon::get_double_seq ()
1101 const CORBA::DoubleSeq
*owned
=
1102 TAO::DynAnyBasicTypeUtils
<CORBA::DoubleSeq
>::get_value (this);
1103 return new CORBA::DoubleSeq (*owned
);
1106 CORBA::LongLongSeq
*
1107 TAO_DynCommon::get_longlong_seq ()
1109 const CORBA::LongLongSeq
*owned
=
1110 TAO::DynAnyBasicTypeUtils
<CORBA::LongLongSeq
>::get_value (this);
1111 return new CORBA::LongLongSeq (*owned
);
1114 CORBA::ULongLongSeq
*
1115 TAO_DynCommon::get_ulonglong_seq ()
1117 const CORBA::ULongLongSeq
*owned
=
1118 TAO::DynAnyBasicTypeUtils
<CORBA::ULongLongSeq
>::get_value (this);
1119 return new CORBA::ULongLongSeq (*owned
);
1122 CORBA::LongDoubleSeq
*
1123 TAO_DynCommon::get_longdouble_seq ()
1125 const CORBA::LongDoubleSeq
*owned
=
1126 TAO::DynAnyBasicTypeUtils
<CORBA::LongDoubleSeq
>::get_value (this);
1127 return new CORBA::LongDoubleSeq (*owned
);
1131 TAO_DynCommon::get_wchar_seq ()
1133 const CORBA::WCharSeq
*owned
=
1134 TAO::DynAnyBasicTypeUtils
<CORBA::WCharSeq
>::get_value (this);
1135 return new CORBA::WCharSeq (*owned
);
1138 // ****************************************************************
1141 TAO_DynCommon::set_flag (DynamicAny::DynAny_ptr component
,
1142 CORBA::Boolean destroying
)
1144 CORBA::TypeCode_var tc
= component
->type ();
1146 CORBA::TCKind tk
= TAO_DynAnyFactory::unalias (tc
.in ());
1150 case CORBA::tk_array
:
1151 TAO::DynAnyFlagUtils
<TAO_DynArray_i
>::set_flag_t (component
,
1154 case CORBA::tk_enum
:
1155 TAO::DynAnyFlagUtils
<TAO_DynEnum_i
>::set_flag_t (component
,
1158 case CORBA::tk_sequence
:
1159 if (TAO_DynCommon::is_basic_type_seq (tc
.in ()))
1161 TAO::DynAnyFlagUtils
<TAO_DynAny_i
>::set_flag_t (component
,
1166 TAO::DynAnyFlagUtils
<TAO_DynSequence_i
>::set_flag_t (component
,
1170 case CORBA::tk_struct
:
1171 TAO::DynAnyFlagUtils
<TAO_DynStruct_i
>::set_flag_t (component
,
1174 case CORBA::tk_union
:
1175 TAO::DynAnyFlagUtils
<TAO_DynUnion_i
>::set_flag_t (component
,
1178 case CORBA::tk_value
:
1179 TAO::DynAnyFlagUtils
<TAO_DynValue_i
>::set_flag_t (component
,
1182 case CORBA::tk_value_box
:
1183 TAO::DynAnyFlagUtils
<TAO_DynValueBox_i
>::set_flag_t (component
,
1186 case CORBA::tk_fixed
:
1187 throw ::CORBA::NO_IMPLEMENT ();
1189 TAO::DynAnyFlagUtils
<TAO_DynAny_i
>::set_flag_t (component
,
1195 DynamicAny::DynAny_ptr
1196 TAO_DynCommon::check_component (CORBA::Boolean isValueType
)
1198 if (this->current_position_
== -1)
1200 throw DynamicAny::DynAny::InvalidValue ();
1203 DynamicAny::DynAny_var cc
=
1204 this->current_component ();
1206 CORBA::TypeCode_var tc
= cc
->type ();
1208 // We are here because we are a component that is the target of
1209 // an insert_*() call on our container. It is
1210 // illegal to insert anything into a component that itself has
1212 switch (TAO_DynAnyFactory::unalias (tc
.in ()))
1214 case CORBA::tk_array
:
1215 case CORBA::tk_except
:
1216 case CORBA::tk_struct
:
1217 case CORBA::tk_union
:
1218 throw DynamicAny::DynAny::TypeMismatch ();
1220 case CORBA::tk_value
:
1223 throw DynamicAny::DynAny::TypeMismatch ();
1227 case CORBA::tk_sequence
:
1228 if (!TAO_DynCommon::is_basic_type_seq (tc
.in ()))
1230 throw DynamicAny::DynAny::TypeMismatch ();
1242 TAO_DynCommon::check_type (CORBA::TypeCode_ptr tc
)
1244 CORBA::Boolean
const equivalent
=
1245 this->type_
->equivalent (tc
);
1249 throw DynamicAny::DynAny::TypeMismatch ();
1254 TAO_DynCommon::is_basic_type_seq (CORBA::TypeCode_ptr tc
)
1256 return (tc
->equal (CORBA::_tc_BooleanSeq
)
1257 || tc
->equal (CORBA::_tc_OctetSeq
)
1258 || tc
->equal (CORBA::_tc_CharSeq
)
1259 || tc
->equal (CORBA::_tc_WCharSeq
)
1260 || tc
->equal (CORBA::_tc_ShortSeq
)
1261 || tc
->equal (CORBA::_tc_UShortSeq
)
1262 || tc
->equal (CORBA::_tc_LongSeq
)
1263 || tc
->equal (CORBA::_tc_ULongSeq
)
1264 || tc
->equal (CORBA::_tc_LongLongSeq
)
1265 || tc
->equal (CORBA::_tc_ULongLongSeq
)
1266 || tc
->equal (CORBA::_tc_FloatSeq
)
1267 || tc
->equal (CORBA::_tc_DoubleSeq
)
1268 || tc
->equal (CORBA::_tc_LongDoubleSeq
));
1272 TAO_DynCommon::has_components () const
1274 return this->has_components_
;
1278 TAO_DynCommon::destroyed () const
1280 return this->destroyed_
;
1284 TAO_DynCommon::the_any ()
1290 TAO_DynCommon::container_is_destroying (CORBA::Boolean val
)
1292 this->container_is_destroying_
= val
;
1296 TAO_DynCommon::ref_to_component (CORBA::Boolean val
)
1298 this->ref_to_component_
= val
;
1302 TAO_DynCommon::check_type_and_unalias (CORBA::TypeCode_ptr tc
)
1304 this->check_type (tc
);
1306 return TAO_DynAnyFactory::strip_alias (tc
);
1309 TAO_END_VERSIONED_NAMESPACE_DECL