Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / orbsvcs / tests / InterfaceRepo / Union_Forward_Test / client.cpp
blobc3b791947dc72daf794e443525fcbcedef921ff6
1 // -*- C++ -*-
3 #include "tao/IFR_Client/IFR_BasicC.h"
4 #include "tao/ORB_Core.h"
6 int
7 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
9 //init IFR objref
10 try
12 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
14 TAO_IFR_Client_Adapter *ifr_client =
15 ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance (
16 TAO_ORB_Core::ifr_client_adapter_name ());
18 if (ifr_client == 0)
20 throw ::CORBA::INTF_REPOS ();
23 ACE_DEBUG ((LM_DEBUG, "Got IFR_Client ref.\n"));
25 CORBA::InterfaceDef_var intDef =
26 ifr_client->get_interface (orb.in (), "IDL:IFR_Test/test_if:1.0");
28 if (CORBA::is_nil (intDef.in ()))
30 ACE_ERROR_RETURN ((LM_ERROR,
31 "get interface returned nil ref\n"),
32 1);
35 CORBA::ContainedSeq_var attributes =
36 intDef->contents (CORBA::dk_Attribute, 1);
37 CORBA::ULong n_ats = attributes->length ();
39 CORBA::ULong index = 0UL;
40 CORBA::String_var name = attributes[index]->name ();
41 ACE_DEBUG ((LM_DEBUG,
42 "found %d attributes, name = %s\n",
43 n_ats,
44 name.in ()));
46 CORBA::AttributeDef_var attr =
47 CORBA::AttributeDef::_narrow (attributes[index]);
49 if (CORBA::is_nil (attr.in ()))
51 ACE_ERROR_RETURN ((LM_ERROR,
52 "could not narrow attribute ref\n"),
53 1);
56 CORBA::TypeCode_var tc = attr->type ();
58 ACE_DEBUG ((LM_DEBUG, "foo attr typecode = %s\n", tc->id ()));
60 catch (const ::CORBA::Exception &ex)
62 ex._tao_print_exception("ERROR : unexpected CORBA exception caugth :");
63 return 1;
66 return 0;