Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / lib / SupplierAdmin_Command.cpp
blob80ba61097f127fd15edd36e233bb4368f97643db
1 #include "SupplierAdmin_Command.h"
4 #include "LookupManager.h"
5 #include "Name.h"
6 #include "Options_Parser.h"
8 TAO_Notify_Tests_SupplierAdmin_Command::TAO_Notify_Tests_SupplierAdmin_Command ()
9 : ifgop_ (CosNotifyChannelAdmin::OR_OP), id_ (0)
13 TAO_Notify_Tests_SupplierAdmin_Command::~TAO_Notify_Tests_SupplierAdmin_Command ()
17 const char*
18 TAO_Notify_Tests_SupplierAdmin_Command::get_name ()
20 return TAO_Notify_Tests_SupplierAdmin_Command::name ();
23 const char*
24 TAO_Notify_Tests_SupplierAdmin_Command::name ()
26 return TAO_Notify_Tests_Name::supplier_admin_command;
29 void
30 TAO_Notify_Tests_SupplierAdmin_Command::init (ACE_Arg_Shifter& arg_shifter)
32 if (arg_shifter.is_anything_left ())
34 /// -Create sa_name factory_name
35 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Create")) == 0)
37 this->command_ = CREATE;
39 arg_shifter.consume_arg ();
41 this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
42 arg_shifter.consume_arg ();
44 this->factory_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
45 arg_shifter.consume_arg ();
47 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-AND_OP")) == 0)
49 arg_shifter.consume_arg ();
51 this->ifgop_ = CosNotifyChannelAdmin::AND_OP;
53 else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-OR_OP")) == 0)
55 arg_shifter.consume_arg ();
57 this->ifgop_ = CosNotifyChannelAdmin::OR_OP;
60 else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Offer")) == 0)
61 // -Subscription admin_name +added_type1 +-added_type2 ... -added_type3 -added_type4..
63 this->command_ = OFFER;
65 arg_shifter.consume_arg ();
67 this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
68 arg_shifter.consume_arg ();
70 TAO_Notify_Tests_Options_Parser options_parser;
71 options_parser.execute (this->added_, this->removed_, arg_shifter);
72 } // Subscription
73 else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Set_QoS")) == 0) // -Set_QoS ec_name [Qos Options]
75 this->command_ = SET_QOS;
77 arg_shifter.consume_arg ();
79 this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ());
81 arg_shifter.consume_arg ();
83 TAO_Notify_Tests_Options_Parser qos_parser;
84 qos_parser.execute (this->qos_, arg_shifter);
86 } /* if */
89 void
90 TAO_Notify_Tests_SupplierAdmin_Command::handle_create ()
92 CosNotifyChannelAdmin::EventChannel_var ec;
94 LOOKUP_MANAGER->resolve (ec, this->factory_.c_str ());
96 // create supplier admin
97 CosNotifyChannelAdmin::SupplierAdmin_var sa =
98 ec->new_for_suppliers (this->ifgop_,
99 this->id_);
101 LOOKUP_MANAGER->_register (sa.in(), this->name_.c_str ());
104 void
105 TAO_Notify_Tests_SupplierAdmin_Command::handle_offers ()
107 CosNotifyChannelAdmin::SupplierAdmin_var admin;
109 LOOKUP_MANAGER->resolve (admin, this->name_.c_str ());
111 // Let the user see what we're subscribed for,
112 ACE_DEBUG ((LM_DEBUG, "Calling SupplierAdmin offer_change : "));
114 CORBA::ULong i = 0;
116 for (; i < added_.length (); ++i)
118 ACE_DEBUG ((LM_DEBUG, "+(%s,%s), ", added_[i].domain_name.in (), added_[i].type_name.in ()));
120 for (i = 0; i < removed_.length (); ++i)
122 ACE_DEBUG ((LM_DEBUG, "-(%s,%s), ", removed_[i].domain_name.in (), removed_[i].type_name.in ()));
125 ACE_DEBUG ((LM_DEBUG, "\n"));
127 admin->offer_change (this->added_, this->removed_);
130 void
131 TAO_Notify_Tests_SupplierAdmin_Command::handle_status ()
135 void
136 TAO_Notify_Tests_SupplierAdmin_Command::handle_set_qos ()
138 CosNotifyChannelAdmin::SupplierAdmin_var admin;
140 LOOKUP_MANAGER->resolve (admin, this->name_.c_str ());
142 admin->set_qos (this->qos_);
145 void
146 TAO_Notify_Tests_SupplierAdmin_Command::execute_i ()
148 if (this->command_ == CREATE)
150 this->handle_create ();
152 else if (this->command_ == OFFER)
154 this->handle_offers ();
156 else if (this->command_ == SET_QOS)
158 this->handle_set_qos ();
160 else if (this->command_ == DUMP_STATE)
162 this->handle_status ();