1 #include "IF_EXE_M_R_StructsS.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
5 CORBA::ORB_var m_ORB_p
;
7 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("test.ior");
10 parse_args (int argc
, ACE_TCHAR
*argv
[])
12 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
15 while ((c
= get_opts ()) != -1)
19 ior_output_file
= get_opts
.opt_arg ();
24 ACE_ERROR_RETURN((LM_ERROR
,
31 // Indicates successful parsing of the command line
36 class IF_Test_impl
: public POA_IF_EXE_M_R::IF_ExeCtrlData
42 m_ORB_p
->shutdown (0);
46 foo (const ::IF_EXE_M_R::Test_Struct
&ts
)
48 const IF_EXE_M_R::CORBA_FOOIInPlan
*anUnion_p
= new IF_EXE_M_R::CORBA_FOOIInPlan
;
49 if (ts
.whatEver
>>= anUnion_p
)
51 ACE_DEBUG((LM_DEBUG
, "Any successfully marshalled\nAny is %@\nID: %C\nNAME: %C\nKIND: %d\n", &ts
.whatEver
,
52 ts
.whatEver
._tao_get_typecode()->id(),
53 ts
.whatEver
._tao_get_typecode()->name(),
54 ts
.whatEver
._tao_get_typecode()->kind()));
59 ACE_ERROR((LM_ERROR
, "ERROR Any not successfully marshalled\nAny is %@\n", &ts
.whatEver
));
60 if (ts
.whatEver
._tao_get_typecode ()->kind () != CORBA::tk_null
)
62 ACE_ERROR((LM_ERROR
, "ID: %C\nNAME: %C\nKIND: %d\n",
63 ts
.whatEver
._tao_get_typecode()->id(),
64 ts
.whatEver
._tao_get_typecode()->name(),
65 ts
.whatEver
._tao_get_typecode()->kind()));
69 ACE_ERROR((LM_ERROR
, "Typecode is NULL\nKIND: %d\n",
70 ts
.whatEver
._tao_get_typecode()->kind()));
79 int Create (int argc
, ACE_TCHAR
*argv
[]);
83 Main_C::Create (int argc
, ACE_TCHAR
*argv
[])
87 // ENTER your code here ...
88 CORBA::Object_var obj
= m_ORB_p
->resolve_initial_references ("RootPOA");
90 if (parse_args (argc
, argv
) != 0)
93 PortableServer::POA_var poa
= PortableServer::POA::_narrow (obj
.in ());
95 PortableServer::POAManager_var mgr
= poa
->the_POAManager ();
98 IF_Test_impl
*servant
= new IF_Test_impl
;
100 PortableServer::ServantBase_var
owner_transfer(servant
);
102 PortableServer::ObjectId_var id
=
103 poa
->activate_object (servant
);
105 CORBA::Object_var object
= poa
->id_to_reference (id
.in ());
107 IF_EXE_M_R::IF_ExeCtrlData_var hello
= IF_EXE_M_R::IF_ExeCtrlData::_narrow (object
.in ());
109 CORBA::String_var ior
= m_ORB_p
->object_to_string (hello
.in ());
111 // Output the IOR to the <ior_output_file>
112 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
113 if (output_file
== 0)
114 ACE_ERROR_RETURN((LM_ERROR
,
115 "Cannot open output file for writing IOR: %s\n",
118 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
119 ACE_OS::fclose (output_file
);
123 catch (const CORBA::Exception
&ex
)
125 ex
._tao_print_exception ("Exception caught:");
132 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
134 m_ORB_p
= CORBA::ORB_init (argc
, argv
);
137 return main_cs
.Create (argc
, argv
);