Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / lib / ConsumerAdmin_Command.cpp
blob2e8163b495d378356d6073a7a7ea5088ef6edd37
1 #include "ConsumerAdmin_Command.h"
4 #include "LookupManager.h"
5 #include "Name.h"
6 #include "Options_Parser.h"
8 TAO_Notify_Tests_ConsumerAdmin_Command::TAO_Notify_Tests_ConsumerAdmin_Command ()
9 :ifgop_ (CosNotifyChannelAdmin::OR_OP), id_ (0)
13 TAO_Notify_Tests_ConsumerAdmin_Command::~TAO_Notify_Tests_ConsumerAdmin_Command ()
17 const char*
18 TAO_Notify_Tests_ConsumerAdmin_Command::get_name ()
20 return TAO_Notify_Tests_ConsumerAdmin_Command::name ();
23 const char*
24 TAO_Notify_Tests_ConsumerAdmin_Command::name ()
26 return TAO_Notify_Tests_Name::consumer_admin_command;
29 void
30 TAO_Notify_Tests_ConsumerAdmin_Command::handle_create ()
32 CosNotifyChannelAdmin::EventChannel_var ec;
34 LOOKUP_MANAGER->resolve (ec, this->factory_.c_str ());
36 // create consumer admin
37 CosNotifyChannelAdmin::ConsumerAdmin_var sa =
38 ec->new_for_consumers (this->ifgop_,
39 this->id_);
41 LOOKUP_MANAGER->_register (sa.in(), this->name_.c_str ());
45 void
46 TAO_Notify_Tests_ConsumerAdmin_Command::handle_subscriptions ()
48 CosNotifyChannelAdmin::ConsumerAdmin_var admin;
50 LOOKUP_MANAGER->resolve (admin, this->name_.c_str ());
52 // Let the user see what we're subscribed for,
53 ACE_DEBUG ((LM_DEBUG, "Calling ConsumerAdmin subscription_change : "));
55 CORBA::ULong i = 0;
57 for (; i < added_.length (); ++i)
59 ACE_DEBUG ((LM_DEBUG, "+(%s,%s), ", added_[i].domain_name.in (), added_[i].type_name.in ()));
61 for (i = 0; i < removed_.length (); ++i)
63 ACE_DEBUG ((LM_DEBUG, "-(%s,%s), ", removed_[i].domain_name.in (), removed_[i].type_name.in ()));
66 ACE_DEBUG ((LM_DEBUG, "\n"));
68 admin->subscription_change (this->added_, this->removed_);
71 void
72 TAO_Notify_Tests_ConsumerAdmin_Command::handle_set_qos ()
74 CosNotifyChannelAdmin::ConsumerAdmin_var admin;
76 LOOKUP_MANAGER->resolve (admin, this->name_.c_str ());
78 admin->set_qos (this->qos_);
81 void
82 TAO_Notify_Tests_ConsumerAdmin_Command::handle_status ()
84 //@@ TODO:
87 void
88 TAO_Notify_Tests_ConsumerAdmin_Command::init (ACE_Arg_Shifter& arg_shifter)
90 if (arg_shifter.is_anything_left ())
92 /// -Create ca_name factory_name
93 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Create")) == 0)
95 this->command_ = CREATE;
97 arg_shifter.consume_arg ();
99 this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
100 arg_shifter.consume_arg ();
102 this->factory_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
103 arg_shifter.consume_arg ();
105 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-AND_OP")) == 0)
107 arg_shifter.consume_arg ();
109 this->ifgop_ = CosNotifyChannelAdmin::AND_OP;
111 else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-OR_OP")) == 0)
113 arg_shifter.consume_arg ();
115 this->ifgop_ = CosNotifyChannelAdmin::OR_OP;
118 else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Subscription")) == 0) // -Subscription admin_name +added_type1 +-added_type2 ... -added_type3 -added_type4..
120 this->command_ = SUBSCRIPTION;
122 arg_shifter.consume_arg ();
124 this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
125 arg_shifter.consume_arg ();
127 TAO_Notify_Tests_Options_Parser options_parser;
128 options_parser.execute (this->added_, this->removed_, arg_shifter);
130 else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Set_QoS")) == 0) // -Set_QoS admin_name [Qos Options]
132 this->command_ = SET_QOS;
134 arg_shifter.consume_arg ();
136 this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
138 arg_shifter.consume_arg ();
140 TAO_Notify_Tests_Options_Parser qos_parser;
141 qos_parser.execute (this->qos_, arg_shifter);
146 void
147 TAO_Notify_Tests_ConsumerAdmin_Command::execute_i ()
149 if (this->command_ == CREATE)
151 this->handle_create ();
153 else if (this->command_ == SUBSCRIPTION)
155 this->handle_subscriptions ();
157 else if (this->command_ == SET_QOS)
159 this->handle_set_qos ();
161 else if (this->command_ == DUMP_STATE)
163 this->handle_status ();