Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / lib / EventChannel_Command.cpp
blob68d4ad61f5e7b35657ff7aaedc41ad5326e58f40
1 #include "EventChannel_Command.h"
2 #include "ace/Log_Msg.h"
5 #include "LookupManager.h"
6 #include "Name.h"
7 #include "Options_Parser.h"
8 #include "orbsvcs/Notify/Service.h"
10 TAO_Notify_Tests_EventChannel_Command::TAO_Notify_Tests_EventChannel_Command ()
11 : collocated_ (0)
15 TAO_Notify_Tests_EventChannel_Command::~TAO_Notify_Tests_EventChannel_Command ()
19 const char*
20 TAO_Notify_Tests_EventChannel_Command::get_name ()
22 return TAO_Notify_Tests_EventChannel_Command::name ();
25 const char*
26 TAO_Notify_Tests_EventChannel_Command::name ()
28 return TAO_Notify_Tests_Name::event_channel_command;
31 void
32 TAO_Notify_Tests_EventChannel_Command::init (ACE_Arg_Shifter& arg_shifter)
34 if (arg_shifter.is_anything_left ())
36 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Create")) == 0) // -Create ec_name factory_name [COLLOCATED]
38 this->command_ = CREATE;
40 arg_shifter.consume_arg ();
42 this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
43 arg_shifter.consume_arg ();
45 this->factory_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
46 arg_shifter.consume_arg ();
48 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("COLLOCATED")) == 0)
50 this->collocated_ = 1;
53 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("COLOCATED")) == 0) // grandfather in misspelled
55 this->collocated_ = 1;
56 ACE_DEBUG ((LM_WARNING, "TAO_Notify_Tests_EventChannel_Command::init --"
57 " warning: deprecated misspelled COLOCATED option used.\n"));
60 else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Destroy")) == 0) // -Destroy ec_name
62 this->command_ = DESTROY;
64 arg_shifter.consume_arg ();
66 this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
68 arg_shifter.consume_arg ();
70 else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Set_QoS")) == 0) // -Set_QoS ec_name [Qos Options]
72 this->command_ = SET_QOS;
74 arg_shifter.consume_arg ();
76 this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
78 arg_shifter.consume_arg ();
80 TAO_Notify_Tests_Options_Parser qos_parser;
81 qos_parser.execute (this->qos_, arg_shifter);
86 void
87 TAO_Notify_Tests_EventChannel_Command::create_collocated_ecf ()
89 CosNotifyChannelAdmin::EventChannelFactory_var notify_factory;
91 // The Service Object.
92 TAO_Notify_Service* notify_service = TAO_Notify_Service::load_default ();
94 if (notify_service == 0)
96 ACE_DEBUG ((LM_DEBUG, "Service not found! check conf. file\n"));
97 return;
100 // Resolve some helpers.
101 CORBA::ORB_var orb;
102 PortableServer::POA_var poa;
103 CosNaming::NamingContextExt_var naming;
105 LOOKUP_MANAGER->resolve (orb);
107 LOOKUP_MANAGER->resolve (poa);
109 LOOKUP_MANAGER->resolve (naming);
111 notify_service->init_service (orb.in ());
113 // Activate the factory
114 notify_factory =
115 notify_service->create (poa.in ());
117 // Register with the Naming Service
118 CosNaming::Name_var name =
119 naming->to_name (TAO_Notify_Tests_Name::event_channel_factory);
121 naming->rebind (name.in (),
122 notify_factory.in ());
125 void
126 TAO_Notify_Tests_EventChannel_Command::handle_create ()
128 if (this->collocated_ == 1)
130 this->create_collocated_ecf ();
133 CosNotifyChannelAdmin::EventChannelFactory_var ec_factory;
135 LOOKUP_MANAGER->resolve (ec_factory , TAO_Notify_Tests_Name::event_channel_factory);
137 CosNotification::QoSProperties qos;
138 CosNotification::AdminProperties admin;
140 // Create an event channel
141 CosNotifyChannelAdmin::EventChannel_var ec =
142 ec_factory->create_channel (qos,
143 admin,
144 this->id_);
146 LOOKUP_MANAGER->_register (ec.in(), this->name_.c_str ());
149 void
150 TAO_Notify_Tests_EventChannel_Command::handle_destroy ()
152 ACE_DEBUG ((LM_DEBUG, "Destroying event channel %s\n", this->name_.c_str ()));
153 CosNotifyChannelAdmin::EventChannel_var ec;
155 LOOKUP_MANAGER->resolve (ec, this->name_.c_str ());
157 ec->destroy ();
159 void
160 TAO_Notify_Tests_EventChannel_Command::handle_set_qos ()
162 CosNotifyChannelAdmin::EventChannel_var ec;
164 LOOKUP_MANAGER->resolve (ec, this->name_.c_str ());
166 ec->set_qos (this->qos_);
169 void
170 TAO_Notify_Tests_EventChannel_Command::handle_status ()
172 //@@ TODO: Implement
175 void
176 TAO_Notify_Tests_EventChannel_Command::execute_i ()
178 if (this->command_ == CREATE)
180 this->handle_create ();
182 else if (this->command_ == DESTROY)
184 this->handle_destroy ();
186 else if (this->command_ == SET_QOS)
188 this->handle_set_qos ();
190 else if (this->command_ == DUMP_STATE)
192 this->handle_status ();