00001
00002
00003 #include "orbsvcs/Event/EC_Kokyu_Factory.h"
00004 #include "orbsvcs/Event/EC_Kokyu_Dispatching.h"
00005 #include "orbsvcs/Event/EC_Kokyu_Scheduling.h"
00006 #include "orbsvcs/Event/EC_Kokyu_Filter_Builder.h"
00007 #include "orbsvcs/Event/EC_Event_Channel_Base.h"
00008 #include "orbsvcs/RtecSchedulerC.h"
00009
00010 #include "ace/Arg_Shifter.h"
00011 #include "ace/Sched_Params.h"
00012 #include "ace/OS_NS_strings.h"
00013
00014 #if ! defined (__ACE_INLINE__)
00015 #include "orbsvcs/Event/EC_Kokyu_Factory.i"
00016 #endif
00017
00018 ACE_RCSID (Event,
00019 EC_Kokyu_Factory,
00020 "EC_Kokyu_Factory.cpp,v 1.12 2006/03/14 06:14:25 jtc Exp")
00021
00022 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00023
00024 TAO_EC_Kokyu_Factory::~TAO_EC_Kokyu_Factory (void)
00025 {
00026 }
00027
00028 int
00029 TAO_EC_Kokyu_Factory::init_svcs (void)
00030 {
00031 return ACE_Service_Config::static_svcs ()->
00032 insert (&ace_svc_desc_TAO_EC_Kokyu_Factory);
00033 }
00034
00035 int
00036 TAO_EC_Kokyu_Factory::init (int argc, ACE_TCHAR* argv[])
00037 {
00038 ACE_Arg_Shifter arg_shifter (argc, argv);
00039
00040 while (arg_shifter.is_anything_left ())
00041 {
00042 const ACE_TCHAR* arg = arg_shifter.get_current ();
00043
00044 if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECDispatching")) == 0)
00045 {
00046 arg_shifter.consume_arg ();
00047
00048 if (arg_shifter.is_parameter_next ())
00049 {
00050 const ACE_TCHAR* opt = arg_shifter.get_current ();
00051 if (ACE_OS::strcasecmp (opt, ACE_TEXT("reactive")) == 0)
00052 {
00053 this->dispatching_ = 0;
00054 }
00055 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("mt")) == 0)
00056 {
00057 this->dispatching_ = 1;
00058 }
00059 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("kokyu")) == 0)
00060 {
00061 this->dispatching_ = 2;
00062 }
00063 else
00064 {
00065 ACE_ERROR ((LM_ERROR,
00066 ACE_TEXT("EC_Kokyu_Factory - ")
00067 ACE_TEXT("unsupported dispatching <%s>\n"),
00068 opt));
00069 }
00070 arg_shifter.consume_arg ();
00071 }
00072
00073 if (this->dispatching_ == 2)
00074 {
00075 if (arg_shifter.is_parameter_next ())
00076 {
00077 const ACE_TCHAR* opt = arg_shifter.get_current ();
00078 if (ACE_OS::strcasecmp (opt, ACE_TEXT("SCHED_FIFO")) == 0)
00079 {
00080 this->disp_sched_policy_ = ACE_SCHED_FIFO;
00081 }
00082 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("SCHED_RR")) == 0)
00083 {
00084 this->disp_sched_policy_ = ACE_SCHED_RR;
00085 }
00086 else
00087 {
00088 this->disp_sched_policy_ = ACE_SCHED_OTHER;
00089 }
00090 arg_shifter.consume_arg ();
00091
00092 if (arg_shifter.is_parameter_next ())
00093 {
00094 const ACE_TCHAR* opt = arg_shifter.get_current ();
00095 if (ACE_OS::strcasecmp (opt, ACE_TEXT("SYSTEM")) == 0)
00096 {
00097 this->disp_sched_scope_ = ACE_SCOPE_THREAD;
00098 }
00099 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("PROCESS")) == 0)
00100 {
00101 this->disp_sched_scope_ = ACE_SCOPE_PROCESS;
00102 }
00103 arg_shifter.consume_arg ();
00104 }
00105 }
00106 }
00107 }
00108
00109 else if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECFiltering")) == 0)
00110 {
00111 arg_shifter.consume_arg ();
00112
00113 if (arg_shifter.is_parameter_next ())
00114 {
00115 const ACE_TCHAR* opt = arg_shifter.get_current ();
00116 if (ACE_OS::strcasecmp (opt, ACE_TEXT("null")) == 0)
00117 {
00118 this->filtering_ = 0;
00119 }
00120 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("basic")) == 0)
00121 {
00122 this->filtering_ = 1;
00123 }
00124 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("prefix")) == 0)
00125 {
00126 this->filtering_ = 2;
00127 }
00128 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("kokyu")) == 0)
00129 {
00130 this->filtering_ = 3;
00131 }
00132 else
00133 {
00134 ACE_ERROR ((LM_ERROR,
00135 ACE_TEXT("EC_Kokyu_Factory - ")
00136 ACE_TEXT("unsupported filtering <%s>\n"),
00137 opt));
00138 }
00139 arg_shifter.consume_arg ();
00140 }
00141 }
00142
00143 else if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECTimeout")) == 0)
00144 {
00145 arg_shifter.consume_arg ();
00146
00147 if (arg_shifter.is_parameter_next ())
00148 {
00149 const ACE_TCHAR* opt = arg_shifter.get_current ();
00150 if (ACE_OS::strcasecmp (opt, ACE_TEXT("reactive")) == 0)
00151 {
00152 this->timeout_ = 0;
00153 }
00154 #if 0
00155 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("kokyu")) == 0)
00156 {
00157 this->timeout_ = 1;
00158 }
00159 #endif
00160 else
00161 {
00162 ACE_ERROR ((LM_ERROR,
00163 ACE_TEXT("EC_Kokyu_Factory - ")
00164 ACE_TEXT("unsupported timeout <%s>\n"),
00165 opt));
00166 }
00167 arg_shifter.consume_arg ();
00168 }
00169 }
00170
00171 else if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECScheduling")) == 0)
00172 {
00173 arg_shifter.consume_arg ();
00174
00175 if (arg_shifter.is_parameter_next ())
00176 {
00177 const ACE_TCHAR* opt = arg_shifter.get_current ();
00178 if (ACE_OS::strcasecmp (opt, ACE_TEXT("null")) == 0)
00179 {
00180 this->scheduling_ = 0;
00181 }
00182 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("group")) == 0)
00183 {
00184 this->scheduling_ = 1;
00185 }
00186 else if (ACE_OS::strcasecmp (opt, ACE_TEXT("kokyu")) == 0)
00187 {
00188 this->scheduling_ = 2;
00189 }
00190 else
00191 {
00192 ACE_ERROR ((LM_ERROR,
00193 ACE_TEXT("EC_Kokyu_Factory - ")
00194 ACE_TEXT("unsupported scheduling <%s>\n"),
00195 opt));
00196 }
00197 arg_shifter.consume_arg ();
00198 }
00199 }
00200
00201 else
00202 {
00203 arg_shifter.ignore_arg ();
00204 }
00205 }
00206 return this->TAO_EC_Default_Factory::init (argc, argv);
00207 }
00208
00209 int
00210 TAO_EC_Kokyu_Factory::fini (void)
00211 {
00212 return 0;
00213 }
00214
00215
00216
00217 TAO_EC_Dispatching*
00218 TAO_EC_Kokyu_Factory::create_dispatching (TAO_EC_Event_Channel_Base *ec)
00219 {
00220 if (this->dispatching_ == 2)
00221 return new TAO_EC_Kokyu_Dispatching (ec,
00222 this->disp_sched_policy_,
00223 this->disp_sched_scope_);
00224 return this->TAO_EC_Default_Factory::create_dispatching (ec);
00225 }
00226
00227 TAO_EC_Filter_Builder*
00228 TAO_EC_Kokyu_Factory::create_filter_builder (TAO_EC_Event_Channel_Base *ec)
00229 {
00230 if (this->filtering_ == 3)
00231 return new TAO_EC_Kokyu_Filter_Builder (ec);
00232
00233 return this->TAO_EC_Default_Factory::create_filter_builder (ec);
00234 }
00235
00236
00237 TAO_EC_Timeout_Generator*
00238 TAO_EC_Kokyu_Factory::create_timeout_generator (TAO_EC_Event_Channel_Base *ec)
00239 {
00240 #if 0
00241 if (this->timeout_ == 1)
00242 {
00243
00244 }
00245 #endif
00246 return this->TAO_EC_Default_Factory::create_timeout_generator (ec);
00247 }
00248
00249 TAO_EC_Scheduling_Strategy*
00250 TAO_EC_Kokyu_Factory::create_scheduling_strategy (TAO_EC_Event_Channel_Base* ec)
00251 {
00252 if (this->scheduling_ == 2)
00253 {
00254 CORBA::Object_var tmp = ec->scheduler ();
00255 RtecScheduler::Scheduler_var scheduler =
00256 RtecScheduler::Scheduler::_narrow (tmp.in ());
00257 return new TAO_EC_Kokyu_Scheduling (scheduler.in ());
00258 }
00259 return this->TAO_EC_Default_Factory::create_scheduling_strategy (ec);
00260 }
00261
00262 TAO_END_VERSIONED_NAMESPACE_DECL
00263
00264
00265
00266 ACE_STATIC_SVC_DEFINE (TAO_EC_Kokyu_Factory,
00267 ACE_TEXT ("EC_Factory"),
00268 ACE_SVC_OBJ_T,
00269 &ACE_SVC_NAME (TAO_EC_Kokyu_Factory),
00270 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00271 0)
00272 ACE_FACTORY_DEFINE (TAO_RTKokyuEvent, TAO_EC_Kokyu_Factory)