2 //=============================================================================
3 //=============================================================================
6 #include "ace/Get_Opt.h"
8 #include "ace/OS_NS_string.h"
13 parse_args (int argc
, ACE_TCHAR
*argv
[])
15 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT(""));
18 while ((c
= get_opts ()) != -1)
23 ACE_ERROR_RETURN ((LM_ERROR
,
29 // Indicates successful parsing of the command line
33 class ChildHandler
: public POA_ChildModule::AMI_ChildInterfaceHandler
36 ChildHandler () = default;
37 ~ChildHandler () = default;
40 class NonRelatedChildHandler
: public POA_AMI_ChildInterfaceHandler
43 NonRelatedChildHandler () = default;
44 ~NonRelatedChildHandler () = default;
48 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
56 CORBA::ORB_init (argc
, argv
);
58 CORBA::Object_var object_var
=
59 orb
->resolve_initial_references ("RootPOA");
61 PortableServer::POA_var poa_var
=
62 PortableServer::POA::_narrow (object_var
.in ());
64 PortableServer::POAManager_var poa_manager_var
=
65 poa_var
->the_POAManager ();
67 poa_manager_var
->activate ();
69 if (parse_args (argc
, argv
) != 0)
72 // Create two handlers
73 ChildHandler child_handler
;
74 NonRelatedChildHandler non_related_child_handler
;
76 PortableServer::ObjectId_var id
=
77 poa_var
->activate_object (&child_handler
);
79 CORBA::Object_var object
= poa_var
->id_to_reference (id
.in ());
81 ChildModule::AMI_ChildInterfaceHandler_var the_child_handler_var
=
82 ChildModule::AMI_ChildInterfaceHandler::_narrow (object
.in ());
84 const char * expectedid
= "IDL:child.pragma.prefix/ChildModule/AMI_ChildInterfaceHandler:1.0";
85 if (ACE_OS::strcmp (the_child_handler_var
->_interface_repository_id (), expectedid
) != 0)
87 ACE_ERROR ((LM_ERROR
, "Error: REGRESSION - ChildModule::repository id is "
88 "incorrectly generated, received %s\n",
89 the_child_handler_var
->_interface_repository_id ()));
93 // This handler has no relationship with the above in IDL.
94 id
= poa_var
->activate_object (&non_related_child_handler
);
96 object
= poa_var
->id_to_reference (id
.in ());
98 AMI_ChildInterfaceHandler_var the_non_related_child_handler_var
=
99 AMI_ChildInterfaceHandler::_narrow (object
.in ());
101 // Check that both handler objects narrow successfully to their parent
103 ParentModule::AMI_ParentInterfaceHandler_var the_parent_handler_var
=
104 ParentModule::AMI_ParentInterfaceHandler::_narrow (the_child_handler_var
.in ());
106 if (CORBA::is_nil (the_parent_handler_var
.in ()))
108 ACE_ERROR ((LM_ERROR
, "Error: REGRESSION - Cannot narrow ChildModule::ChildInterface "
109 "reply handler to its parent handler type.\n"));
113 AMI_ParentInterfaceHandler_var the_non_related_parent_handler_var
=
114 AMI_ParentInterfaceHandler::_narrow (the_non_related_child_handler_var
.in ());
116 if (CORBA::is_nil (the_non_related_parent_handler_var
.in ()))
118 ACE_ERROR ((LM_ERROR
, "Error: REGRESSION - Cannot narrow ChildInterface "
119 "reply handler to its parent handler type.\n"));
123 // Check that both handler objects *won't* narrow to each other's parent
125 the_parent_handler_var
=
126 ParentModule::AMI_ParentInterfaceHandler::_narrow (the_non_related_child_handler_var
.in ());
128 if (! CORBA::is_nil (the_parent_handler_var
.in ()))
130 ACE_ERROR ((LM_ERROR
, "Error: REGRESSION - ChildModule::ChildInterface reply handler "
131 "narrows to unrelated type.\n"));
135 the_non_related_parent_handler_var
=
136 AMI_ParentInterfaceHandler::_narrow (the_child_handler_var
.in ());
138 if (! CORBA::is_nil (the_non_related_parent_handler_var
.in ()))
140 ACE_ERROR ((LM_ERROR
, "Error: REGRESSION - ChildModule::ChildInterface reply handler "
141 "narrows to unrelated type.\n"));
145 poa_var
->destroy (1,0);
149 catch (const CORBA::Exception
& ex
)
151 ex
._tao_print_exception ("Caught exception:");