diff options
Diffstat (limited to 'TAO/tao/DynamicAny/DynAnyFactory.cpp')
-rw-r--r-- | TAO/tao/DynamicAny/DynAnyFactory.cpp | 358 |
1 files changed, 315 insertions, 43 deletions
diff --git a/TAO/tao/DynamicAny/DynAnyFactory.cpp b/TAO/tao/DynamicAny/DynAnyFactory.cpp index 4910fc1a1a2..33e2e77d355 100644 --- a/TAO/tao/DynamicAny/DynAnyFactory.cpp +++ b/TAO/tao/DynamicAny/DynAnyFactory.cpp @@ -19,7 +19,6 @@ #include "tao/DynamicAny/DynEnum_i.h" #include "tao/DynamicAny/DynArray_i.h" #include "tao/DynamicAny/DynUnion_i.h" -#include "tao/DynamicAny/DynAnyUtils_T.h" #include "ace/Auto_Ptr.h" @@ -34,6 +33,50 @@ TAO_DynAnyFactory::TAO_DynAnyFactory (void) { } +// Utility function called by all the DynAny classes +// to extract the TCKind of possibly aliased types. +CORBA::TCKind +TAO_DynAnyFactory::unalias (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) +{ + CORBA::TCKind tck = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::tk_null); + + while (tck == CORBA::tk_alias) + { + CORBA::TypeCode_var temp = + tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::tk_null); + + tck = TAO_DynAnyFactory::unalias (temp.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::tk_null); + } + + return tck; +} + +// Same as above, but returns the type code. +CORBA::TypeCode_ptr +TAO_DynAnyFactory::strip_alias (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) +{ + CORBA::TypeCode_var retval = CORBA::TypeCode::_duplicate (tc); + CORBA::TCKind tck = retval->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + + while (tck == CORBA::tk_alias) + { + retval = retval->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + + tck = retval->kind (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + } + + return retval._retn (); +} + DynamicAny::DynAny_ptr TAO_DynAnyFactory::create_dyn_any ( const CORBA::Any & value @@ -44,10 +87,7 @@ TAO_DynAnyFactory::create_dyn_any ( DynamicAny::DynAnyFactory::InconsistentTypeCode )) { - return - TAO::MakeDynAnyUtils<const CORBA::Any&>::make_dyn_any_t ( - value._tao_get_typecode (), - value); + return TAO_DynAnyFactory::make_dyn_any (value ACE_ENV_ARG_PARAMETER); } DynamicAny::DynAny_ptr @@ -60,12 +100,7 @@ TAO_DynAnyFactory::create_dyn_any_from_type_code ( DynamicAny::DynAnyFactory::InconsistentTypeCode )) { - // Second arg is typed in the template parameter, repeating it - // this way allows cleaner template code. - return - TAO::MakeDynAnyUtils<CORBA::TypeCode_ptr>::make_dyn_any_t ( - type, - type); + return TAO_DynAnyFactory::make_dyn_any (type ACE_ENV_ARG_PARAMETER); } DynamicAny::DynAny_ptr @@ -79,8 +114,8 @@ TAO_DynAnyFactory::create_dyn_any_without_truncation ( DynamicAny::MustTruncate )) { - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), - DynamicAny::DynAny::_nil ()); + // TODO + return DynamicAny::DynAny::_nil (); } DynamicAny::DynAnySeq * @@ -95,7 +130,8 @@ TAO_DynAnyFactory::create_multiple_dyn_anys ( DynamicAny::MustTruncate )) { - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); + // TODO + return 0; } DynamicAny::AnySeq * @@ -107,51 +143,287 @@ TAO_DynAnyFactory::create_multiple_anys ( CORBA::SystemException )) { - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); + // TODO + return 0; } -// Utility function called by all the DynAny classes -// to extract the TCKind of possibly aliased types. -CORBA::TCKind -TAO_DynAnyFactory::unalias (CORBA::TypeCode_ptr tc - ACE_ENV_ARG_DECL) +//******************************************************************* + +DynamicAny::DynAny_ptr +TAO_DynAnyFactory::make_dyn_any (const CORBA::Any &any + ACE_ENV_ARG_DECL) { - CORBA::TCKind tck = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::tk_null); + CORBA::TypeCode_var tc = any.type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (DynamicAny::DynAny::_nil ()); - while (tck == CORBA::tk_alias) + switch (kind) { - CORBA::TypeCode_var temp = - tc->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::tk_null); + case CORBA::tk_null: + case CORBA::tk_void: + case CORBA::tk_short: + case CORBA::tk_long: + case CORBA::tk_ushort: + case CORBA::tk_ulong: + case CORBA::tk_float: + case CORBA::tk_double: + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + case CORBA::tk_boolean: + case CORBA::tk_char: + case CORBA::tk_wchar: + case CORBA::tk_octet: + case CORBA::tk_any: + case CORBA::tk_TypeCode: + case CORBA::tk_objref: + case CORBA::tk_string: + case CORBA::tk_wstring: + { + TAO_DynAny_i *p = 0; - tck = TAO_DynAnyFactory::unalias (temp.in () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::tk_null); + ACE_NEW_THROW_EX (p, + TAO_DynAny_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynAny_i> dp (p); + p->init (any ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + case CORBA::tk_struct: + case CORBA::tk_except: + { + TAO_DynStruct_i *p = 0; + + ACE_NEW_THROW_EX (p, + TAO_DynStruct_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynStruct_i> dp (p); + p->init (any ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + case CORBA::tk_sequence: + { + TAO_DynSequence_i *p = 0; + + ACE_NEW_THROW_EX (p, + TAO_DynSequence_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynSequence_i> dp (p); + p->init (any ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + case CORBA::tk_union: + { + TAO_DynUnion_i *p = 0; + + ACE_NEW_THROW_EX (p, + TAO_DynUnion_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynUnion_i> dp (p); + p->init (any ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + case CORBA::tk_enum: + { + TAO_DynEnum_i *p = 0; + + ACE_NEW_THROW_EX (p, + TAO_DynEnum_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynEnum_i> dp (p); + p->init (any ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + case CORBA::tk_array: + { + TAO_DynArray_i *p = 0; + + ACE_NEW_THROW_EX (p, + TAO_DynArray_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynArray_i> dp (p); + p->init (any ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + + case CORBA::tk_fixed: + case CORBA::tk_value: + case CORBA::tk_value_box: + case CORBA::tk_abstract_interface: + case CORBA::tk_component: + case CORBA::tk_home: + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + DynamicAny::DynAny::_nil ()); + case CORBA::tk_native: + ACE_THROW_RETURN (DynamicAny::DynAnyFactory::InconsistentTypeCode (), + DynamicAny::DynAny::_nil ()); + default: + break; } - return tck; + return DynamicAny::DynAny::_nil (); } -// Same as above, but returns the type code. -CORBA::TypeCode_ptr -TAO_DynAnyFactory::strip_alias (CORBA::TypeCode_ptr tc - ACE_ENV_ARG_DECL) +DynamicAny::DynAny_ptr +TAO_DynAnyFactory::make_dyn_any (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) { - CORBA::TypeCode_var retval = CORBA::TypeCode::_duplicate (tc); - CORBA::TCKind tck = retval->kind (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + CORBA::TCKind kind = + TAO_DynAnyFactory::unalias (tc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (DynamicAny::DynAny::_nil ()); - while (tck == CORBA::tk_alias) + switch (kind) { - retval = retval->content_type (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + case CORBA::tk_null: + case CORBA::tk_void: + case CORBA::tk_short: + case CORBA::tk_long: + case CORBA::tk_ushort: + case CORBA::tk_ulong: + case CORBA::tk_float: + case CORBA::tk_double: + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + case CORBA::tk_boolean: + case CORBA::tk_char: + case CORBA::tk_wchar: + case CORBA::tk_octet: + case CORBA::tk_any: + case CORBA::tk_TypeCode: + case CORBA::tk_objref: + case CORBA::tk_string: + case CORBA::tk_wstring: + { + TAO_DynAny_i *p = 0; - tck = retval->kind (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::TypeCode::_nil ()); + ACE_NEW_THROW_EX (p, + TAO_DynAny_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynAny_i> dp (p); + p->init (tc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + case CORBA::tk_struct: + case CORBA::tk_except: + { + TAO_DynStruct_i *p = 0; + + ACE_NEW_THROW_EX (p, + TAO_DynStruct_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynStruct_i> dp (p); + p->init (tc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + case CORBA::tk_sequence: + { + TAO_DynSequence_i *p = 0; + + ACE_NEW_THROW_EX (p, + TAO_DynSequence_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynSequence_i> dp (p); + p->init (tc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + case CORBA::tk_union: + { + TAO_DynUnion_i *p = 0; + + ACE_NEW_THROW_EX (p, + TAO_DynUnion_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynUnion_i> dp (p); + p->init (tc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + case CORBA::tk_enum: + { + TAO_DynEnum_i *p = 0; + + ACE_NEW_THROW_EX (p, + TAO_DynEnum_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynEnum_i> dp (p); + p->init (tc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + case CORBA::tk_array: + { + TAO_DynArray_i *p = 0; + + ACE_NEW_THROW_EX (p, + TAO_DynArray_i, + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + ACE_Auto_Basic_Ptr<TAO_DynArray_i> dp (p); + p->init (tc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + return dp.release (); + } + + case CORBA::tk_fixed: + case CORBA::tk_value: + case CORBA::tk_value_box: + case CORBA::tk_abstract_interface: + case CORBA::tk_component: + case CORBA::tk_home: + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + DynamicAny::DynAny::_nil ()); + case CORBA::tk_native: + ACE_THROW_RETURN (DynamicAny::DynAnyFactory::InconsistentTypeCode (), + DynamicAny::DynAny::_nil ()); + default: + break; } - return retval._retn (); + return DynamicAny::DynAny::_nil (); } TAO_END_VERSIONED_NAMESPACE_DECL |