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()));
58 ACE_ERROR((LM_ERROR
, "ERROR Any not successfully marshalled\nAny is %@\n", &ts
.whatEver
));
59 if (ts
.whatEver
._tao_get_typecode ()->kind () != CORBA::tk_null
)
61 ACE_ERROR((LM_ERROR
, "ID: %C\nNAME: %C\nKIND: %d\n",
62 ts
.whatEver
._tao_get_typecode()->id(),
63 ts
.whatEver
._tao_get_typecode()->name(),
64 ts
.whatEver
._tao_get_typecode()->kind()));
68 ACE_ERROR((LM_ERROR
, "Typecode is NULL\nKIND: %d\n",
69 ts
.whatEver
._tao_get_typecode()->kind()));
78 int Create (int argc
, ACE_TCHAR
*argv
[]);
82 Main_C::Create (int argc
, ACE_TCHAR
*argv
[])
86 // ENTER your code here ...
87 CORBA::Object_var obj
= m_ORB_p
->resolve_initial_references ("RootPOA");
89 if (parse_args (argc
, argv
) != 0)
92 PortableServer::POA_var poa
= PortableServer::POA::_narrow (obj
.in ());
94 PortableServer::POAManager_var mgr
= poa
->the_POAManager ();
97 IF_Test_impl
*servant
= new IF_Test_impl
;
99 PortableServer::ServantBase_var
owner_transfer(servant
);
101 PortableServer::ObjectId_var id
=
102 poa
->activate_object (servant
);
104 CORBA::Object_var object
= poa
->id_to_reference (id
.in ());
106 IF_EXE_M_R::IF_ExeCtrlData_var hello
= IF_EXE_M_R::IF_ExeCtrlData::_narrow (object
.in ());
108 CORBA::String_var ior
= m_ORB_p
->object_to_string (hello
.in ());
110 // Output the IOR to the <ior_output_file>
111 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
112 if (output_file
== 0)
113 ACE_ERROR_RETURN((LM_ERROR
,
114 "Cannot open output file for writing IOR: %s\n",
117 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
118 ACE_OS::fclose (output_file
);
122 catch (const CORBA::Exception
&ex
)
124 ex
._tao_print_exception ("Exception caught:");
131 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
133 m_ORB_p
= CORBA::ORB_init (argc
, argv
);
136 return main_cs
.Create (argc
, argv
);