void TAO_Notify_Tests_EventChannel_Command::init (ACE_Arg_Shifter& arg_shifter) { if (arg_shifter.is_anything_left ()) { if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Create")) == 0) // -Create ec_name factory_name [COLLOCATED] { this->command_ = CREATE; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); this->factory_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("COLLOCATED")) == 0) { this->collocated_ = 1; } if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("COLOCATED")) == 0) // grandfather in misspelled { this->collocated_ = 1; ACE_DEBUG ((LM_WARNING, "TAO_Notify_Tests_EventChannel_Command::init --" " warning: deprecated misspelled COLOCATED option used.\n")); } } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Destroy")) == 0) // -Destroy ec_name { this->command_ = DESTROY; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Set_QoS")) == 0) // -Set_QoS ec_name [Qos Options] { this->command_ = SET_QOS; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); TAO_Notify_Tests_Options_Parser qos_parser; qos_parser.execute (this->qos_, arg_shifter); } } }
int Job_i::init (ACE_Arg_Shifter& arg_shifter) { // Read the name of the Job job_name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); // Read the name of the POA POA_name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); return 0; }
void TAO_Notify_Tests_Options_Parser::execute (CosNotification::EventTypeSeq& added, CosNotification::EventTypeSeq& removed, ACE_Arg_Shifter& arg_shifter) { const ACE_TCHAR* current_arg = 0; while (arg_shifter.is_anything_left ()) { current_arg = arg_shifter.get_current (); arg_shifter.consume_arg (); if (current_arg[0] == '+') { // create 1 more space. int seq_ln = added.length (); added.length (seq_ln + 1); added[seq_ln].domain_name = CORBA::string_dup ("*"); added[seq_ln].type_name = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(++current_arg)); // Skip the '+' sign. } else if (current_arg[0] == '-') { // create 1 more space. int seq_ln = removed.length (); removed.length (seq_ln + 1); removed[seq_ln].domain_name = CORBA::string_dup ("*"); removed[seq_ln].type_name = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(++current_arg)); // Skip the '-' sign. } } }
int Client_Options::boolean_option (ACE_Arg_Shifter &arg_shifter, const ACE_TCHAR *option_name, int &option_value) { if (ACE_OS::strcmp (arg_shifter.get_current (), option_name) != 0) return 0; arg_shifter.consume_arg (); option_value = 1; return 1; }
int DT_Creator::dt_task_init (ACE_Arg_Shifter& arg_shifter) { static int dt_index = 0; time_t start_time = 0; int load = 0; int iter = 0; int importance = 0; char *job_name = 0; int dist = 0; const ACE_TCHAR* current_arg = 0; if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Importance")) == 0) { arg_shifter.consume_arg (); current_arg = arg_shifter.get_current (); importance = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Start_Time")))) { start_time = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Iter")))) { iter = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Load")))) { load = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-JobName")))) { job_name = (char *)current_arg; dist = 1; arg_shifter.consume_arg (); } dt_list_ [dt_index++] = this->create_thr_task (importance, start_time, load, iter, dist, job_name); return 0; }
int Client_Options::option (ACE_Arg_Shifter &arg_shifter, const ACE_TCHAR *option_name, int &option_value) { if (ACE_OS::strcmp (arg_shifter.get_current (), option_name) != 0) return 0; arg_shifter.consume_arg (); if (arg_shifter.is_parameter_next ()) { option_value = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); } else { ACE_DEBUG ((LM_DEBUG, "Missing value for option '%s'\n", option_name)); } return 1; }
void TAO_Notify_Tests_Options_Parser::execute (CosNotification::QoSProperties& qos, ACE_Arg_Shifter& arg_shifter) { const ACE_TCHAR *current_arg = 0; NotifyExt::Priority default_priority = NotifyExt::minPriority; if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-ThreadPool")) == 0) // -ThreadPool [-Threads static_threads] [-Priority default_priority] { arg_shifter.consume_arg (); CORBA::ULong static_threads = 1u; if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Threads")) == 0) { arg_shifter.consume_arg (); current_arg = arg_shifter.get_current (); static_threads = static_cast<CORBA::ULong> (ACE_OS::atoi (current_arg)); arg_shifter.consume_arg (); } if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Priority")) == 0) { arg_shifter.consume_arg (); current_arg = arg_shifter.get_current (); const int priority= ACE_OS::atoi (current_arg); if (priority < NotifyExt::minPriority) { NotifyExt::Priority default_priority = NotifyExt::minPriority; ACE_DEBUG ((LM_DEBUG, "-Priority %d is too small (min priority %d used)\n", priority, static_cast<int> (default_priority))); } else if (NotifyExt::maxPriority < priority) { NotifyExt::Priority default_priority = NotifyExt::maxPriority; ACE_DEBUG ((LM_DEBUG, "-Priority %d is too large (max priority %d used)\n", priority, static_cast<int> (default_priority))); } else default_priority = static_cast<NotifyExt::Priority> (priority); arg_shifter.consume_arg (); } NotifyExt::ThreadPoolParams tp_params = { NotifyExt::CLIENT_PROPAGATED, default_priority, 0, static_threads, 0, default_priority, 0, 0, 0 }; qos.length (1); qos[0].name = CORBA::string_dup (NotifyExt::ThreadPool); qos[0].value <<= tp_params; } /* ThreadPool */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Lanes")) == 0) // -Lanes lane_count -Lane prio static_thr dy_thr { arg_shifter.consume_arg (); current_arg = arg_shifter.get_current (); int lanecount = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); NotifyExt::ThreadPoolLanesParams tpl_params; tpl_params.priority_model = NotifyExt::CLIENT_PROPAGATED; tpl_params.server_priority = default_priority; tpl_params.stacksize = 0; tpl_params.lanes.length (lanecount); tpl_params.allow_borrowing = 0; tpl_params.allow_request_buffering = 0; tpl_params.max_buffered_requests = 0; tpl_params.max_request_buffer_size = 0; int l_index = 0; //parse lane values ... while (arg_shifter.is_anything_left ()) { if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Lane")) == 0) { arg_shifter.consume_arg (); // read priority tpl_params.lanes[l_index].lane_priority = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); // static thread count tpl_params.lanes[l_index].static_threads = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); // dynamic thread count tpl_params.lanes[l_index].dynamic_threads = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "QoS Parser parsed lane: - %d, %d, %d\n", tpl_params.lanes[l_index].lane_priority, tpl_params.lanes[l_index].static_threads, tpl_params.lanes[l_index].dynamic_threads)); l_index++; } else break; } /* while -- lane values */ qos.length (1); qos[0].name = CORBA::string_dup (NotifyExt::ThreadPoolLanes); qos[0].value <<= tpl_params; } /* ThreadPoolLane */ }
void TAO_Notify_Tests_Filter_Command::init (ACE_Arg_Shifter& arg_shifter) { if (arg_shifter.is_anything_left ()) { if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-CreateFactory")) == 0) // -Create factory_name ec { this->command_ = CREATE_FACTORY; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); // FF name arg_shifter.consume_arg (); this->factory_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); //EC arg_shifter.consume_arg (); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-CreateFilter")) == 0) // -CreateFilter filter_name filterfactory_name { this->command_ = CREATE_FILTER; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); // Filter name arg_shifter.consume_arg (); this->factory_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); //FF arg_shifter.consume_arg (); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Add_Constraint")) == 0) // -Add_Constraint filter_name constraint_expr { this->command_ = ADD_CONSTRAINT; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); // Filter name arg_shifter.consume_arg (); this->constraint_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); //Constraint arg_shifter.consume_arg (); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Add_Filter")) == 0) // -Add_Filter filter_name FilterAdmin_Name { this->command_ = ADD_FILTER; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); // Filter name arg_shifter.consume_arg (); this->factory_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); //FilterAdmin arg_shifter.consume_arg (); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Destroy")) == 0) // -Destroy filter_name { this->command_ = DESTROY; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); // filter arg_shifter.consume_arg (); } } }
int Periodic_Task::init_task (ACE_Arg_Shifter& arg_shifter) { const ACE_TCHAR *current_arg = 0; while (arg_shifter.is_anything_left ()) { if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-JobName")))) { name_ = ACE_TEXT_ALWAYS_CHAR(current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Priority")))) { task_priority_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Period")))) { period_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ExecTime")))) { exec_time_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Phase")))) { phase_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Iter")))) { iter_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); // create the stat object. ACE_NEW_RETURN (task_stats_, Task_Stats (iter_), -1); if (task_stats_->init () == -1) return -1; } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Load")))) { load_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); return 0; } else { ACE_DEBUG ((LM_DEBUG, "parse Task unknown option %s\n", arg_shifter.get_current ())); if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "name %s, priority %d, period %duS, exec_time %duS, phase %duS, iter %d, load %d\n", name_.c_str(), task_priority_, period_, exec_time_, phase_, iter_, load_)); break; } } return 0; }
void TAO_Notify_Tests_Periodic_Consumer_Command::init (ACE_Arg_Shifter& arg_shifter) { if (arg_shifter.is_anything_left ()) { /// -Create consumer_name admin_name -POA [POA_name] consumer_specific_options if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Create")) == 0) { this->command_ = CREATE; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); int is_relay = 0; int is_direct = 0; ACE_CString relay_destination; if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Relay")) == 0) { is_relay = 1; arg_shifter.consume_arg (); relay_destination = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Direct")) == 0) { is_direct = 1; arg_shifter.consume_arg (); } TAO_Notify_Tests_Periodic_Consumer* consumer = 0; // create the consumer if (is_relay == 1) consumer = new TAO_Notify_Tests_Relay_Consumer (relay_destination); else if (is_direct == 1) consumer = new TAO_Notify_Tests_Direct_Consumer (); else consumer = new TAO_Notify_Tests_Periodic_Consumer (); consumer->set_name (this->name_); TAO_Notify_Tests_Activation_Manager* act_mgr = 0; LOOKUP_MANAGER->resolve (act_mgr); { act_mgr->_register (consumer, this->name_.c_str ()); } consumer->init_state (arg_shifter); } /* -Create */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Subscription")) == 0) // -Subscription admin_name +added_type1 +-added_type2 ... -added_type3 -added_type4.. { this->command_ = SUBSCRIPTION; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); TAO_Notify_Tests_Options_Parser options_parser; options_parser.execute (this->added_, this->removed_, arg_shifter); } /* Subscription */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Disconnect")) == 0) // { this->command_ = DISCONNECT; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); } /* disconnect */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Deactivate")) == 0) // { this->command_ = DEACTIVATE; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); } /* deactivate */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Status")) == 0) // { this->command_ = DUMP_STATE; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); } /* -Dump */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Set_QoS")) == 0) // -Set_QoS ec_name [Qos Options] { this->command_ = SET_QOS; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); TAO_Notify_Tests_Options_Parser qos_parser; qos_parser.execute (this->qos_, arg_shifter); } } }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { // Initialize DomainParticipantFactory DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); enum { READER, WRITER } mode = READER; bool toggle = false; { // New scope. ACE_Arg_Shifter shifter (argc, argv); while (shifter.is_anything_left ()) { const ACE_TCHAR* x = shifter.get_current(); if (ACE_OS::strcmp(x, ACE_TEXT("-reader")) == 0) { mode = READER; } if (ACE_OS::strcmp(x, ACE_TEXT("-writer")) == 0) { mode = WRITER; } if (ACE_OS::strcmp(x, ACE_TEXT("-toggle")) == 0) { toggle = true; } shifter.consume_arg (); } } // Create DomainParticipant DDS::DomainParticipantQos dp_qos; dpf->get_default_participant_qos(dp_qos); dp_qos.user_data.value.length(6); dp_qos.user_data.value[0] = 0; dp_qos.user_data.value[1] = 0; dp_qos.user_data.value[2] = 0; dp_qos.user_data.value[3] = 0; dp_qos.user_data.value[4] = 0; dp_qos.user_data.value[5] = (mode == READER) ? 0 : 1; DDS::DomainParticipant_var participant = dpf->create_participant(DOMAIN_ID, dp_qos, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (!participant) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" create_participant failed!\n")), -1); } // Register TypeSupport TestMsgTypeSupport_var ts = new TestMsgTypeSupportImpl; if (ts->register_type(participant, "") != DDS::RETCODE_OK) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" register_type failed!\n")), -1); } // Create Topic CORBA::String_var type_name = ts->get_type_name(); DDS::Topic_var topic = participant->create_topic("TheTopic", type_name, TOPIC_QOS_DEFAULT, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (!topic) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" create_topic failed!\n")), -1); } int return_code = 1; switch (mode) { case READER: return_code = do_reader(participant, topic, toggle); break; case WRITER: return_code = do_writer(participant, topic, toggle); break; } // Clean-up! participant->delete_contained_entities(); dpf->delete_participant(participant); TheServiceParticipant->shutdown(); return return_code; } catch (const CORBA::Exception& e) { e._tao_print_exception("Exception caught in main():"); return -1; } return 0; }
int POA_Holder::init (ACE_Arg_Shifter& arg_shifter) { ACE_DEBUG ((LM_DEBUG, "Init POA\n")); const ACE_TCHAR *current_arg = 0; POA_name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); // Read the name of the POA arg_shifter.consume_arg (); while (arg_shifter.is_anything_left ()) { if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-PriorityModel")))) { if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("CLIENT")) == 0) priority_model_ = RTCORBA::CLIENT_PROPAGATED; else priority_model_ = RTCORBA::SERVER_DECLARED; arg_shifter.consume_arg (); server_priority_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Lanes")))) { int lanecount = ACE_OS::atoi (current_arg); lanes_.length (lanecount); arg_shifter.consume_arg (); int l_index = 0; //parse lane values ... while (arg_shifter.is_anything_left ()) { if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Lane")) == 0) { arg_shifter.consume_arg (); // read priority lanes_[l_index].lane_priority = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); // static thread count lanes_[l_index].static_threads = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); // dynamic thread count lanes_[l_index].dynamic_threads = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); //if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "lane parsed - %d, %d, %d\n", lanes_[l_index].lane_priority, lanes_[l_index].static_threads, lanes_[l_index].dynamic_threads)); l_index++; } else break; } /* while -- lane values */ } /* if -Lanes */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-ThreadPool")) == 0) { ACE_DEBUG ((LM_DEBUG, "Thread Pool\n")); arg_shifter.consume_arg (); thread_pool_ = 1; // read priority tp_static_threads_ = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); tp_dynamic_threads_ = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); tp_priority_ = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); ACE_DEBUG ((LM_DEBUG, "Thread Pool Initialized\n")); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Bands")))) { ACE_DEBUG ((LM_DEBUG, "Initializing Bands\n")); int bandcount = ACE_OS::atoi (current_arg); bands_.length (bandcount); arg_shifter.consume_arg (); int b_index = 0; //parse band values ... while (arg_shifter.is_anything_left ()) { if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Band")) == 0) { arg_shifter.consume_arg (); // read low bands_[b_index].low = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); // read high bands_[b_index].high = ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); //if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "band parsed - %d, %d\n", bands_[b_index].low, bands_[b_index].high)); b_index++; } else break; } /* while -- Band values */ ACE_DEBUG ((LM_DEBUG, "Bands Initialized\n")); } /* if -Bands */ else // something else is showing up ... { ACE_DEBUG ((LM_DEBUG, "Finish Init POA\n")); return 0; } } ACE_DEBUG ((LM_DEBUG, "Finish Init POA\n")); return 0; }
int Activator_Options::parse_args (int &argc, ACE_TCHAR *argv[]) { ACE_Arg_Shifter shifter (argc, argv); while (shifter.is_anything_left ()) { if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-c")) == 0) { shifter.consume_arg (); if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') { ORBSVCS_ERROR ((LM_ERROR, "Error: -c option needs a command\n")); this->print_usage (); return -1; } if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("install")) == 0) { this->service_command_ = SC_INSTALL; } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("remove")) == 0) { this->service_command_ = SC_REMOVE; } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("install_no_imr")) == 0) { this->service_command_ = SC_INSTALL_NO_LOCATOR; } else { ORBSVCS_ERROR((LM_ERROR, "Error: Unknown service command : %s\n", shifter.get_current())); this->print_usage (); return -1; } } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-d")) == 0) { shifter.consume_arg (); if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') { ORBSVCS_ERROR ((LM_ERROR, "Error: -d option needs a debuglevel\n")); this->print_usage (); return -1; } this->debug_ = ACE_OS::atoi (shifter.get_current ()); } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-e")) == 0) { shifter.consume_arg (); if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') { ORBSVCS_ERROR ((LM_ERROR, "Error: -e option needs " "an environment buffer length\n")); this->print_usage (); return -1; } this->env_buf_len_ = ACE_OS::atoi (shifter.get_current ()); } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-m")) == 0) { shifter.consume_arg (); if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') { ORBSVCS_ERROR ((LM_ERROR, "Error: -m option needs " "a maximum number of environment vars\n")); this->print_usage (); return -1; } this->max_env_vars_ = ACE_OS::atoi (shifter.get_current ()); } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-o")) == 0) { shifter.consume_arg (); if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') { ORBSVCS_ERROR ((LM_ERROR, "Error: -o option needs a filename\n")); this->print_usage (); return -1; } this->ior_output_file_ = shifter.get_current (); } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-s")) == 0) { this->service_ = true; } else if ((ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-?")) == 0) || (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-h")) == 0)) { this->print_usage (); return 1; } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-n")) == 0) { shifter.consume_arg (); if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') { ORBSVCS_ERROR ((LM_ERROR, "Error: -n option needs a name\n")); this->print_usage (); return -1; } this->name_ = ACE_TEXT_ALWAYS_CHAR(shifter.get_current ()); } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-l")) == 0) { this->notify_imr_ = true; } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-delay")) == 0) { shifter.consume_arg (); if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') { ORBSVCS_ERROR ((LM_ERROR, "Error: -delay option needs a value\n")); this->print_usage (); return -1; } this->induce_delay_ = ACE_OS::atoi (shifter.get_current ()); } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-detach")) == 0) { shifter.consume_arg (); if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-') { ORBSVCS_ERROR ((LM_ERROR, "Error: -detach option needs a value\n")); this->print_usage (); return -1; } this->detach_child_ = ACE_OS::atoi (shifter.get_current ()) != 0; } else { shifter.ignore_arg (); continue; } shifter.consume_arg (); } return 0; }
void TAO_Notify_Tests_Periodic_Supplier_Command::init (ACE_Arg_Shifter& arg_shifter) { if (arg_shifter.is_anything_left ()) { /// -Create supplier_name admin_name -POA [POA_name] supplier_specific_options if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Create")) == 0) { this->command_ = CREATE; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); int is_direct = 0; ACE_CString direct_target; if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Direct")) == 0) { is_direct = 1; arg_shifter.consume_arg (); direct_target = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); } TAO_Notify_Tests_Periodic_Supplier* supplier = 0; // create the supplier if (is_direct == 1) supplier = new TAO_Notify_Tests_Direct_Supplier (direct_target); else supplier = new TAO_Notify_Tests_Periodic_Supplier (); supplier->set_name (this->name_); TAO_Notify_Tests_Activation_Manager* act_mgr = 0; LOOKUP_MANAGER->resolve (act_mgr); { act_mgr->_register (supplier, this->name_.c_str ()); } supplier->init_state (arg_shifter); } /* -Create */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Offer")) == 0) // -Offer supplier_name +added_type1 +-added_type2 ... -added_type3 -added_type4.. { this->command_ = OFFER; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); TAO_Notify_Tests_Options_Parser options_parser; options_parser.execute (this->added_, this->removed_, arg_shifter); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Disconnect")) == 0) // { this->command_ = DISCONNECT; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); } /* disconnect */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Deactivate")) == 0) // { this->command_ = DEACTIVATE; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); } /* deactivate */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Status")) == 0) // { this->command_ = DUMP_STATE; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); } /* -Dump */ else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Set_QoS")) == 0) // -Set_QoS ec_name [Qos Options] { this->command_ = SET_QOS; arg_shifter.consume_arg (); this->name_ = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); TAO_Notify_Tests_Options_Parser qos_parser; qos_parser.execute (this->qos_, arg_shifter); } } /* if */ }
int TAO_Notify_Tests_Periodic_Supplier::init_state (ACE_Arg_Shifter& arg_shifter) { // First, let the base class look for options. if (TAO_Notify_Tests_StructuredPushSupplier::init_state (arg_shifter) == -1) return -1; const ACE_TCHAR *current_arg = 0; while (arg_shifter.is_anything_left ()) { if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-EventType")))) { this->event_.type ("*", ACE_TEXT_ALWAYS_CHAR(current_arg)) ; zeroth_event.type ("*", ACE_TEXT_ALWAYS_CHAR(current_arg)) ; arg_shifter.consume_arg (); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-FilterLongData")) == 0) // -FilterLongData name value { arg_shifter.consume_arg (); ACE_CString name = ACE_TEXT_ALWAYS_CHAR(arg_shifter.get_current ()); arg_shifter.consume_arg (); CORBA::Long value = (CORBA::Long)ACE_OS::atoi (arg_shifter.get_current ()); arg_shifter.consume_arg (); CORBA::Any buffer; buffer <<= (CORBA::Long) value; this->event_.filter (name.c_str (), buffer); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Priority")))) { priority_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); CORBA::Any buffer; buffer <<= (CORBA::Short) this->priority_; this->event_.qos (CosNotification::Priority, buffer); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Period")))) { period_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ExecTime")))) { exec_time_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Phase")))) { phase_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Iter")))) { iter_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); if (stats_.init (iter_) == -1) return -1; } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-Load")))) { load_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-RunTime")))) // in seconds { run_time_ = ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else { ACE_DEBUG ((LM_DEBUG, "parse Task unknown option %s\n", arg_shifter.get_current ())); if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "event type %s, priority %d, period %duS, exec_time %duS, phase %duS, iter %d, load %d\n", event_.type(), priority_, period_, exec_time_, phase_, iter_, load_)); break; } } return 0; }