本文整理汇总了C++中corba::ORB_ptr::create_enum_tc方法的典型用法代码示例。如果您正苦于以下问题:C++ ORB_ptr::create_enum_tc方法的具体用法?C++ ORB_ptr::create_enum_tc怎么用?C++ ORB_ptr::create_enum_tc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corba::ORB_ptr
的用法示例。
在下文中一共展示了ORB_ptr::create_enum_tc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runDynamic
int runDynamic(CORBA::ORB_ptr orb)
{
try
{
// Create typecode for EventKind.
CORBA::EnumMemberSeq eseq;
eseq.length(2);
eseq[0] = CORBA::string_dup("ALARM_EVENT");
eseq[1] = CORBA::string_dup("LOG_EVENT");
CORBA::TypeCode_var eventKindTc;
eventKindTc = orb->create_enum_tc("IDL:DynAnyTest/EventKind:1.0",
"EventKind",
eseq);
// Create typecode for EventData. EventKind tc is used.
CORBA::Any label;
CORBA::UnionMemberSeq useq;
useq.length(2);
label <<= DynAnyTest::ALARM_EVENT;
useq[0].name = CORBA::string_dup("ev_data");
useq[0].label = label;
useq[0].type = CORBA::TypeCode::_duplicate(CORBA::_tc_any);
useq[0].type_def = CORBA::IDLType::_nil ();
label <<= DynAnyTest::LOG_EVENT;
useq[1].name = CORBA::string_dup("ev_desc");
useq[1].label = label;
useq[1].type = CORBA::TypeCode::_duplicate(CORBA::_tc_string);
useq[1].type_def = CORBA::IDLType::_nil ();
CORBA::TypeCode_var eventDataTc;
eventDataTc = orb->create_union_tc("IDL:DynAnyTest/EventData:1.0",
"EventData",
eventKindTc.in (),
useq);
// Now create DynUnion
CORBA::Object_var obj = orb->resolve_initial_references("DynAnyFactory");
DynamicAny::DynAnyFactory_var dfact =
DynamicAny::DynAnyFactory::_narrow(obj.in ());
if (CORBA::is_nil (dfact.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Nil dynamic any factory after narrow\n"),
-1);
}
DynamicAny::DynAny_var dany =
dfact->create_dyn_any_from_type_code(eventDataTc.in ());
DynamicAny::DynUnion_var dunion =
DynamicAny::DynUnion::_narrow(dany.in ());
DynamicAny::DynAny_var disc = dunion->get_discriminator();
DynamicAny::DynEnum_var denum =
DynamicAny::DynEnum::_narrow(disc.in ());
// This fails. The type of discriminator is ulong
if (CORBA::is_nil (denum.in ()))
{
ACE_ERROR_RETURN ((LM_ERROR,
"Nil dynamic enum after narrow\n"),
-1);
}
ACE_DEBUG ((LM_DEBUG, "Dynamic Test Passed\n"));
denum->destroy();
dunion->destroy();
}
catch (const CORBA::Exception & ex)
{
ex._tao_print_exception ("Dynamic Test Failed with exception");
}
return 0;
}