Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / lib / Options_Parser.cpp
blob88d482374648abd637cb7ee3f31869e098126b12
1 #include "Options_Parser.h"
2 #include "orbsvcs/NotifyExtC.h"
3 #include "tao/debug.h"
4 #include "ace/Log_Msg.h"
6 TAO_Notify_Tests_Options_Parser::TAO_Notify_Tests_Options_Parser ()
10 TAO_Notify_Tests_Options_Parser::~TAO_Notify_Tests_Options_Parser ()
14 void
15 TAO_Notify_Tests_Options_Parser::execute (CosNotification::EventTypeSeq& added, CosNotification::EventTypeSeq& removed, ACE_Arg_Shifter& arg_shifter)
17 const ACE_TCHAR* current_arg = 0;
19 while (arg_shifter.is_anything_left ())
21 current_arg = arg_shifter.get_current ();
22 arg_shifter.consume_arg ();
24 if (current_arg[0] == '+')
26 // create 1 more space.
27 int seq_ln = added.length ();
28 added.length (seq_ln + 1);
30 added[seq_ln].domain_name = CORBA::string_dup ("*");
31 added[seq_ln].type_name = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(++current_arg)); // Skip the '+' sign.
33 else if (current_arg[0] == '-')
35 // create 1 more space.
36 int seq_ln = removed.length ();
37 removed.length (seq_ln + 1);
39 removed[seq_ln].domain_name = CORBA::string_dup ("*");
40 removed[seq_ln].type_name = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(++current_arg)); // Skip the '-' sign.
45 void
46 TAO_Notify_Tests_Options_Parser::execute (CosNotification::QoSProperties& qos, ACE_Arg_Shifter& arg_shifter)
48 const ACE_TCHAR *current_arg = 0;
49 NotifyExt::Priority default_priority = NotifyExt::minPriority;
51 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-ThreadPool")) == 0) // -ThreadPool [-Threads static_threads] [-Priority default_priority]
53 arg_shifter.consume_arg ();
55 CORBA::ULong static_threads = 1u;
57 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Threads")) == 0)
59 arg_shifter.consume_arg ();
61 current_arg = arg_shifter.get_current ();
63 static_threads = static_cast<CORBA::ULong> (ACE_OS::atoi (current_arg));
65 arg_shifter.consume_arg ();
68 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Priority")) == 0)
70 arg_shifter.consume_arg ();
71 current_arg = arg_shifter.get_current ();
72 const int priority= ACE_OS::atoi (current_arg);
73 if (priority < NotifyExt::minPriority)
75 NotifyExt::Priority default_priority = NotifyExt::minPriority;
76 ACE_DEBUG ((LM_DEBUG, "-Priority %d is too small (min priority %d used)\n",
77 priority, static_cast<int> (default_priority)));
79 else if (NotifyExt::maxPriority < priority)
81 NotifyExt::Priority default_priority = NotifyExt::maxPriority;
82 ACE_DEBUG ((LM_DEBUG, "-Priority %d is too large (max priority %d used)\n",
83 priority, static_cast<int> (default_priority)));
85 else
86 default_priority = static_cast<NotifyExt::Priority> (priority);
88 arg_shifter.consume_arg ();
91 NotifyExt::ThreadPoolParams tp_params
92 = { NotifyExt::CLIENT_PROPAGATED, default_priority,
93 0, static_threads, 0, default_priority, 0, 0, 0 };
95 qos.length (1);
96 qos[0].name = CORBA::string_dup (NotifyExt::ThreadPool);
97 qos[0].value <<= tp_params;
98 } /* ThreadPool */
99 else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Lanes")) == 0) // -Lanes lane_count -Lane prio static_thr dy_thr
101 arg_shifter.consume_arg ();
103 current_arg = arg_shifter.get_current ();
104 int lanecount = ACE_OS::atoi (current_arg);
106 arg_shifter.consume_arg ();
108 NotifyExt::ThreadPoolLanesParams tpl_params;
110 tpl_params.priority_model = NotifyExt::CLIENT_PROPAGATED;
111 tpl_params.server_priority = default_priority;
112 tpl_params.stacksize = 0;
113 tpl_params.lanes.length (lanecount);
114 tpl_params.allow_borrowing = 0;
115 tpl_params.allow_request_buffering = 0;
116 tpl_params.max_buffered_requests = 0;
117 tpl_params.max_request_buffer_size = 0;
119 int l_index = 0;
120 //parse lane values ...
121 while (arg_shifter.is_anything_left ())
123 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-Lane")) == 0)
125 arg_shifter.consume_arg ();
127 // read priority
128 tpl_params.lanes[l_index].lane_priority = ACE_OS::atoi (arg_shifter.get_current ());
129 arg_shifter.consume_arg ();
131 // static thread count
132 tpl_params.lanes[l_index].static_threads = ACE_OS::atoi (arg_shifter.get_current ());
133 arg_shifter.consume_arg ();
135 // dynamic thread count
136 tpl_params.lanes[l_index].dynamic_threads = ACE_OS::atoi (arg_shifter.get_current ());
137 arg_shifter.consume_arg ();
139 if (TAO_debug_level > 0)
140 ACE_DEBUG ((LM_DEBUG, "QoS Parser parsed lane: - %d, %d, %d\n",
141 tpl_params.lanes[l_index].lane_priority, tpl_params.lanes[l_index].static_threads, tpl_params.lanes[l_index].dynamic_threads));
142 l_index++;
144 else
145 break;
146 } /* while -- lane values */
148 qos.length (1);
149 qos[0].name = CORBA::string_dup (NotifyExt::ThreadPoolLanes);
150 qos[0].value <<= tpl_params;
151 } /* ThreadPoolLane */