2 //=============================================================================
6 * This program tests the construction of RTCORBA policies, both
7 * through the generic ORB::create_policy interface and the
8 * RTCORBA specific interfaces.
10 * @author Irfan Pyarali
12 //=============================================================================
16 #include "tao/RTCORBA/RTCORBA.h"
17 #include "tao/AnyTypeCode/Any.h"
19 #include "ace/Log_Msg.h"
22 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
26 // Initialize the ORB first.
28 CORBA::ORB_init (argc
, argv
);
30 CORBA::Object_var object
=
31 orb
->resolve_initial_references ("RTORB");
33 RTCORBA::RTORB_var rtorb
=
34 RTCORBA::RTORB::_narrow (object
.in ());
37 * The following code should be reenabled once the OMG spec has
38 * been fixed such that a RTCORBA::PriorityModelPolicy can be
39 * created by using the ORB::create_policy interface.
42 RTCORBA::PriorityModelPolicy_var policy1 =
43 rtorb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
44 RTCORBA::minPriority);
46 CORBA::Any policy_value;
47 policy_value <<= RTCORBA::CLIENT_PROPAGATED;
48 policy_value <<= RTCORBA::minPriority;
50 CORBA::Policy_var policy =
51 orb->create_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE,
54 RTCORBA::PriorityModelPolicy_var policy2 =
55 RTCORBA::PriorityModelPolicy::_narrow (policy.in ());
57 ACE_ASSERT (policy1->priority_model () == policy2->priority_model ());
58 ACE_ASSERT (policy1->server_priority () == policy2->server_priority ());
64 RTCORBA::ThreadpoolId poolid
= 0;
66 RTCORBA::ThreadpoolPolicy_var policy1
=
67 rtorb
->create_threadpool_policy (poolid
);
69 CORBA::Any policy_value
;
70 policy_value
<<= poolid
;
72 CORBA::Policy_var policy
=
73 orb
->create_policy (RTCORBA::THREADPOOL_POLICY_TYPE
,
76 RTCORBA::ThreadpoolPolicy_var policy2
=
77 RTCORBA::ThreadpoolPolicy::_narrow (policy
.in ());
79 ACE_ASSERT (policy1
->threadpool () == policy2
->threadpool ());
83 RTCORBA::ProtocolList empty_protocols
;
85 RTCORBA::ServerProtocolPolicy_var policy1
=
86 rtorb
->create_server_protocol_policy (empty_protocols
);
88 CORBA::Any policy_value
;
89 policy_value
<<= empty_protocols
;
91 CORBA::Policy_var policy
=
92 orb
->create_policy (RTCORBA::SERVER_PROTOCOL_POLICY_TYPE
,
95 RTCORBA::ServerProtocolPolicy_var policy2
=
96 RTCORBA::ServerProtocolPolicy::_narrow (policy
.in ());
98 RTCORBA::ProtocolList_var protocols1
=
99 policy1
->protocols ();
100 RTCORBA::ProtocolList_var protocols2
=
101 policy2
->protocols ();
103 ACE_ASSERT (protocols1
->length () == protocols2
->length ());
107 RTCORBA::ProtocolList empty_protocols
;
109 RTCORBA::ClientProtocolPolicy_var policy1
=
110 rtorb
->create_client_protocol_policy (empty_protocols
);
112 CORBA::Any policy_value
;
113 policy_value
<<= empty_protocols
;
115 CORBA::Policy_var policy
=
116 orb
->create_policy (RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE
,
119 RTCORBA::ClientProtocolPolicy_var policy2
=
120 RTCORBA::ClientProtocolPolicy::_narrow (policy
.in ());
122 RTCORBA::ProtocolList_var protocols1
=
123 policy1
->protocols ();
124 RTCORBA::ProtocolList_var protocols2
=
125 policy2
->protocols ();
127 ACE_ASSERT (protocols1
->length () == protocols2
->length ());
131 RTCORBA::PrivateConnectionPolicy_var policy1
=
132 rtorb
->create_private_connection_policy ();
134 CORBA::Any policy_value
;
136 CORBA::Policy_var policy
=
137 orb
->create_policy (RTCORBA::PRIVATE_CONNECTION_POLICY_TYPE
,
140 RTCORBA::PrivateConnectionPolicy_var policy2
=
141 RTCORBA::PrivateConnectionPolicy::_narrow (policy
.in ());
145 RTCORBA::PriorityBands empty_priority_bands
;
147 RTCORBA::PriorityBandedConnectionPolicy_var policy1
=
148 rtorb
->create_priority_banded_connection_policy (empty_priority_bands
);
150 CORBA::Any policy_value
;
151 policy_value
<<= empty_priority_bands
;
153 CORBA::Policy_var policy
=
154 orb
->create_policy (RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE
,
157 RTCORBA::PriorityBandedConnectionPolicy_var policy2
=
158 RTCORBA::PriorityBandedConnectionPolicy::_narrow (policy
.in ());
160 RTCORBA::PriorityBands_var priority_bands1
=
161 policy1
->priority_bands ();
162 RTCORBA::PriorityBands_var priority_bands2
=
163 policy2
->priority_bands ();
165 ACE_ASSERT (priority_bands1
->length () == priority_bands2
->length ());
168 ACE_DEBUG ((LM_DEBUG
,
174 catch (const CORBA::Exception
& ex
)
176 ex
._tao_print_exception ("Exception caught");