Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / PluggableTopology / main.cpp
blob15fa9de6a2e73a08fee1df07a58f8628e643fde4
2 #include "orbsvcs/CosNotifyChannelAdminC.h"
3 //#include <orbsvcs/CosNotifyCommS.h>
4 //#include <orbsvcs/CosNotificationS.h>
5 #include "tao/TimeBaseC.h"
7 #include "ace/ARGV.h"
8 #include "ace/OS_NS_stdio.h"
10 using namespace CORBA;
11 namespace CNCA = CosNotifyChannelAdmin;
12 namespace CN = CosNotification;
13 namespace CNC = CosNotifyComm;
15 const char* NOTIFY_IOR = "corbaloc::localhost:9050/NotifyEventChannelFactory";
17 ORB_var orb;
18 CNCA::EventChannelFactory_var ecf;
20 namespace {
21 void init_qos_props(CN::QoSProperties& qos, bool topology_persist) {
22 qos.length(13);
23 ULong i = 0;
24 qos[i].name = "EventReliability";
25 qos[i++].value <<= CN::BestEffort;
26 if (topology_persist) {
27 qos[i].name = "ConnectionReliability";
28 qos[i++].value <<= CN::Persistent;
30 else
32 qos[i].name = "ConnectionReliability";
33 qos[i++].value <<= CN::BestEffort;
35 qos[i].name = "Priority";
36 qos[i++].value <<= (Short) 1234;
37 qos[i].name = "Timeout";
38 qos[i++].value <<= (TimeBase::TimeT) 55555; // 5.5555 ms
39 qos[i].name = "MaximumBatchSize";
40 qos[i++].value <<= (Long) 200;
41 qos[i].name = "PacingInterval";
42 qos[i++].value <<= (TimeBase::TimeT) 42000; // 4.2ms
43 qos[i].name = "StopTimeSupported";
44 qos[i++].value <<= Any::from_boolean(0);
45 qos.length(i);
47 void init_admin_props(CN::AdminProperties& admin) {
48 admin.length(13);
49 ULong i = 0;
50 admin[i].name = "MaxQueueLength";
51 admin[i++].value <<= (Long) 200;
52 admin[i].name = "MaxConsumers";
53 admin[i++].value <<= (Long) 2;
54 admin[i].name = "MaxSuppliers";
55 admin[i++].value <<= (Long) 1;
56 admin[i].name = "RejectNewEvents";
57 admin[i++].value <<= Any::from_boolean(1);
59 void setUp()
61 ACE_ARGV av;
62 int ac = 0;
63 orb = ORB_init(ac, av.argv());
64 ACE_ASSERT(! is_nil(orb.in()));
65 Object_var obj = orb->string_to_object(NOTIFY_IOR);
66 ACE_ASSERT(! is_nil(obj.in()));
67 ecf = CNCA::EventChannelFactory::_narrow(obj.in());
68 ACE_ASSERT(! is_nil(ecf.in()));
71 void tearDown()
73 ecf = CNCA::EventChannelFactory::_nil();
74 orb->destroy();
75 orb = ORB::_nil();
80 int ACE_TMAIN (int, ACE_TCHAR *[])
82 try
84 setUp();
86 CN::QoSProperties qos;
87 CN::AdminProperties admin;
88 init_qos_props(qos, true);
89 init_admin_props(admin);
91 CNCA::ChannelID ecid;
92 CNCA::EventChannel_var ec = ecf->create_channel(qos, admin, ecid);
94 ACE_OS::printf("Created channel id=\"%ld\"\n", static_cast<long>(ecid));
96 tearDown();
98 return 0;
100 catch (Exception& e)
102 ACE_OS::fputs(e._name (), stderr);
103 ACE_OS::fputs("\n", stderr);
105 return 1;